Previous Up Next

23.3.2  Finding approximate solutions of equations involving one variable

The fsolve or nSolve command can solve equations or systems of equations. This section will discuss solving equations; systems will be discussed in the next section.

The cfsolve command is the complex version of fsolve, with the same arguments. The only difference is that cfsolve gives numeric solutions over the complex numbers, even if Xcas is not in complex mode (see Section 2.5.5). fsolve will return complex roots, but only in complex mode.

fsolve solves numeric equations of the form:

  f(x)=0,    x ∈ (a,b).

Unlike solve (Section 9.3.6) or proot (Section 23.3.4), it is not limited to polynomial equations.

Examples

Input in real mode:

fsolve(x^3-1,x)
     
1.0           

Input in complex mode:

fsolve(x^3-1,x)
     

−0.5−0.866025403784i,−0.5+0.866025403784i,1.0
          

Input in any mode:

cfsolve(x^3-1,x)
     

−0.5−0.866025403784 i,−0.5+0.866025403784 i,1.0
          
fsolve(sin(x)=2)
     


          
cfsolve(sin(x)=2)
     

1.57079632679−1.31695789692 i,1.57079632679+1.31695789692 i
          
fsolve((cos(x))=x,x,-1..1,brent_solver)
     

0.739085133215
          

Previous Up Next