Question

Use Newtons method to find the solution for tanh(x)=x/3. This has two parts to it. Solve...

Use Newtons method to find the solution for tanh(x)=x/3. This has two parts to it. Solve it using the "While" loop and with a "For" loop.

Homework Answers

Answer #1

The Matlab program using while loop is as follows:

clc
clear
x0=1; % assuming initial value of x as 1
y=tanh(x0)-x0/3; %calculates y value at x0=1
dy=1-(tanh(x0))^2-1/3; % calculates dy value at x0=1
x1=x0-y/dy; % calculates next x value
while abs(x1-x0)>0.0001 %checking the error
x0 = x1; % now x1 becomes x0
y=tanh(x0)-x0/3;
dy=1-(tanh(x0))^2-1/3;
x1=x0-y/dy;
end
disp(x1)

The Matlab program using for loop is as follows:

clc
clear
n=99;
x = zeros(n+1,1);
x(1) = 1;
for k=1:100
y=tanh(x(k))-x(k)/3;
dy=1-(tanh(x(k)))^2-1/3;
x(k+1)=x(k)-y/dy;
end
disp(x)

In using for loop, I used 100 iterations and checked the result..I got the solution in the 4th iteration itself..if I did n't get the solution in 100 iterations, I would've increased the no.of iterations

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
1. Consider the ODE dy/ dx = tanh(x) − y tanh(x). Use the integrating factor method...
1. Consider the ODE dy/ dx = tanh(x) − y tanh(x). Use the integrating factor method to find the general solution of the ODE. Find the general solution of the ODE using a different method. Do you get the same answer? Explain briefly.
use newtons method to find the absolute maximum value of the function f(x)= 4xcosx, 0<x<pi correct...
use newtons method to find the absolute maximum value of the function f(x)= 4xcosx, 0<x<pi correct to 6 decimal places.
use newtons method to find all roots of the equation correct to six decimal places. Enter...
use newtons method to find all roots of the equation correct to six decimal places. Enter your answer as a comma separated list. 7cos x = 7 sqrt x
Use the method of undetermined coefficents to find a general solution for the DE y'''-6y''=3-cos(x)
Use the method of undetermined coefficents to find a general solution for the DE y'''-6y''=3-cos(x)
Find this integral using Integration By Parts; use the Tabular D.I. method. ∫ e^(5x) cos x...
Find this integral using Integration By Parts; use the Tabular D.I. method. ∫ e^(5x) cos x dx
Use dy/dx + p(x)y = f(x) has the solution y = y_c + y_p to solve....
Use dy/dx + p(x)y = f(x) has the solution y = y_c + y_p to solve. (Integrating Factor method) Find the General solution for the DEQ: dy/dx + 2xy = y + 4x - 2. Show step by step. Please explain or I will give a down-vote. Thank you
Using the method of undetermined coefficients, solve the following IVP y″ + y′  =  f (x)  ...
Using the method of undetermined coefficients, solve the following IVP y″ + y′  =  f (x)  = { 3 0  ≤  x  <  1 0 x  ≥  1 y(0)  =  y′(0)  =  0. Your solution will be a piecewise-defined function. Enter it's parts into the boxes below. Remember that both the solution, and its derivative, must be continuous. (a) Solution for x ∈ [0, 1). (b) Solution for x  ≥  1.
Use algebraic method to solve 3 x 3 payoff matrix for the player A given by  ...
Use algebraic method to solve 3 x 3 payoff matrix for the player A given by   B1 B2 B3                       ?1 12   5 -7                                  ?2 6 -3 1                        ?3 8 7 -5
Use method of undeterminde coeficients to find a particular solution to x'= A(x) + g(t) [...
Use method of undeterminde coeficients to find a particular solution to x'= A(x) + g(t) [ 1 1] [4 -2] and g(t) = [e^2t] [e^t]
using newtons method to find the second and third root approximations of 2x^7+2x^4+3=0 starting with x1=1...
using newtons method to find the second and third root approximations of 2x^7+2x^4+3=0 starting with x1=1 as the initial approximation
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT