sympy / sympy_gamma

A SymPy version of WolframAlpha.

Home Page:https://sympygamma.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to solve absolute value equations?

moliata opened this issue · comments

commented

Hello, I would like to ask, how should I solve absolute value equations? I can't do that with SymPy Gamma, because it interprets symbols as not real or imaginary.
screen shot 2018-01-28 at 21 02 34

commented

To fix this, we need to set Symbol as a real number. But I can't find where SymPy Gamma converts string to a SymPy Input and where specifically variables to Symbols.

@moliata Update sympy to the latest version and using solveset is viable option.
solveset (Abs(x), x)

This can be done in resultsets.py

diff --git a/app/logic/resultsets.py b/app/logic/resultsets.py
index 90004f0..171d8a1 100644
--- a/app/logic/resultsets.py
+++ b/app/logic/resultsets.py
@@ -701,7 +701,7 @@ no_pre_output = lambda *args: ""
 all_cards = {
     'roots': ResultCard(
         "Roots",
-        "solve(%s, {_var})",
+        "solveset(%s, {_var})",
         lambda statement, var, *args: var,
         format_output_function=format_list),
commented

@charlesverge how can I update SymPy to the new version without having issues with dependency mpmath?

@moliata The pip command should be able to install mpmath for you.

commented

@charlesverge my instance of SymPy Gamma is on Google App Engine, not on a local machine.