Symbolic package and solving multiple variables

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
RT
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Symbolic package and solving multiple variables

RT
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

OctSymPy v2.2.4: this is free software without warranty, see source.
Initializing communication with SymPy using a popen2() pipe.
Some output from the Python subprocess (pid 20298) might appear next.
Python 2.7.12 (default, Nov 19 2016, 06:48:10)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> >>> Traceback (most recent call last):
  File "<stdin>", line 26, in <module>
  File "<stdin>", line 6, in _fcn
  File "/usr/lib/python2.7/dist-packages/sympy/matrices/matrices.py", line 3084, in __getattr__
    "%s has no attribute %s." % (self.__class__.__name__, attr))
AttributeError: MutableDenseMatrix has no attribute is_Relational.


OctSymPy: Communication established.  SymPy v0.7.6.1.
PYTHON: Error in cmd
Resetting the octsympy communication mechanism
Closing the Python pipe...
error: python_cmd: unexpected return
error: called from
    python_cmd at line 144 column 6
    solve at line 135 column 9

I'm trying to create a function when given two points it comes back with the exponential equation see link of image below
http://storage6.static.itmages.com/i/17/0711/h_1499812064_8774730_bb5b98baf0.png

I'm use Octave 4.0 Ubuntu 16.04 64bit
symbolic *|   2.2.4 | /usr/share/octave/packages/symbolic-2.2.4  (from Ubuntu repos)

Any ideas how to get this to work should I not use the symbolic package?

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Symbolic package and solving multiple variables

Mike Miller-4
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.

--
mike

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Loading...