# Root Finder


```julia
using Plots

f(x) = x^4+0.4*x^3-0.5*x^2+1.2*x-1.5 
range = -100:1:100
plot(range, f.(range), linewidth=4, label="p(x)")
```




    

    



## Vieta's formulas for $n=4$:

$
\begin{align}
x_1 + x_2 + x_3 + x_4 &= -0.4 \\
x_1 (x_2 + x_3 + x_4) + x_2 (x_3 + x_4) + x_3 x_4 &= -0.5 \\
x_1 x_2 ( x_3 + x_4) + x_2 x_3 x_4 + x_1 x_3 x_4   &= -1.2 \\
x_1 x_2 x_3 x_4 &= 1.5
\end{align}
$

## Jacobian Matrix

$
\begin{bmatrix}
  1 & 1 & 1 & 1 \\
  x_2 + x_3 + x_4 & x_1 + x_3 + x_4 & x_1 + x_2 + x_4 & x_1 + x_2 + x_3 \\
  x_2x_3 + x_2x_4 + x_3x_4 & x_1x_3 + x_1x_4 + x_3x_4 & x_1x_2 + x_2x_4 + x_1x_4 & x_1x_2 + x_2x_3 + x_1x_3 \\
  x_2x_3x_4 & x_1x_3x_4 & x_1x_2x_4 & x_1x_2x_3
\end{bmatrix}
$

# Solution with Roots


```julia
using Roots

p = find_zeros(f, -100, 100)
```




    2-element Array{Float64,1}:
     -1.5789900595892086
      0.8695222544496146




```julia
# test
f.(p)
```




    2-element Array{Float64,1}:
     -1.7763568394002505e-15
     -2.220446049250313e-16



# Solution with PolynomicalRoots


```julia
using PolynomialRoots

p = roots([-1.5, 1.2, -0.5, 0.4, 1])
```




    4-element Array{Complex{Float64},1}:
     -1.5789900595892088 + 0.0im
     0.15473390256979705 + 1.0337223322714935im
      0.8695222544496146 - 8.320880518027517e-17im
     0.15473390256979702 - 1.0337223322714935im




```julia
# test
f.(p)
```




    4-element Array{Complex{Float64},1}:
      2.220446049250313e-16 + 0.0im
     -4.440892098500626e-16 + 2.220446049250313e-16im
     -4.440892098500626e-16 - 3.218046955410157e-16im
     -2.220446049250313e-16 - 2.220446049250313e-16im



## Adjourn


```julia
using Dates
println("mahdiar")
Dates.format(now(), "Y/U/d HH:MM")  
```

    mahdiar





    "2021/March/18 17:50"



e15bda5985d668601322e0112c0f9d5cf9c05f05
ipynb
Jupyter Notebook
HW08/2.ipynb
mahdiarsadeghi/NumericalAnalysis
95a0914c06963b0510971388f006a6b2fc0c4ef9
MIT
HW08/2.ipynb
mahdiarsadeghi/NumericalAnalysis
95a0914c06963b0510971388f006a6b2fc0c4ef9
MIT
HW08/2.ipynb
mahdiarsadeghi/NumericalAnalysis
95a0914c06963b0510971388f006a6b2fc0c4ef9
MIT
Qwen/Qwen-72B
1. YES
2. YES