kill(all)$
load(lrats)$
load(vect)$

numerical methods ' eulerdiffeq ' , version 1.0
peter.vlasschaert@gmail.com, 04/10/2018

ODE                       : y'       =   f(x,y) = f
Initial Condition  : y(x0) =   y0

algorithm :  euler method. 'first order differential equations'
==================================================

eulerdiffeq(f,x0,y0,h,nsteps):= block(
[i,x,y],
x:makelist(0,i,1,nsteps+1,1),
y:makelist(0,i,1,nsteps+1,1),  
    x[1] : x0,
    y[1] : y0,
for i:1 thru nsteps do (
      x[i+1] : x[i] + h,
      y[i+1]  :y[i]+  h*ev( f,x=x[i],y=y[i]) 
                                     ),
   return(m:[x,y])                                  
)$

How to use 'algo' , above.
---------------------------------------

initial values : x0,y0  : f(x0,y0)
=========================

find : f(x0,y0) = ?
==============

x0:0;
y0:2;

y0*sin(x0);

rhs of  differential equation (ODE)
============================

f:y*sin(x);

simulation 'interval' 
=================

step value : ?
============

h:0.1;

number of steps ?
===============

nsteps:10;

rem : number values = nsteps+1

eulerdiffeq(f,x0,y0,h,nsteps);

values : column = 2 ,row = 3   =>
------------------------------------------

m[2][3];

p2:m;

p3:length(m);

x values 'list': from 'output'
===========

p4:m[1];

number of x values 'list'
------------------------------------

p5:length(p4);

y values 'list': from 'output'
===========

p6:m[2];

number of y values 'list'
------------------------------------

p7:length(p6);

=>     : wxplot2d , ' discrete points '
=============================

wxplot2d([discrete,[[1,2],[2,4],[5,6],[8,5]]]);

how  to makelist of points to display on graph
=======================================

m1:makelist([m[1][i],m[2][i]],i,1,nsteps+1);

graphics : from solution from the above differential equation.
===================================================

p8:wxplot2d([discrete,m1],[style,lines],[color,blue]);
p8a:wxplot2d([discrete,m1],[style,points],[point_type,diamond],[color,red]);

rem : see plot2d help to find the option , legend,xlabel........

convert : ' list to matrix '
====================

matrix :
-----------

m2:matrix(m1);

points :
------------

m2[1,3];

x,y values :
-----------------

m2[1,3][1];
m2[1,3][2];