% EX 2.7 % Hitta en rot till f(x) = 10 x^1/10 - x - cos x - e^-x = 0. % Plotta, undersök övriga rötter, och vad som händer då x->0, x->inf % Rot 1 % x->0: ungefar f(x) = 10 x^1/10 - 0 - 1 - 1 => rot vid x = 0.2^10 = 1.0240e-07 % x->inf: ungefar f(x) = -x => inga rötter för stora x % Startpunkt för första rot x_start = 1.0240e-07; % Maximalt relativfel h_max = 5e-10; % Definiera funktionerna f = @(x) 10*x.^0.1 - x - cos(x) - exp(-x); f_prim = @(x) x.^-0.9 - 1 + sin(x) + exp(-x); % Newton-Raphson [x, h] = newton_raphson(x_start, h_max, f, f_prim); % Rot 2 % Plotta x = 0:0.01:20; plot(x, 10*x.^0.1 - x - cos(x) - exp(-x)) grid on % Körning: % rot vid x = 12 % Startpunkt för andra rot x_start = 12; % Newton-Raphson [x, h] = newton_raphson(x_start, h_max, f, f_prim);