[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Axiom-math] (no subject)
From: |
cf |
Subject: |
[Axiom-math] (no subject) |
Date: |
Sun, 5 Dec 2004 17:11:16 +0200 |
5 December 2004
Dear Colleagues,
I have started slowly translating my Matlab programs to axiom, and
am experiencing some difficulties. The type system of axiom is
very advanced. However, its not clear to me at this stage
how to implement in axiom certain basic operations that I can
implement relatively easily in Matlab. I have written a test program
file test.input with some questions (as comments) and pasted this
below.
You can run this in axiom with: )read test.input;
--Test program file test.input for basic manipulations.
--qi, i=1,..,n=3 are the generalized co-ordinates (functions of time t),
--and pi = derivative of qi wrt to time t, i=1,..,n=3.
--In Matlab it is possible to "convert" strings to symbolic variables
--as follows: n=3; qt = sym(zeros(n,1)); pt = sym(zeros(n,1));
--for i=1:n, qt(i)=sym(['q',int2str(i),'(t)']);
--pt(i) = sym(['p',int2str(i),'(t)']); end;
-- IS THERE A WAY OF DOING THE ABOVE IN AXIOM ??? So far I could only
--find the following method.
q1:=operator 'q1
q2:=operator 'q2
q3:=operator 'q3
p1:=operator 'p1
p2:=operator 'p2
p3:=operator 'p3
gt := q1(t)*q1(t) + p1(t)*sin(q2(t)) + p2(t)*cos(q3(t)) + p3(t)
dgtdt:= D(gt,t)
dgtdt := (rule D(q1(t),t) == p1(t)) dgtdt;
dgtdt := (rule D(q2(t),t) == p2(t)) dgtdt;
dgtdt := (rule D(q3(t),t) == p3(t)) dgtdt
--I want to "supress the t" in the expression gt and
--obtain: g = q1*q1 + p1*sin(q2) + p2*cos(q3) + p3.
--Then take the derivative of g wrt the qi's, and pi's, i=1,..,n=3.
--In Matlab I do this as follows:
--q = sym(zeros(n,1)); p = sym(zeros(n,1));
--for i=1:n, q(i)=sym(['q',int2str(i)]); p(i) = sym(['p',int2str(i)]);
--end;
--g = subs(g,qt,q); g = subs(g,pt,p);
--IS THERE A WAY OF DOING THE ABOVE IN AXIOM ??? So far I could only find
--the following method.
g := (rule (q1(t) == qw1; q2(t) == qw2; q3(t) == qw3; p1(t) == pw1; p2(t)
== pw2; p3(t) == pw3))gt
dgdqw1 := D(g,qw1)
dgdqw2 := D(g,qw2)
dgdqw3 := D(g,qw3)
dgdpw1 := D(g,pw1)
dgdpw2 := D(g,pw2)
dgdpw3 := D(g,pw3)
--end of program.
Thanks very much.
Regards,
C. Frangos.
------
Constantine Frangos.
Professor
Dept. of Mathematics and Statistics
Rand Afrikaans University
P O Box 524
Auckland Park 2006
South Africa
Tel: +27-11-489-2452
Fax: +27-11-489-2832
e-mail: address@hidden (work)
address@hidden (home)
- [Axiom-math] (no subject),
cf <=