The rootfinding problem, Exercise 1

  1. x2=ex, over [-2, 2]
  1. Rewrite: f(x)=exx2
using FundamentalsNumericalComputation

f1(x) = exp(-x) - x^(2.);
x1 = -2:0.1:2;

plot(x1, f1.(x1))
#plot(f1, -2, 2)

There should be one root.

s1 = nlsolve(x->f1(x[1]), [0.75], ftol = 1e-14);
[s1.zero f1.(s1.zero)]
  1. inverse of the derivative evaluated at the root
f1d(x) = -exp(-x) - 2x;
abs.(f1d.(s1.zero))
1 ./ abs.(f1d.(s1.zero))