RE : Changing variables



> Moby wrote:
> >
> > Raymond Toy wrote:
> >> Moby wrote:
> >>
> >>> I have what is probably a very simple question.  I have a function
> >>> defined in Maxima, say the following:
> >>>
> >>> G(s) := 1/(3*s^2+2*s+1)
> >>>
> >>> Now I would like to define a variable r such that
> >>>
> >>> r^2 = 3*s^2
> >>>
> >>> and then define G(s) in terms of this new variable r.  How does one go
> >>> about achieving this in Maxima?
> >>>
> >> Perhaps this will help:
> >>
> >> subst([s = r/sqrt(3)], 1/(3*s^2+2*s+1))
> >> -> 1/(r^2+2*r/sqrt(3)+1)
> >>
> >> Ray
> >>
> >>
> >>
> > Many thanks Raymond - is it possible to have Maxima itself work out the
> > first paramter, namely the value of s in terms of r?
> 
> I kind of purposely didn't have maxima solve for s in terms of r for
> your substitution.  But you can do it via solve:
> 
> soln:solve(r^2=3*s^2,s) ->
> [s = -r/sqrt(3), s = r/sqrt(3)]
> 
> I assume you want the second solution, so we can do something like
> 
> subst(soln[2], 1/(3*s^2+2*s+1))
> 
> to get the answer.
> 
> There may be better ways....
> 
> Ray

One others way:

solve(eliminate([G(s) = 1/(3*s^2+2*s+1), r^2 = 3*s^2], [s]), G(s));

Laurent.
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima