Post Reply 
help: euler() prg on home mode
05-30-2017, 03:59 PM (This post was last modified: 05-30-2017 04:13 PM by toml_12953.)
Post: #2
RE: help: euler() prg on home mode
(05-30-2017 02:36 PM)compsystems Wrote:  Hello, the next numerical code, I want to run it in HOME MODE.

The definition v(t) does not allow me to define it within the code, Why?

PHP Code:
EXPORT euler()
BEGIN
    local g
,c,m,t;
    
local vi,ti,vf,tf;
        
local v;
    
purge(g,c,m,t,vi,ti,vf,tf);
    
g:=9.81c:=12.5m:=68.1;
    
v(t):= 'vi+(g-(c/m)*vi)*(t-ti)';
    
vi:=0;  ti:=0;
    
//print();
    
FOR tf FROM 0 TO 60 STEP 2 DO
        print(); 
// clear terminal view (output)
        
vf:=v(tf);
        print(
"vi = "+vi);
        print(
"ti = "+ti);
        print(
"tf = "+tf);
        print(
"vf("+tf+") = "+vf);
        print(
"");
        
vi:=vf;
        
ti:=tf;
        
wait();
    
END;
    return 
"Done";
END
Source: NUMERICAL METHODS FOR ENGINEERS Steven C. Chapra & Raymond P. Canale

euler (all lowercase) is a CAS function so I renamed it to EULER. Also, I'm not sure about your function definition. The following program works:

Code:
g;c;m;t;
vi;ti;vf;tf;

v(t)
BEGIN
    return vi+(g-(c/m)*vi)*(t-ti);
END;

EXPORT EULER()
BEGIN
    purge(g,c,m,t,vi,ti,vf,tf);
    g:=9.81; c:=12.5; m:=68.1;
    vi:=0; ti:=0;
    print();
    FOR tf FROM 0 TO 60 STEP 2 DO
        print();
        vf:=v(tf);
        print("vi = "+vi);
        print("ti = "+ti);
        print("tf = "+tf);
        print("vf("+tf+") = "+vf);
        print("");
        vi:=vf;
        ti:=tf;
        wait();
    END;
    return "Done";
END;

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: help: euler() prg on home mode - toml_12953 - 05-30-2017 03:59 PM



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