# How to solve a nonlinear equation system numerically? Anonymous

I am new to sagemath and am having some trouble by printing the solution of a nonlinear equation system in a numerical way. I tried it with print(soln.n(160)) but that didn't work. Has someone an idea how to overcome this problme?

var('x y')
eq1 = x*y^2 - 5*y + 4*x - 3 == 0
eq2 = x*y - 2*x + 2 == 0
solutions = solve([eq1,eq2],x,y)
sol_n = solutions # save only the negative results
sol_p = solutions # save only the positive results
print(sol_n)
print(sol_n)
print(sol_p)
print(sol_p)


Resulting (exact) output:

x == -1/16*I*sqrt(7) + 21/16
y == -1/14*I*sqrt(7) + 1/2
x == 1/16*I*sqrt(7) + 21/16
y == 1/14*I*sqrt(7) + 1/2

edit retag close merge delete

Sort by » oldest newest most voted

The result you get are expressions (see the == sign):

sage: a = sol_n
sage: a
x == -1/16*I*sqrt(7) + 21/16


What you could do is to get their right-hand side, with the rhs method:

sage: a.rhs()
-1/16*I*sqrt(7) + 21/16
sage: a.rhs().n(160)
1.3125000000000000000000000000000000000000000000 - 0.16535945694153691190635098460245377660689119894*I

more