Basic question on verbifying expressions



Rodrigo da Silva Guerra <tioguerra at gmail.com> writes:
> /* I was calculating a Laplace transform, like below: */
> ex1:exp(-3*t)*'diff(x(t),t);
> lap_ex1:laplace(ex1,t,s);
>
> /* Then I added an initial condition: */
>
> atvalue(x(t),t=0,0);
>
> /* And I managed to re-evaluate the expression: */
>
> lap_ex1:ev(lap_ex1);

Following you so far, I get:

(%i4) lap_ex1:ev(lap_ex1);
                                                !
(%o4)               (s + 3) (laplace(x(t), t, s)!         )
                                                !s = s + 3

> /* Now I what I wanted to do is to plug an specific x(t) into that
> expression: */
>
> x(t):=1
>

The easiest way to do this sort of thing is syntactically: instead of
saying to Maxima "please resimplify the expression, knowing also that
x(t)=1", just say "replace all occurrences of x(t) with 1 in here".

(%i5) subst(x(t)=1, lap_ex1);
                                      !
(%o5)                (laplace(1, t, s)!         ) (s + 3)
                                      !s = s + 3

This has the added benefit of not clobbering x(t) for future work: maybe
you want to look at the laplace transform for other functions too (eg
using the Laplace transform's linearity and expanding a periodic
function as a sum of trig functions or whatever)

Of course, you need to tell the laplace code to get run again (what
looks like a function call in %o5 is actually a noun form, as I guess
you've realised, given the title of the thread).

(%i6) %, nouns;
(%o6)                                  1

Tada! If you want to read more about this, have a look at the
documentation for the ev function. The line "expr, nouns" is just a
shorthand for "ev(expr, nouns)".

Rupert
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 315 bytes
Desc: not available
URL: <http://www.math.utexas.edu/pipermail/maxima/attachments/20120419/e7ccfc3a/attachment-0001.pgp>;