# Numerical approximations

```
g(x)=x^2-sqrt(2)
solve(g(x)==0,x)
[x == -2^(1/4), x == 2^(1/4)]
```

What's the best/quickest way to get numerical approximations of these values of x? Thanks.

Numerical approximations

```
g(x)=x^2-sqrt(2)
solve(g(x)==0,x)
[x == -2^(1/4), x == 2^(1/4)]
```

What's the best/quickest way to get numerical approximations of these values of x? Thanks.

add a comment

0

0

In your case, since `g`

can be seen as a polynomial, you can also look at its roots in the real double field (floating-point approximations with 53 bits of precision):

```
sage: g.polynomial(RDF).roots()
[(-1.189207115002721, 1), (1.189207115002721, 1)]
```

0

Try taking the right hand side of each solution.

```
sage: A = solve(g(x)==0,x)
sage: [a.rhs().n() for a in A]
[-1.18920711500272, 1.18920711500272]
```

where `n()`

is short for `numerical_approx()`

. There are other ways of approaching this as well, such as via the `solution_dict=True`

keyword to `solve()`

.

Asked: **
2015-06-03 18:33:02 -0500
**

Seen: **174 times**

Last updated: **Jun 05 '15**

Using numerical integration within solve or find_root

Understanding the 'solve()' result with braces and brackets ("([{x:z},{x:y}],[1,1])")

Correct way to get an exact number of decimal digits (after the point)

Change output to numerical values globally

Solution of ODE expressed with hyperbolic trigonometric function

Ignoring the very small imaginary part

How to solve this algebraic equation by SageMath (rather than by hand)

W10,Sagemath 8.4 solve() does not give a response

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.