load(diffeq)$
load(lrats)$

Elektrochemistry :appendix1 (system odes 'rk',numerical,version 1.0)
peter.vlasschaert@gmail.com,12/03/2019

How to solve , system of odes : (numerical method).
============================================

find help 'rk' from above packages.
-----------------------------------------------------

? rk;

we have two first order : odes  (ordinary differential equations ) ,system.

system : odes
----------------------

1e  ODE   :  dx/dt = 4 - x^2 - y^2
2e  ODE   :  dy/dt = y^2 - x^2 + 1

f(x,y) :=4 - x^2 - y^2;
g(x,y) := y^2 - x^2 + 1;

variable
------------

var_1 : x;
var_2 : y;

var_n:[var_1,var_2];

initial condition ( by start value =  't=0')
----------------------------------------------------------
x0 = -1.25
y0 = 0.75

x0:-1.25;
y0: 0.75;

ic:[x0,y0];

simulation range : var ,start_ value , end_ value ,step _value ( dt  = > time)
----------------------------------------------------------------------------------------------------------------
variable      = t    (  from  dt)  here  'var'
start_ value = 0
end_ value = 4
step_value = 0.02

list values (select : other values , to much output. 'below' otherwise)
   for 'sr'

var: t;
start_value : 0;
end_value  : 1.4;
step_value : 0.2;

sr :[var,start_value,end_value,step_value];

how to solve  ' load packages : see above '
====================================

1e)  simulation  ' use rk from packages '
------------------------------------------------------------

sol : rk([f(x,y),g(x,y)],var_n,ic,sr)$

number items in the list
-----------------------------------

q1: length(sol);

list : sol
=======

ptxy :for i:1 thru q1 do(
        print(sol[i]));

2e)  output (use discrete plot)
--------------------------------------------

data (t,x(t))
=========

ptx:for i:1 thru q1 do(
print(makelist([p[1],p[2]],p,sol)[i]));

plot  x = x(t)
-----------------

p1: wxplot2d ([discrete,makelist([p[1],p[2]],p,sol)], [xlabel,"t"],[ylabel,"x"])$

data (t,y(t))
=========

pty:for i:1 thru q1 do(
print(makelist([p[1],p[3]],p,sol)[i]));

plot :y = y(t)
-----------------

p2:wxplot2d ([discrete,makelist([p[1],p[3]],p,sol)], [xlabel,"t"],[ylabel,"y"])$

'----------------------------------------------------------------------------------------------------------------------