Task 1

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.

Examples

Main Example

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


WARNING: replacing docs for 'newtonInv :: Union{Tuple{Real,Any}, Tuple{Real}}' in module 'Main'.
Out[2]:
newtonInv

In [3]:
?newtonInv


search:

Out[3]:
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

In [ ]: