[newbie] how to expand function to original variables
Subject: [newbie] how to expand function to original variables
From: Rupert Swarbrick
Date: Tue, 19 Feb 2013 12:08:08 +0000
Hugo Coolens <coolens at kahosl.be> writes:
> I have reworked the code as follows:
> p(tau11,tau22):=tau11*tau22;
> sigma(tau11,tau12,tau22):=tau11+tau12+tau22;
> A(p,sigma):=sqrt(p^2+2*p*sigma)-p;
> hjmax(A,sigma,p):=sqrt((1+A/p)/((1-A/sigma^2)^2+A/p));
> subst(sigma(tau11,tau12,tau22),sigma,hjmax);
> subst(p(tau11,tau22),p,hjmax);
>
> this gives me hjmax as a function of tau11, tau12 and tau22 which is
> what I wanted. I just wondered whether the last two statements can be
> combined in one?
Yep, see the documentation for subst. The other syntax is something like
subst ([foo1 = bar1, foo2 = bar2], expr)
And this does the same as the iterated substitution:
subst (bar1, foo1, subst (bar2, foo2, expr))
(Well, almost. If bar2 contains foo1, you get slightly different
behavior:
(%i42) subst (bar1, foo1, subst (foo1, foo2, foo2 + 1));
(%o42) bar1 + 1
(%i43) subst ([foo1 = bar1, foo2 = bar2], foo2 + 1);
(%o43) bar2 + 1
)
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/20130219/5e6ce65c/attachment.pgp>