Subject: Distributing trig functions over a matrix
From: TonyJOlivo at Eaton.com
Date: Wed, 13 Aug 2008 15:08:45 -0400
Hi,
I'm working on using Maxima for a sort of manual optimization operation.
I have two variables for which I have a handful of values, and I'd like
to evaluate some derived parameters based on the different combinations.
What I've set up below are some functions that can be evaluated for
single values, or plotted vs. t (or any one other variable I guess).
What I've done below is set up an array of the values I'd like to
evaluate for R and C, and manipulated them into matrices that look
like...
R | 1 2 |
| 1 2 |
| 1 2 |
C | 3 3 |
|.5 .5 |
| 4 4 |
So I something like R*C would give the a 3x2 matrix of each element of R
multiplied by each element of C. Here are the inputs I give maxima.
w(l,c) := 1/sqrt(l*c);
a(r,l) := r*1/(2*l);
q(r,l,c) := w(l,c)^2-a(r,l)^2;
i(t,r,l,c,V) := V*exp(-a(r,l)*t)/(l*q(r,l,c))*sin(q(r,l,c)*t);
tmax(r,l,c) := %pi/(2*q(r,l,c));
R : [1,2];
C : [3,.5,4];
R : matrix(R,R,R);
C : transpose(C);
C : addcol(C,C);
L : 70e-6;
V: 480;
i(tmax(R,L,C),R,L,C,V)
The problem I have is for the i() function, the sin function does not
distribute over each element of the matrix in the same way a function
like exp() would. Instead the result I get would be something like...
sin([1 2])*[8 9]
[3 4] [7 6]
Instead of...
[sin(1)*8 sin(2)*9]
[sin(3)*7 sin(4)*6]
I have tried reading the help file further on the doallmxops variables
and listarith and the like, but have yet to find anything that makes the
sin distribute. If all else fails I should be able to write some code
that will manually distribute the operation, but I feel like that could
be a fairly specific solution and this is a method I could apply in the
future to different problems.
The reasons I want to evaluate the function in this way instead of using
a plot3d of i() vs. r and c (which I have done) is that it's easier for
me to document my design work with just the values in something like a
spreadsheet format vs. a plot graphic. Also R and C are discrete
electronic components whose values are not evenly distributed, so it
makes it a little tricky to pick out the function's value for a given
combination of R and C when working with a 3d plot.
If anyone has any advice on distributing the sin and other trig
functions over a matrix, or any other way I might come at this problem
using Maxima, I would greatly appreciate it. I have been using Maxima
quite a bit for my work and really like the way it handles functions and
plotting.
-Tony Olivo