[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Symbolic package and solving multiple variables

From: Mike Miller
Subject: Re: Symbolic package and solving multiple variables
Date: Tue, 11 Jul 2017 15:47:57 -0700
User-agent: NeoMutt/20170609 (1.8.3)

On Tue, Jul 11, 2017 at 18:31:38 -0400, RT wrote:
> I know the symbolic package isn't the same as matlab but this error
> confuses me and I'm not sure what causes this
> What I type in to test it
> pkg load symbolic
> syms x y
> sol = solve([x^2+y^2==20,y==x^2,x>0,y>0],[x,y])
> I should get x=2 and y=4
> but I get this instead
> Any ideas how to get this to work should I not use the symbolic package?

Our solve function is not quite Matlab compatible, but it will give you
what you want if you adapt slightly.

The first difference is to pass each equality, inequality, and variable
as separate arguments instead of as a matrix.

The second difference is that SymPy doesn't appear to handle solving
systems of inequalities for more than one variable at a time.

To work around both of these differences, I used the following

    syms x y
    assume x y positive
    sol = solve (x^2+y^2==20, y==x^2, x, y)

That gives the solution you're after.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]