1 | initial version |

Root finding is a difficult subject. In general, you cannot expect an algorithm to yield all the solutions of a given equation $f(x)=0$. It is required some prior knowledge and analysis of the equation.

The `solve`

function tries to obtain exact solutions, if any. For the equation you propose, that is, $\sin x=0.8$, you have already tested

```
solve(sin(x)==0.8,x)
```

which yields $x=\arcsin(4/5)$ and misses the other solution in $[0,2\pi]$, which is $x=\pi-\arcsin(4/5)$. You have also tried

```
solve(sin(x)==0.8, x, to_poly_solve = 'force')
```

and got something like

```
[x == pi + 2*pi*z103 - arctan(3602879701896397/7301667457314599911469129704407*sqrt(7301667457314599911469129704407)),
x == 2*pi*z105 + arctan(3602879701896397/7301667457314599911469129704407*sqrt(7301667457314599911469129704407))]
```

Here, `z103`

and `z105`

represent integer constants. Every time you evaluate such a function, you get different numbers after `z`

. In a more mathematical notation, Sage proposes the solutions
$$x=-\arctan\Bigl(\frac{a\sqrt{b}}{b}\Bigr)+\pi(2z_{103}+1)\quad\text{and}\quad
x=\arctan\Bigl(\frac{a\sqrt{b}}{b}\Bigr)+2\pi z_{105},$$
where
$$a=3602879701896397 \quad\text{and}\quad b=7301667457314599911469129704407.$$
Please, note that we have now an infinite number of solutions. If `z103`

and `z105`

are replaced by given integers, we get specific solutions. For example,

```
sol = solve(sin(x)==0.8, x, to_poly_solve = 'force')
print "First solution:", sol[0].rhs().subs(z103=0).n()
print "Second solution:",sol[1].rhs().subs(z105=0).n()
```

yields

```
First solution: 2.21429743558818
Second solution: 0.927295218001612
```

assuming, of course, that `z103`

and `z105`

still were the constants appearing in `sol`

. These are the expected roots (up to an error of order $10^{-16}$) in $[0,2\pi]$, since

```
sage: print N(arcsin(4/5)), N(pi-arcsin(4/5))
0.927295218001612 2.21429743558818
```

The `find_root`

function applies a numerical algorithm, essentially Brent's method. So each call to `find_root`

will yield, if any, just one approximated root of the equation. Hence, to find all the zeros of a function, you need to know in advance how many they are and where they live and then use `find_root`

as many times as needed, changing the corresponding intervals.

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.