Question

In: Advanced Math

Study the roots of the nonlinear equation f(x) = cos(x) + (1 /(1 + e^2x)) both...

Study the roots of the nonlinear equation f(x) = cos(x) + (1 /(1 + e^2x)) both theoretically and numerically. (a) Plot f(x) on the interval x ∈ [−15, 15] and describe the overall behaviour of the function as well as the number and location of its roots. Use the “zoom” feature of Matlab’s plotting window (or change the axis limits) in order to ensure that you are identifying all roots – you may have to increase your plotting point density in order to see sufficient detail!

Please provide MATLAB code as well.

Solutions

Expert Solution


%%Matlab code for finding root using newton secant bisection and false
clear all
close all

%function for which root have to find
fun=@(x) cos(x)+(1./(1+exp(2*x)));
fprintf('function for which root have to find f(x)=')
disp(fun)
xx=linspace(-15,15,100001);
yy=fun(xx);

plot(xx,yy)
xlabel('x')
ylabel('f(x)')
title('x vs. f(x) plot')
grid on
x0=-10;
[root]=newton_method(fun,x0,1000);
hold on
plot(root,fun(root),'r*')

x0=-5;
[root]=newton_method(fun,x0,1000);
hold on
plot(root,fun(root),'r*')

x0=2;
[root]=newton_method(fun,x0,1000);
hold on
plot(root,fun(root),'r*')

x0=5;
[root]=newton_method(fun,x0,1000);
hold on
plot(root,fun(root),'r*')

x0=8;
[root]=newton_method(fun,x0,1000);
hold on
plot(root,fun(root),'r*')

x0=10;
[root]=newton_method(fun,x0,1000);
hold on
plot(root,fun(root),'r*')

x0=13;
[root]=newton_method(fun,x0,1000);
hold on
plot(root,fun(root),'r*')

%Matlab function for Newton Method
function [root]=newton_method(fun,x0,maxit)
syms x
g1(x) =diff(fun,x);   %1st Derivative of this function
xx=x0;            %initial guess]
fprintf('\nRoot using Newton method for initial guess %f\n',x0)
%Loop for all intial guesses
    n=5*10^-15; %error limit for close itteration
    for i=1:maxit
        x2=double(xx-(fun(xx)./g1(xx))); %Newton Raphson Formula
        cc=abs(double(fun(x2)));                 %Error
        err(i)=cc;
        xx=x2;
        if cc<=n
            break
        end
      
    end
    fprintf('\tAfter %d iteration root using Newton method is %f\n',i,xx)
    root=xx;
end

%%%%%%%%%%%%%%% End of Code %%%%%%%%%%%%%


Related Solutions

   1) lim (e^x + e^(-x) - 2) / (1 - cos 2x) as x approaches...
   1) lim (e^x + e^(-x) - 2) / (1 - cos 2x) as x approaches 0 2) lim sin 5x / 16x as x approaches 0 can someone evaluate the limit
Find the roots of the following equation in [−π, π] 2x 2 − 4 cos(5x) −...
Find the roots of the following equation in [−π, π] 2x 2 − 4 cos(5x) − 4x sin x + 1 = 0 by using the Newton’s method with accuracy 10^(−5) . how do I solve this using a computer
1) Find f(x) by solving the initial value problem. f' (x) = e x − 2x;...
1) Find f(x) by solving the initial value problem. f' (x) = e x − 2x; f (0) = 2 2) A rectangular box is to have a square base and a volume of 20f t^3 . If the material for the base costs 30¢/f t^2 , the material for the sides costs 10¢/ft^2 , and the material for the top costs 20¢/f t^2 , determine the dimensions of the box that can be constructed at minimum cost.
Let f(x) = (x − 1)2, g(x) = e−2x, and h(x) = 1 + ln(1 − 2x). (a) Find the linearizations of f, g, and h at  a =...
Let f(x) = (x − 1)2, g(x) = e−2x, and h(x) = 1 + ln(1 − 2x). (a) Find the linearizations of f, g, and h at  a = 0. Lf (x) =    Lg(x) =    Lh(x) =  (b) Graph f, g, and h and their linear approximations. For which function is the linear approximation best? For which is it worst? Explain. The linear approximation appears to be the best for the function  ? f g h since it is closer to  ? f g h for a larger domain than it is to  - Select - f and g g and h f and h . The approximation looks worst for  ? f g h since  ? f g h moves away from L faster...
Let f(x) = a(e-2x – e-6x), for x ≥ 0, and f(x)=0 elsewhere. a) Find a...
Let f(x) = a(e-2x – e-6x), for x ≥ 0, and f(x)=0 elsewhere. a) Find a so that f(x) is a probability density function b)What is P(X<=1)
Consider the nonlinear equation f(x) = x3− 2x2 − x + 2 = 0. (a) Verify...
Consider the nonlinear equation f(x) = x3− 2x2 − x + 2 = 0. (a) Verify that x = 1 is a solution. (b) Convert f(x) = 0 to a fixed point equation g(x) = x where this is not the fixed point iteration implied by Newton’s method, and verify that x = 1 is a fixed point of g(x) = x. (c) Convert f(x) = 0 to the fixed point iteration implied by Newton’s method and again verify that...
3. For the inhomogeneous differential equation x ′′ + 2x ′ + 10x = 100 cos(4t),...
3. For the inhomogeneous differential equation x ′′ + 2x ′ + 10x = 100 cos(4t), (a) Describe a system for which this differential equation would be an appropriate model. (b) Find the general solution, x(t), to the equation. (c) Does the general solution have the expected terms? What behavior do the terms describe? (d) Find the specific solution that fits the initial conditions x(0) = 0 and x ′ (0) = 0. (e) Plot the solution and discuss how...
Find the solutions of y'' + 4y' + 3y = sen(x) + 3 cos(2x) + e˄(−x)+...
Find the solutions of y'' + 4y' + 3y = sen(x) + 3 cos(2x) + e˄(−x)+ 2 x˄2
find f'(x) 1. f(x)=3sinx-secx+5 _______ 2. f(x)=e^xcot(3x) _______ 3. f(x)= cos^5(3x-1) _______
find f'(x) 1. f(x)=3sinx-secx+5 _______ 2. f(x)=e^xcot(3x) _______ 3. f(x)= cos^5(3x-1) _______
find the line tangent to graph of f(x) at x=0 1) f(x)=sin(x^2+x) 2)f(x)=e^2x+x+1
find the line tangent to graph of f(x) at x=0 1) f(x)=sin(x^2+x) 2)f(x)=e^2x+x+1
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT