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;
