Write a matlab program which will find the root of the following equation within
ID: 1860974 • Letter: W
Question
Write a matlab program which will find the root of the following equation within the interval 0<x<1. The program should solve the problem using two methods: 1) Binary Serach; and 2) False position.Y=AX^3 * sin(sqrt(X)-10)
The constant A=123
The program will ask the user to select the convergence criteria and the convergence value. The output of the program is a table, as shown below, illustrating the results obtained by three methods: Iteration Binary | Search False Positin | Newton Raphson X X X 1 2 3
Write a matlab program which will find the root of the following equation within the interval 0<x<1. The program should solve the problem using two methods: 1) Binary Serach; and 2) False position.
Y=AX^3 * sin(sqrt(X)-10)
The constant A=123
The program will ask the user to select the convergence criteria and the convergence value. The output of the program is a table, as shown below, illustrating the results obtained by three methods: Iteration Binary | Search False Positin | Newton Raphson X X X 1 2 3
The program will ask the user to select the convergence criteria and the convergence value. The output of the program is a table, as shown below, illustrating the results obtained by three methods: Iteration Binary | Search False Positin | Newton Raphson X X X 1 2 3
Explanation / Answer
clear all;
clc;
display('Equation is 120*x^3 * sin(sqrt(x)-10 = 0')
i=1;
while(i)
xl=input('Enter lower value:');
xu=input('Enter upper value: ');
e=input('Enter accuracy: ');
i = 0;
end
temp1 = xl;
temp2 = xu;
%%%% This is to be used for False Position %%%%
if equan(xl)<0
xn=xl;
xp=xu;
else
xn=xu;
xp=xl;
end
xm=xl;
while (abs(equan(xm))>e)
xm=(xn*equan(xp)-xp*equan(xn))/(equan(xp)-equan(xn));
if equan(xm)<0
xn=xm;
else
xp=xm;
end
end
Root_fals_pos=xm
%%%% This is to be used for Binary Search %%%%
xl = temp1;
xu = temp2;
xp = (xl + xu)/2;
err = abs(equan(xp));
count = 0;
while ((err > e) && (count < 100))
if equan(xl)*equan(xp)<0
xu = xp;
else
xl = xp;
end
xp = (xl + xu)/2;
err = abs(equan(xp));
count = count+1;
end
if (count == 100)
disp('No solution in Binary Search');
else
xp
end
In separate file of name equan.m
% Equation to be solved
function[eqn]=equan(x);
eqn= 123*x^3 * sin(sqrt(x)-10);
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.