Solve doesn't work well in some scenarios

Issue #176 resolved
Former user created an issue

Hi, There are 3 problem with Solve i encountered:

  1. IExpr exp2 = util.evaluate("x=20.796855124168776"); IExpr exp = util.evaluate("Solve(x==(-1.0000000000000002)*Sqrt(y^2.0),y)"); and don't get any solution. The exp result is "{}".

  2. When we run just the expression: IExpr exp = util.evaluate("Solve(x==(-1.0000000000000002)Sqrt(y^2.0),y)"); (without the line x=<?>), we get the next solution: {{y->0.9999999999999998Sqrt(x^2.0)}} And the sqrt{x^2.0} should be changed to x.

  3. IExpr exp1 = util.evaluate("x=985.3698808807793"); IExpr exp2 = util.evaluate("y=89.73311105248706"); IExpr exp3 = util.evaluate("z=30.358930164378133"); IExpr exp4 = util.evaluate("w=143.26674070021394"); IExpr exp5 = util.evaluate("q=923.282853878973"); IExpr exp6 = util.evaluate("j=955.7677262340256"); IExpr exp = util.evaluate(" N(Solve(q/w==(m+2.0*y)/(m+z+x+j),m))"); And the "exp" not returns me the solution for m. Am I doing something wrong?

  4. The next code doesn't return any solution: IExpr exp = util.evaluate("Solve(4.027433300199394==(110.70534+x)/(1015.3739400000001+x),x)");

Comments (2)

  1. Axel Kramer repo owner

    For the latest Symja sources (commit f932847) this program (tested under a Windows environment:) gives the same results for me as wolframalpha.com:

    package org.matheclipse.core.examples;
    
    import org.matheclipse.core.eval.ExprEvaluator;
    import org.matheclipse.core.interfaces.IExpr;
    import org.matheclipse.parser.client.SyntaxError;
    import org.matheclipse.parser.client.math.MathException;
    
    public class SolveIssue176 {
    
        public static void main(String[] args) {
            try {
                ExprEvaluator util = new ExprEvaluator();
                util.eval("x0=20.796855124168776");
                IExpr result = util.eval("Solve(x0==(-1.0000000000000002)*Sqrt(y^2.0),y)");
                // {}
                System.out.println(result.toString());
    
                result = util.eval("Solve(x1==(-1.0000000000000002)*Sqrt(y^2.0),y)");
                // {{y->-x1},{y->x1}}
                System.out.println(result.toString());
    
                IExpr exp1 = util.eval("x2=985.3698808807793");
                IExpr exp2 = util.eval("y=89.73311105248706");
                IExpr exp3 = util.eval("z=30.358930164378133");
                IExpr exp4 = util.eval("w=143.26674070021394");
                IExpr exp5 = util.eval("q=923.282853878973");
                IExpr exp6 = util.eval("j=955.7677262340256");
                result = util.eval(" N(Solve(q/w==(m+2.0*y)/(m+z+x2+j),m))");
                // {{m->-2300.6414589715228}}
                System.out.println(result.toString());
    
                result = util.eval(
                        "Solve(923.282853878973/143.26674070021394==(m+2.0*89.73311105248706)/(m+30.358930164378133+985.3698808807793+955.7677262340256),m)");
                // {{m->-2300.6414589715228}}
                System.out.println(result.toString());
    
                result = util.eval("Solve(4.027433300199394==(110.70534+x3)/(1015.3739400000001+x3),x3)");
                // {{x3->-1314.197567242396}}
                System.out.println(result.toString());
            } catch (SyntaxError e) {
                // catch Symja parser errors here
                System.out.println(e.getMessage());
            } catch (MathException me) {
                // catch Symja math errors here
                System.out.println(me.getMessage());
            } catch (Exception e) {
                e.printStackTrace();
            } catch (final StackOverflowError soe) {
                System.out.println(soe.getMessage());
            } catch (final OutOfMemoryError oome) {
                System.out.println(oome.getMessage());
            }
        }
    }
    

    For the point 1.) and 2.) of your issue the Solve algorithm uses different approaches to get the different results.

  2. Log in to comment