Post Reply 
1st program with problems "Euler Method"
12-26-2019, 08:44 PM
Post: #3
RE: 1st program with problems "Euler Method"
Quote:For the first three lines of your program, I think this is what you want:
Code:

Code:
EXPORT eulerm(funct,X0,Y0,ch,times)
BEGIN
 LOCAL a, s,check,x,y;
 CAS(EVAL("myfunct(x,y):="+funct));
 RETURN(myfunct('x','y'));
END;
With those changes,

eulerm("(3-y)*(y+1)",0,4,1,5) will return (y+1)*(-y+3)

Nothing after the return statement will be executed.

-road

Thank You roadrunner. I was able to get the program to run properly with your help. Then finding the debug softkey I was able to find out the matrices were incorrect too as they don't start with position [0,0].

The resulting display is good enough for me. But I would like to figure out a way to make it more user friendly. And maybe add in some functionality that allows the change to be negative. Something to tool around with in between quarters at school. The program operates fine on my physical device... But I'm getting a syntax error at s(a,2):=y+(f(x,y))*ch; right after 'f' on the PC emulated HP Prime. Like the variable isn't defined yet or something... i'm not sure.

Here is the proof of concept version of the Euler's Method program:
funct = the given equation
X0=initial x value
Y0=inital y value
ch=change in x
times = number of times the method is executed

Code:

EXPORT eulerm(funct,X0,Y0,ch,times)
BEGIN
LOCAL a, s,check,x,y;
CAS(EVAL("f(x,y):="+funct));
MAKEMAT(0,times,2)▶s[];
check=0;
FOR a FROM 1 TO times+1 DO
IF check==0 THEN
s(a,1):=X0;
s(a,2):=Y0;
check:=1;
ELSE
s(a,1):=s(a-1,1)+ch;
x:=s(a,1);
y:=s(a-1,2);
s(a,2):=y+(f(x,y))*ch; 
END;

END;
return s[];


END;
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: 1st program with problems "Euler Method" - oneletterz - 12-26-2019 08:44 PM



User(s) browsing this thread: 1 Guest(s)