The Museum of HP Calculators

HP Forum Archive 15

[ Return to Index | Top of Index ]

33s -- Newton's Method
Message #1 Posted by Tim Wessman on 19 July 2005, 4:01 p.m.

As my teacher was talking (for a rather long time--I've teaken the class before) about newton's method in calculus I started trying to make a program on my 33s for calculating it step by step. I know the solver does basically the same thing, but it was really driving me nuts that I couldn't get something working.

Does anyone have a working newton's method program on their calcs that I could look at for starting? I haven't done much programming yet on the 33s. Is there a way to evaluate an equation from my list? Or would I have to edit my program for each equation?

TW

      
Re: 33s -- Newton's Method
Message #2 Posted by José Lauro Strapasson on 19 July 2005, 8:28 p.m.,
in response to message #1 by Tim Wessman

Here is a program to calculate with Newton methold. It is not for 33S but for Ada95 language (like Pascal), maybe it helps.

P.S. I have a 33S too (not that bad) I will try on it too!:)

with Ada.Float_Text_IO, Ada.Numerics.Elementary_Functions, Text_IO, Ada.Integer_Text_IO; use Ada.Float_Text_IO, Ada.Numerics.Elementary_Functions, Text_IO, Ada.Integer_Text_IO;

procedure Newton is

X1:Float; N:Integer;

function Funcao (X:Float) return Float is Y:Float; begin --Put here your function Y:=(abs(X))**2.0 - 5.0 * X + 4.0; return Y; end Funcao;

function Derivada (X:Float) return Float is YLinha,variacao:Float; begin Variacao:=abs(X/1000.0); --This gives the precision. YLinha:=(Funcao(X+Variacao)-Funcao(X))/Variacao; return Ylinha; end Derivada;

begin Put_Line("Enter X1 (not zero)"); Get(X1); Put_Line("Enter the number of interactions:"); Get(N);

for A in 1..N loop Put_Line("F(X" & Integer'Image(A) & ") is : "); Put(Funcao(X1)); New_Line; Put_Line("F'(X" & Integer'Image(A) & ") is : "); Put(derivada(X1)); New_Line; Put_Line("X" & Integer'Image(A+1) & " vale: "); X1:=X1- (Funcao(X1)/derivada(X1)); Put(X1); New_Line; end loop;

end Newton;

      
Re: 33s -- Newton's Method
Message #3 Posted by José Lauro Strapasson on 19 July 2005, 9:35 p.m.,
in response to message #1 by Tim Wessman

Hi!

Here is your program. Write your function in program F using X as RCL X. (In the case shown it is x^2-5x+4) Put the initial value in A memory (STO A) Then XEQ N, XEQ N, XEQ N! Have fun!

José Lauro.

P.S. 1000.000 is for the derivative. To create the delta. P.S.2 Could someone delete my other message? Thank you!

LBL F RCL X 2 y^x RCL X 5 x - 4 + RTN

LBL D RCL A 1000000 / STO V RCL A RCL V + STO X XEQ F STO D RCL A STO X XEQ F STO –D RCL V STO / D RCL D RTN

LBL N RCL A STO X XEQ F STO N RCL A STO X XEQ D STO / N RCL A RCL N - STO A RTN

      
Re: 33s -- Newton's Method
Message #4 Posted by Karl Schneider on 20 July 2005, 2:52 a.m.,
in response to message #1 by Tim Wessman

Tim --

The 33S, as well as the predecessor 32SII and 32S upon which it was based, all include the SOLVE function. Therefore, I doubt that there would be a Newton's Method program in the manuals, because such a capability is already built in.

The programming and letter-variable paradigm is unique to those three models. However, there is an RPN-based Newton's Method program starting on p. 154 of the HP-11C manual.

Also, there are TVM Equation programs in the HP-11C manual (starting on p. 189) and in the HP-41 Finance and Advantage ROM's. These programs include code to iteratively solve for interest rate in terms of the other four variables, since no direct equation can be derived.

The HP-11C manual is on CD #1 of the MoHPC set for purchase.

-- KS

            
Re: 33s -- Newton's Method
Message #5 Posted by Tim Wessman on 20 July 2005, 10:16 a.m.,
in response to message #4 by Karl Schneider

thanks for the program, and the info. It gives me a place to start at so I can see how to start programming this little beast. =)

TW


[ Return to Index | Top of Index ]

Go back to the main exhibit hall