How to transfer the solve data to another function
Subject: How to transfer the solve data to another function
From: Stavros Macrakis
Date: Sun, 15 Nov 2009 15:41:52 -0500
I'm not entirely sure I understand what you want... perhaps this:
(%i1) f(x):=x^2+a*x+b$
(%i2) sols: solve([f(1)=10,f(2)=5],[a,b]);
(%o2) [[a = -8,b = 17]]
Solve returns a *list* of solutions. In this case, the solution happens to
be unique.
''( ... ) evaluates ... and substitutes it into your input
(%i3) F(x):= ''( subst(sols[1],f(x)) );
(%o3) F(x):=x^2-8*x+17
You do not actually need to define programmatic functions f and F. You
could also do:
(%i1) expr: x^2+a*x+b$
(%i2) eqs: [ subst(x=1, expr=10), subst(x=2, expr=5) ];
(%o2) [b+a+1 = 10,b+2*a+4 = 5]
(%i3) sols: solve(eqs,[a,b]);
(%o3) [[a = -8,b = 17]]
(%i4) subst(sols[1],expr);
(%o4) x^2-8*x+17
I hope this is helpful. By the way, I recommend you avoid using commands
like
expr, %
(which internally call ev); ev often works well in simple cases, but can be
messy and complicated in less simple cases.
-s
2009/11/14 ? ?? <bear.tw at hotmail.com>
> How to transfer the solve data to another function?
>
> Q: f(x)=x^2+ax+b,f(1)=10,f(2)=5, solve f(x)=?
> I want to transfer the data of the solve([eq1,eq2]) to F(a,b) directly,
> don't input F(-8,17) by myself.
>
> How Can I to do?
>
> f(x):=x^2+a*x+b;
> F(a,b):=f(x);
> eq1:f(1)=10;
> eq2:f(2)=5;
> solve([eq1,eq2]);
> F(-8,17);
>
> (%o34) f(x):=x^2+a*x+b
> (%o35) F(a,b):=f(x)
> (%o36) b+a+1=10
> (%o37) b+2*a+4=5
> (%o38) [[b=17,a=-8]]
> (%o39) x^2-8*x+17
>
>
> ------------------------------
> ??? Windows 7?????????? ????? <http://windows.microsoft.com/shop>
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>
>