Roots2Eqns - find the roots of two nonlinear functions for the HP-42S

By Namir Shammas

Roots2Eqns is a program that finds the roots of 2 nonlinear functions. The program uses a straightforward version of Newton's algorithm:

Where

And,

G is G(x,y)

Fx is dF(x,y)/dx

Gx is dG(x,y)/dx

Fy is dF(x,y)/dy

Gy is dG(x,y)/dy

The program approximates the first derivatives of the functions. For example:

where

And,

where

- To start the program execute XEQ "RT2EQN"
- The program prompts you for the names of the function F(x,y) and G(x,y) in Alpha mode.
- To find the roots, execute XEQ B and respond to the prompts for the guesses, maximum number of iterations, and tolerance. The program will iterate and display the root, function values at the root, and the number of iterations.
- To select a new set of functions execute XEQ A and enter the new function names.

The label AA and BB implements the following sample functions:

Given

Allow 55 iterations at most and use a tolerance of 1E-7.

NAME F?

AA

RUN

NAME G?

BB

RUN

XEQ B

X?

0.10000 RUN

Y?

0.30000 RUN

TOLER?

1E-7 RUN

MAX ITER?

55.00000 RUN

0.10000,0.30000

1.23744,1.37667

0.72437,0.96429

0.53698,0.87197

0.50178,0.86611

0.50003,0.86603

0.50000,0.86603

0.50000,0.86603

X=0.50000

RUN

Y=0.86603

RUN

F=6.58752E-9

RUN

G=6.23685E-9

RUN

ITERS=8.00000

The program found roots at

R00 = Function name for F(x,y)

R01 = Function name for G(x,y)

R02 = x

R03 = y

R04 = hx (increment used to calculate the derivatives with respect to x)

R05 = hy (increment used to calculate the derivatives with respect to y)

R06 = F(x,y)

R07 = G(x,y)

R08 = dF/dx

R09 = dF/dy

R10 = dG/dx

R11 = dG/dy

R12 = Iters

R13 = Max Iters

R14 = Tolerance

R15 = Delta x

R16 = Delta y

R17 = J matrix

RT2EQN Main program label

AA Sample function F(x,y) label

BB Sample function G(x,y) label

A Supply function names

B Calculate root

00 Main loop

01 Show results

09 Calculate hx or hy

99 Display diverge message

Binary files for emulators:

Raw binary: roots2eqns.raw Binary for HP-42X: roots2eqns.42x (HP-48) roots2eqns49.42x (HP-49)

Generated by 42s2html - 10 May 2005, 20:01