Hi,
It looks like solve returns a list containing the solution:
129 after solving for b1
[-(F_1 + G_1*b_{-1}**2 + G_1*b_{-2})/(2*F_1*b_{-1} - 1)]
SymPy's Eq expects something that can be converted to an expression. In
this case, this should work:
Eq(b1, ex129b[0])
Kalevi Suominen
On Thursday, February 27, 2020 at 5:44:53 PM UTC+2, Thomas Ligon wrote:
>
> It looks to me like I haven’t fully understood how to use symbols.
>
> I define b sub minus 1 and b sub minus 2 as
>
> bm1, bm2 = symbols('b_{-1} b_{-2}')
>
> Then I define expression 129 as
>
> ex129 = 2*F1*b1*bm1 + F1 + G1*bm1**2 + G1*bm2 - b1
>
> This reflects my expectation that I should use bm2 in the code, but the
> output via latex() will contain b_{-2}. However, when I look at ex129 in
> the debugger, it looks like this:
>
> 2*F_1*b_1*b_{-1} + F_1 + G_1*b_{-1}**2 + G_1*b_{-2} - b_1
>
> This is presumably why my subs() statement fails:
>
> ex129a = ex129.subs(bm2, ex132a)
>
> I expect bm2 to be gone from ex129a, but it isn’t.
>
>
>
> What is the correct way to do this?
>
>
>
> The other problem is, even though
>
> print(latex(ex129b))
>
> works fine,
>
> print(latex(Eq(b1, ex129b)))
>
> produces the following error:
>
>
>
> Message=SympifyError: [-(F_1 + G_1*b_{-1}**2 +
> G_1*b_{-2})/(2*F_1*b_{-1} - 1)]
>
> Source=C:\data\Tom\Research\Hill\python\Ansatz3\solveTest1.py
>
> StackTrace:
>
> File "C:\data\Tom\Research\Hill\python\Ansatz3\solveTest1.py", line 48,
> in <module>
>
> print(latex(Eq(b1, ex129b)))
>
>
>
--
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 view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/0301d518-080f-46b8-9a52-757258a15473%40googlegroups.com.