Tuesday, October 19, 2010

roots function and solve functioin

Today I learned two methods to solve polynomial.Two functions, roots and solve can be used. For example, if I would like to solve the polynomial:

x^3+2*x^2-8*x+10=0

I can use:

r=roots([1 2 -8 10])

or:

solve('x^3+2*x^2-8*x+10')

However, the answers will be given in different form. The first one will give numerical values of the roots, like:
ans =

  -4.3605          
   1.1803 + 0.9488i
   1.1803 - 0.9488i

the latter one will give symbolic form answers:
ans =
 
-1/3*(215+3*2697^(1/2))^(1/3)-28/3/(215+3*2697^(1/2))^(1/3)-2/3
 1/6*(215+3*2697^(1/2))^(1/3)+14/3/(215+3*2697^(1/2))^(1/3)-2/3+1/2*i*3^(1/2)*(-1/3*(215+3*2697^(1/2))^(1/3)+28/3/(215+3*2697^(1/2))^(1/3))
 1/6*(215+3*2697^(1/2))^(1/3)+14/3/(215+3*2697^(1/2))^(1/3)-2/3-1/2*i*3^(1/2)*(-1/3*(215+3*2697^(1/2))^(1/3)+28/3/(215+3*2697^(1/2))^(1/3))
 
 

1 comment:

Any comments?

my-alpine and docker-compose.yml

 ``` version: '1' services:     man:       build: .       image: my-alpine:latest   ```  Dockerfile: ``` FROM alpine:latest ENV PYTH...