El Martes, 18 de Octubre de 2005 21:14, Ron Crummett escribió:
> Hi -
>
> I am a college student who discovered Maxima recently and think it is
> great. A lot of power, for not a lot of money. Not bad.
>
> Still, I find myself needing to do some things that I would like to do
> with Maxima, and I am wondering if they are possible. First of all, I
> am taking an advanced electromagnetics class and we work with vector
> operations a lot, particularly curl, divergence, gradient and
> laplacian. I have not seen any description of these functions in my
> searches. It doesn't seem like it would be too terribly hard to write,
> but I don't know how to write functions in Maxima, and how I could have
> them automatically load up when I start.
>
> Secondly, I am taking a control systems class in which we use Bode
> diagrams frequently. Generally we do all of our work in Matlab, but one
> person likes to use MathCad and it occurred to me that Maxima might be
> able to do some of this, if Bode plots can be done. Not a lot on that
> subject either. So, do any of you more experienced Maxima users have
> some suggestions for me on what I can do, where I can to, to satisfy
> these needs? Thanks a ton.
>
> -Ron Crummett
>
Sorry, can't help with Bode plots. But regarding the first part of your
question, look at the following maxima session:
(%i1) /* gradient */
nabla(f,[v]):=block([n],
n:length(v),
makelist(diff(f,v[i]),i,1,n))$
(%i2) /* laplacian */
nabla2(f,[v]):=block([n],
n:length(v),
sum(diff(f,v[i],2),i,1,n))$
(%i3) /* divergence */
div(f,[v]):=block([n],
n:length(v),
if not listp(f) or n # length(f)
then error("Illegal input"),
sum(diff(f[i],v[i]),i,1,n))$
(%i4) /* curl */
rot(f,[v]):=block([n],
n:length(v),
if not listp(f) or n # 3 or n # length(f)
then error("Wrong input"),
[diff(f[3],v[2])-diff(f[2],v[3]),
diff(f[1],v[3])-diff(f[3],v[1]),
diff(f[2],v[1])-diff(f[1],v[2])] )$
(%i5) /* Some examples follow */
nabla(x*y^2+2*y*z*t+sin(x*t),x,y,z,t);
2
(%o5) [y + t cos(t x), 2 t z + 2 x y, 2 t y, 2 y z + x cos(t x)]
(%i6) %,x=2,y=3,z=1,t=0;
(%o6) [9, 12, 0, 8]
(%i7) nabla(f(u,v,w),u,v,w);
d d d
(%o7) [-- (f(u, v, w)), -- (f(u, v, w)), -- (f(u, v, w))]
du dv dw
(%i8) nabla2(f(u,v,w),u,v,w);
2 2 2
d d d
(%o8) --- (f(u, v, w)) + --- (f(u, v, w)) + --- (f(u, v, w))
2 2 2
dw dv du
(%i9) div([3*x*y,x^2*z,-y^2*exp(2*z)],x,y,z);
2 2 z
(%o9) 3 y - 2 y %e
(%i10) %,x=1,x=2,z=0;
2
(%o10) 3 y - 2 y
(%i11) %,x=1,y=2,z=0;
(%o11) - 2
(%i12) depends([Fx,Fy,Fz],[x,y,z]);
(%o12) [Fx(x, y, z), Fy(x, y, z), Fz(x, y, z)]
(%i13) rot([Fx,Fy,Fz],x,y,z);
dFz dFy dFx dFz dFy dFx
(%o13) [--- - ---, --- - ---, --- - ---]
dy dz dz dx dx dy
Hope this helps.
Mario
--
--------------------------
Mario Rodriguez Riotorto
www.biomates.net