For starting with Maxima programming, there is Boris Gaertner's tutorial at
http://maxima.sourceforge.net/docs/tutorial/en/gaertner-tutorial-revision/Pages/Programming0001.htm
or you can just browse through *.mac and *.lisp in the Maxima directory
tree.
-Alasdair
On 3/31/07, Zoho Vignochi <zoho.vignochi at gmail.com> wrote:
>
> Hello,
>
> I am looking for a good tutorial on the Maxima programming language. As
> well as some sample code. I am currently in the process of porting a
> simple Maple program to Maxima and I could use some help regarding
> arrays.
>
> Here is the maple code snipit in question:
>
> step:=proc(lambda,alpha)
> #
> # Given lambda and alpha, solve the differential
> # equation subject to the first boundary condition
> # returning psi(0.5) and d/d lambda psi(0.5).
> #
> local i,h;
> global a,ap,n,these;
> h:=1/(2*n); # The step size.
> a:=array(0..3); ap:=array(0..3); # The coefficients and their
> for i from 0 to 3 do # derivatives.
> a[i]:=array(0..n); ap[i]:=array(0..n);
> end do;
> a[0][0]:=alpha; a[1][0]:=0; a[2][0]:=-lambda/2*sin(a[0][0]);
> a[3][0]:=0;
> ap[0][0]:=0; ap[1][0]:=0; ap[2][0]:=-0.5*sin(alpha); ap[3][0]:=0;
> for i from 1 to n do
> a[0][i]:=a[0][i-1]+a[1][i-1]*h+a[2][i-1]*h^2;
> a[1][i]:=a[1][i-1]+2*a[2][i-1]*h+3*a[3][i-1]*h^2;
> a[2][i]:=-lambda/2*sin(a[0][i]);
> a[3][i]:=-lambda/6*cos(a[0][i])*a[1][i];
> ap[0][i]:=ap[0][i-1]+ap[1][i-1]*h+ap[2][i-1]*h^2;
> ap[1][i]:=ap[1][i-1]+2*ap[2][i-1]*h+3*ap[3][i-1]*h^2;
> ap[2][i]:=-0.5*sin(a[0][i])-lambda/2*cos(a[0][i])*ap[0][i];
> ap[3][i]:=-1/6*cos(a[0][i])*a[1][i]+lambda/6*sin(a[0][i])*ap[0][i]*a[1][i]
> -lambda/6*cos(a[0][i])*ap[1][i];
> end do;
> these:=[]; # Points on psi for plotting.
> for i from 0 to n do
> these:=[op(these),[i*h,a[0][i]]];
> end do;
> [a[0][n],ap[0][n]];
> end proc;
>
> I have not including the other proc's. It is the declaration of the
> array's which is giving me trouble. I believe that Maxima can have an
> array of arrays but I have been unable to locate an example of how to do
> this.
>
> Any help appreciated and thank you for your time.
>
> Zoho
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>