It works but for solve you need to set x as real using
>>> x = symbols('x', real=True)
>>> solve(abs(2*x - 4) - 14, x)
[-5, 9]
alternately you can use solveset
>>> solveset(abs(2*x - 4) - 14, x, S.Reals)
{-5, 9}
Aaron Meurer
On Sat, Oct 5, 2019 at 12:52 AM Steve F <[email protected]> wrote:
>
> Hello,
>
> I am new to Python and Sympy and have looked around the web for a good
> bit and found a solution to this problem
>
> Solve: Abs(2*x -4) =14.
>
> I could do it this way:
>
> #Solving a single Linear Equation for X.
> #https://docs.sympy.org/latest/modules/solvers/solvers.html
> from sympy.solvers import solve
> from sympy import Symbol
> x = Symbol('x')
> solve(2*x - 4 -14,x)
>
> and
>
> #Solving a single Linear Equation for X.
> #https://docs.sympy.org/latest/modules/solvers/solvers.html
> from sympy.solvers import solve
> from sympy import Symbol
> x = Symbol('x')
> solve(2*x -4 + 14,x)
>
> But I wonder if there is a better way.
>
> Also, I would like to plot this in Jupyter Lab/Python.
>
> Thank you,
> Steve.
>
> --
> 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/ad9480bc-f268-455e-b056-e5abcc73c173%40googlegroups.com.
--
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/CAKgW%3D6J0r%3DJfoN%2Bt63dJA56d4Bt%3DWLrx3W%3DcK99on_ZdMtuB%3DQ%40mail.gmail.com.