Em segunda-feira, 25 de maio de 2015 19:17:56 UTC-3, Renan Birck Pinheiro 
escreveu:
>
> Hi,
>
> Say I have two expressions, for example, f(x) = (a+b)*x^2 + (b+c)*x + c 
> and g(x) = 3*x^2 + 5*x + 1.
>
> In this case one can see that a+b = 3, b+c = 5 and c = 1, then setting a = 
> -1, b = 4 and c=1 makes the two expressions equivalent (that is, f(x) - 
> g(x) = 0 for all x - I don't know the correct term).
>
> How can I, using SymPy, find the values of a, b, c, that make those 
> expressions equivalent?
>
> Thanks!
>

Hi,

I found that sympy.solvers.solvers.solve_undetermined_coeffs does what I 
want, e.g. using my example:

>>> # Sample problem (for testing)
>>> a, b, c, x = sym.var('a b c x')
>>> f = lambda x: (a+b)*x**2 + (b+c)*x + c
>>> g = lambda x: 3*x**2 + 5*x + 1
>>> solvers.solve_undetermined_coeffs(f(x) - g(x), [a, b, c], x)
{a: -1, b: 4, c: 1}


-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/637038ee-3da0-42a3-8f97-0ee670a05cf0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to