If you use some user defined functions listed in the textboo

(If you use some user defined functions listed in the textbook, specify them and make necessary explanations) Make a plot to show: a root of the equation tan x - tan hx = 0 lies in (7.0, 7.4). Find this root with error tolerance of 10^-6 by the method of bisection.

Solution

%plot
x = 6:0.1:8;
y = tan(x) - tanh(x);
plot(x, y);
grid on

%finding root
tol = 10^-6;
a = 6;
b = 8;
x = (a+b)/2.0;
while (abs(tan(x)-tanh(x))>tol)
    if (tan(x)-tanh(x)<0)
        a = x;
    else
        b = x;
    end
    x = (a+b)/2.0;
end

disp([\'Root using the bisection method: \', num2str(x)]);

 (If you use some user defined functions listed in the textbook, specify them and make necessary explanations) Make a plot to show: a root of the equation tan x

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site