0% found this document useful (0 votes)
23 views2 pages

Sohelnum 1

This document contains code to solve two problems. Problem 1 uses bisection search to find the root of a function between two bounds where the function changes sign. It iteratively calculates the midpoint until the bounds are within a specified tolerance. Problem 2 plots a 4th order polynomial function against x from -10 to 10 on a graph with a grid.

Uploaded by

rohanfyaz00
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views2 pages

Sohelnum 1

This document contains code to solve two problems. Problem 1 uses bisection search to find the root of a function between two bounds where the function changes sign. It iteratively calculates the midpoint until the bounds are within a specified tolerance. Problem 2 plots a 4th order polynomial function against x from -10 to 10 on a graph with a grid.

Uploaded by

rohanfyaz00
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Problem1:

a=-10;
b=10;
tol=1e-10;
fa=a*a-4;
fb=b*b-4;
if fa*fb<0
while b-a>tol
c=(a+b)/2;
fc=c*c-4;
if fa*fc<0
b=c;
fb=fc;
elseif fb*fc<0
a=c;
fa=fc;
else
break
end

end
x=c

else
end

disp('wrong assumption');

problem2:

clc;
clf;
clear all;
close all;
x=-10:.10:10;
y=5*x.^4+2*x-3;
plot(x,y)
grid on;

You might also like