Ask Your Question
0

numerical_approx()

asked 2018-12-04 16:28:23 +0100

thetha gravatar image

updated 2019-03-16 08:24:34 +0100

FrédéricC gravatar image

from sympy.solvers import solve

from sympy import Symbol

x = Symbol('x')

C=solve((x+86)/x-95/58,x)

How its possible to use numerical_approx() on this https://ask.sagemath.org/question/992... this solutions is not working,

C[0].numerical_approx()

numerical_approx(C[0])

also not

edit retag flag offensive close merge delete

Comments

To display blocks of code or error messages, skip a line above and below, and do one of the following (all give the same result):

  • indent all code lines with 4 spaces
  • select all code lines and click the "code" button (the icon with '101 010')
  • select all code lines and hit ctrl-K

For instance, typing

If we define `f` by

    def f(x, y, z):
        return x * y * z

then `f(2, 3, 5)` returns `30` but `f(2*3*5)` gives:

    TypeError: f() takes exactly 3 arguments (1 given)

produces:

If we define f by

def f(x, y, z):
    return x * y * z

then f(2, 3, 5) returns 30 but f(2*3*5) gives:

TypeError: f() takes exactly 3 arguments (1 given)

Please edit your question to do that.

slelievre gravatar imageslelievre ( 2018-12-04 18:22:12 +0100 )edit

1 Answer

Sort by » oldest newest most voted
2

answered 2018-12-04 17:34:20 +0100

rburing gravatar image

updated 2018-12-04 17:34:55 +0100

Sage's and SymPy's expressions and numbers have different types, but you can convert between them as explained in A Sample Session using SymPy.

In your case:

sage: C[0]._sage_().numerical_approx()
134.810810810811
sage: numerical_approx(C[0]._sage_())
134.810810810811
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2018-12-04 16:28:23 +0100

Seen: 851 times

Last updated: Dec 04 '18