Add a documentation to the function newtonInv from session 4, such that ?newtonInv
displays the following information:
newtonInv(x::Real,y0=0.1;iterations=10)
Calculate an approximation of the inverse of x
by using the iteration $y_{k+1} = 2*y_k - y_k^2*x$
with inital value $y_0$ = y0.
julia> newonInv(2)
0.5
In [2]:
"""
newtonInv(x::Real,y0=0.1;iterations=10)
Calculate an approximation of the inverse of `x`
by using the iteration ``y_{k+1} = 2*y_k - y_k^2*x``
with inital value ``y_0`` = y0.
# Examples
## Main Example
```
julia> newonInv(2)
0.5
```
"""
function newtonInv(x::Real,y0=0.1;iterations=10)
y = y0;
for i in 1:iterations
y = 2*y-y^2*x
end
return y
end
Out[2]:
In [3]:
?newtonInv
Out[3]:
In [ ]: