Programming examples « Next Oldest | Next Newest »

 ▼ Han Unregistered Posts: 709 Threads: 104 Joined: Nov 2005 10-21-2013, 10:09 PM Newton's Method implemented several ways. Videos of the programming: Click the video description for parts 2 and 3. Source code below. Style 1: Expect user to enter function into F1 in the function app, and guess and tolerance are hardcoded. Style 2: Provide a graphical interface for user input; automatically creates UI when run from program catalogue Style 3: Bypass graphical interface; create a function instead Style 4: Expect f(x) in F1 but still have function interface for Newton's Method (to get around a small issue with running from program catalogue) Style 1: Initial attempt as a solution to a specific problem ```export NEWT() begin local n,xold,xnew,err; err:=.000001; n:=0; xnew:=2; xold:=xnew-2*err; F0:=expr("'X-F1(X)/(" + diff(F1(X),X) + ")'"); L1:={}; while (abs(xnew-xold)>err and n<100) do n:=n+1; L1(n):=xnew; xold:=xnew; xnew:=F0(xold); end; L1(n+1):=xnew; end;``` Syle 2: Creating a user interface ```export NEWT2() begin local n,xold,xnew,err,N,f; N:=100; err:=.00001; xnew:=1; if input( {f,xnew,err,N}, "Newton's Method", {"f(X)=", "Guess=", "Error=", "Max Iter.="}, { "Enter the function surrounded by single quotes", "Enter the initial guess", "Enter the tolerance", "Enter the maximum number of iterations" }, {f,xnew,err,N} ) then F1:=f; CAS("F0:=id-F1/F1'"); L1:={}; L1(1):=xnew; for n from 2 to N+1 do xold:=xnew; xnew:=F0(xold); L1(n):=xnew; if abs(xnew-xold)

 Possibly Related Threads… Thread Author Replies Views Last Post Prime program examples Gilles Carpentier 10 2,829 07-24-2013, 05:55 PM Last Post: Gilles Carpentier WP34s-matrix examples jason foose 8 2,373 11-19-2012, 05:18 PM Last Post: Marcus von Cube, Germany Examples for matrix operations on WP34S?? Namir 6 2,197 06-18-2012, 10:04 PM Last Post: Palmer O. Hanson, Jr. 7470A Plotter Programming Examples DavidShenk 2 1,183 06-04-2010, 11:10 AM Last Post: DavidShenk HPGCC 2 Tutorial Updated with Vista, OS/X, More Examples Egan Ford 0 798 12-01-2008, 02:02 AM Last Post: Egan Ford HP 71B/HP-IL/RS-232 examples? Egan Ford 1 903 03-25-2007, 05:30 PM Last Post: Raymond Del Tondo Custom Programming vs. Pre-packaged programming Eddie Shore 3 1,495 01-24-2005, 03:42 AM Last Post: Karl Schneider RPN vs. AOS: *GOOD* examples [LONG] Valentin Albillo 2 1,084 10-08-2003, 05:22 AM Last Post: Valentin Albillo 3468A - IL programming examples? Chris morris 3 1,254 11-22-1999, 03:42 PM Last Post: Chris Morris hp48g gx where i can read good examples and have information to build programs to hp48g gustavo 2 1,114 07-15-1999, 10:50 PM Last Post: Wayne Brown

Forum Jump: