Post Reply 
Does Prime support multistatement.......
10-29-2015, 10:21 PM (This post was last modified: 10-29-2015 10:22 PM by toshk.)
Post: #1
Does Prime support multistatement.......
say you want to know iterations (gauss-seidel method) of a function when you press enter each time .....without writing a program/codes. doable In Casio Fx.2....wondering in Hp prime.
Find all posts by this user
Quote this message in a reply
10-30-2015, 06:26 AM
Post: #2
RE: Does Prime support multistatement.......
Hello,

I am not sure what you are trying to achieve there, but Ans might be the key to your request.
type 1 ENTER
Ans+1 ENTER
and then press Enter repetitively, you get 2, 3, 4, ...

This might help you achieve what you are looking for.

Cyrille

Although I work for the HP calculator group, the views and opinions I post here are my own. I do not speak for HP.
Find all posts by this user
Quote this message in a reply
10-30-2015, 04:11 PM
Post: #3
RE: Does Prime support multistatement.......
As Cyrille explained you can use Ans to iterate a function:

Type the initial value of x ENTER
Type your function replacing x by Ans ENTER
Then press ENTER repetitively

For ex:

2 ENTER
2*Ans ENTER
ENTER
ENTER


Display:
2
4
8
16
32


But beware of Ans when dealing with CAS functions in Home (some details here) …
Find all posts by this user
Quote this message in a reply
10-30-2015, 05:03 PM (This post was last modified: 10-30-2015 05:22 PM by Han.)
Post: #4
RE: Does Prime support multistatement.......
(10-29-2015 10:21 PM)toshk Wrote:  say you want to know iterations (gauss-seidel method) of a function when you press enter each time .....without writing a program/codes. doable In Casio Fx.2....wondering in Hp prime.

Edit: the method below is an example of Jacobi iterations

Here's an example of Jacobi iterations, which is very similar to Gauss-Seidel:

Suppose you wish to solve the system:
\[
\begin{array}{rrrrcr}
10x_1 & -x_2 & + 2x_3 & & = & 6\\
-x_1 & + 11x_2 & -x_3 & +3x_4 & = & 25\\
2x_1 & - x_2 & +10x_3 & -x_4 & = & -11\\
& 3x_2 & -x_3 & +8x_4 & = & 15
\end{array}
\]

Solving for \( x_i \) in the i-th equation:
\[
\begin{array}{rcrrrrr}
x_1 & = & & \frac{1}{10}x_2 & -\frac{1}{5}x_3 & & \frac{3}{5}\\
x_2 & = & \frac{1}{11}x_1 & & \frac{1}{11}x_3 & -\frac{3}{11}x_4 & \frac{25}{11} \\
x_3 & = & -\frac{1}{5}x_1 & \frac{1}{10}x_2 & & \frac{1}{10}x_4 & -\frac{11}{10} \\
x_4 & = & & -\frac{3}{8}x_2 & \frac{1}{8}x_3 & & \frac{15}{8}
\end{array}
\]
Enter the following matrix into M1 using the matrix editor:

\[ \left[ \begin{array}{rrrrr}
0 & \frac{1}{10} & -\frac{1}{5} & 0 & \frac{3}{5}\\
\frac{1}{11} & 0 & \frac{1}{11} & -\frac{3}{11} & \frac{25}{11} \\
-\frac{1}{5} & \frac{1}{10} & 0 & \frac{1}{10} & -\frac{11}{10} \\
0 & -\frac{3}{8} & \frac{1}{8} & 0 & \frac{15}{8}\\
0 & 0 & 0 & 0 & 1
\end{array} \right] \]

Row i corresponds to the coefficients after solving for variable i in the i-the equation. The last row (all 0's and a 1 at the far right) is necessary in order for us to iterate using only the ENTER key. This system has solution (1,2,-1,1). In the Jacobi method, we start with an initial guess \( \langle x_1^{(0)}, x_2^{(0)}, x_3^{(0)}, x_4^{(0)} \rangle^T \) and substitute into the variables; this is equivalent to multiplying the matrix above by \( \langle x_1^{(0)}, x_2^{(0)}, x_3^{(0)}, x_4^{(0)}, 1 \rangle^T \). If we did not have the final row in the matrix above (call this matrix \( \overline{M1} \)), then
\[ \overline{M1} \cdot \langle x_1^{(0)}, x_2^{(0)}, x_3^{(0)}, x_4^{(0)}, 1 \rangle^T
= \langle x_1^{(1)}, x_2^{(1)}, x_3^{(1)}, x_4^{(1)} \rangle^T \]
However, we want the result of this multiplication to have the same form as our initial guess so that we can simply iterate with the ENTER key. So this is the reason for the final row in the matrix above. Note that
\[M1 \cdot \langle x_1^{(0)}, x_2^{(0)}, x_3^{(0)}, x_4^{(0)}, 1 \rangle^T
= \langle x_1^{(1)}, x_2^{(1)}, x_3^{(1)}, x_4^{(1)}, 1 \rangle^T \]

With M1 entered as shown above, here's how to iterate using only the ENTER key. Type:

[0,0,0,0,1] ENTER

This puts the initial guess of (0,0,0,0) into Ans. Now type:

M1*Ans ENTER

to get the first iteration [.6, 2.2727272727273, -1.1, 1.875, 1], and continue pressing ENTER to get the subsequent iterations until you finally see [1, 2, -1, 1, 1]. Remember that the last entry is just a "dummy" entry so that the solution is (1,2,-1,1). (For those wondering, we should have technically written our vector as a column vector, but it appears the Prime allows one to use row vectors and smartly interprets them as column vectors! This, of course, would not work for a row matrix, though)

The Gauss-Seidel method uses the next iteration for the lower triangular portion of the matrix M1. I'm curious how this could be done on the Casio without using a program.

Graph 3D | QPI | SolveSys
Find all posts by this user
Quote this message in a reply
10-30-2015, 07:45 PM
Post: #5
RE: Does Prime support multistatement.......
thanks guys!!!

this is my function x^4-19x^3+145x^2-378x+252=0
this is my acceleration = 1.25
guess=2
Gauss-Seidel in casio Fx; multistatements in FX2.0 are ":" and "tiny triangle symbol"
iterations;
1.8016
1.6067
1.4310
1.2872
1.1810
1.1098
1.0656
...
....
1.0076 (13th iteration)


Attached File(s) Thumbnail(s)
   
Find all posts by this user
Quote this message in a reply
10-30-2015, 08:25 PM (This post was last modified: 10-30-2015 08:30 PM by Han.)
Post: #6
RE: Does Prime support multistatement.......
The Prime equivalent of ":" is the semicolon ";" (assuming default settings). You can place an entire program on the command line on the HP Prime using ; to separate commands if you were so inclined.

For example:

X:=0; Y:=0; ENTER (this initializes X and Y to 0)

X:=X+1; Y:=2*X+Y+1; ENTER

Now repeatedly press ENTER to continue iterating both X and Y. Another way to store values is to use the ▶ which uses a "reversed" syntax and is similar to the Casio syntax.


In your case:

x = (x^4 - 19x^3 + 145x^2 + 252)/378

So you can do:

2▶X ENTER (would be the same as X:=2 ENTER)

(X^4-19*X^3+145*X^2+252)/378▶X ENTER

(Now keep pressing ENTER to see more iterations)

Graph 3D | QPI | SolveSys
Find all posts by this user
Quote this message in a reply
10-30-2015, 11:31 PM (This post was last modified: 11-02-2015 01:40 AM by toshk.)
Post: #7
RE: Does Prime support multistatement.......
(10-30-2015 08:25 PM)Han Wrote:  The Prime equivalent of ":" is the semicolon ";" (assuming default settings). You can place an entire program on the command line on the HP Prime using ; to separate commands if you were so inclined.

For example:

X:=0; Y:=0; ENTER (this initializes X and Y to 0)

X:=X+1; Y:=2*X+Y+1; ENTER

Now repeatedly press ENTER to continue iterating both X and Y. Another way to store values is to use the ▶ which uses a "reversed" syntax and is similar to the Casio syntax.


In your case:

x = (x^4 - 19x^3 + 145x^2 + 252)/378

So you can do:

2▶X ENTER (would be the same as X:=2 ENTER)

(X^4-19*X^3+145*X^2+252)/378▶X ENTER

(Now keep pressing ENTER to see more iterations)

thanks .....Han. it did work...
Find all posts by this user
Quote this message in a reply
11-01-2015, 10:03 PM
Post: #8
RE: Does Prime support multistatement.......
Hello !

Is there a way to use multistatement in RPN ?
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)