Does Prime support multistatement....... - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: HP Prime (/forum-5.html) +--- Thread: Does Prime support multistatement....... (/thread-5030.html) Does Prime support multistatement....... - toshk - 10-29-2015 10:21 PM 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. RE: Does Prime support multistatement....... - cyrille de brébisson - 10-30-2015 06:26 AM 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 RE: Does Prime support multistatement....... - Didier Lachieze - 10-30-2015 04:11 PM 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) … RE: Does Prime support multistatement....... - Han - 10-30-2015 05:03 PM (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. RE: Does Prime support multistatement....... - toshk - 10-30-2015 07:45 PM 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) RE: Does Prime support multistatement....... - Han - 10-30-2015 08:25 PM 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) RE: Does Prime support multistatement....... - toshk - 10-30-2015 11:31 PM (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... RE: Does Prime support multistatement....... - retoa - 11-01-2015 10:03 PM Hello ! Is there a way to use multistatement in RPN ?