Post Reply 
1st program with problems "Euler Method"
12-26-2019, 12:21 AM
Post: #1
1st program with problems "Euler Method"
I was told that an Euler's method program would be easy to make... On this forum? Somewhere... anyway that doesn't matter. I think it should be an easy program.

I'm getting an Invalid Input error and I think it has something to do with passing a function. I have this 'slopefield' app that someone wrote and I tried to pass the function the same way he did it... But it doesn't work for me in this instance.

By the way... I'm just learning about differentials AND programming. So maybe I'm doing something all wrong.

Obviously there would be a return or a print of s after the loop finishes. I didn't get that far in programming yet.

While previewing the post, I just had a thought... 'maybe I'm doing the matrix wrong.'

Code:

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

END;

END;

sample input
Code:

eulerm("(3-y)*(y+1)",0,4,1,5)
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
1st program with problems "Euler Method" - oneletterz - 12-26-2019 12:21 AM



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