Professional Documents
Culture Documents
Output: Give Coord (x0 Y0 x1 Y1) : (0 0 5 5) : Experiment - 3 Program For Scan Conversion of A Straight Line
Output: Give Coord (x0 Y0 x1 Y1) : (0 0 5 5) : Experiment - 3 Program For Scan Conversion of A Straight Line
OUTPUT:
OUTPUT:
OUTPUT
Enter the function in the form of variable x:x^3-x-1
Enter Initial Guess:1.5
Enter allowed Error:0.001
f=
Inline function:
f(x) = x^3-x-1
root =
1.3252
Experiment No- 8 Write a program for bisection method in MATLAB
% Clearing Screen
clc
% Setting x as symbolic variable
syms x;
% Input Section
y = input('Enter non-linear equations: ');
a = input('Enter first guess: ');
b = input('Enter second guess: ');
e = input('Tolerable error: ');
% Finding Functional Value
fa = eval(subs(y,x,a));
fb = eval(subs(y,x,b));
% Implementing Bisection Method
if fa*fb > 0
disp('Given initial values do not bracket the
root.');
else
c = (a+b)/2;
fc = eval(subs(y,x,c));
fprintf('\n\na\t\t\tb\t\t\tc\t\t\tf(c)\n');
while abs(fc)>e
fprintf('%f\t%f\t%f\t%f\n',a,b,c,fc);
if fa*fc< 0
b =c;
else
a =c;
end
c = (a+b)/2;
fc = eval(subs(y,x,c));
end
OUTPUT:
Enter non-linear equations: cos(x) - x * exp(x)
Enter first guess: 0
Enter second guess: 1
Tolerable error: 0.00001
a b c f(c)
0.000000 1.000000 0.500000 0.053222
0.500000 1.000000 0.750000 -0.856061
0.500000 0.750000 0.625000 -0.356691
0.500000 0.625000 0.562500 -0.141294
0.500000 0.562500 0.531250 -0.041512
0.500000 0.531250 0.515625 0.006475
0.515625 0.531250 0.523438 -0.017362
0.515625 0.523438 0.519531 -0.005404
0.515625 0.519531 0.517578 0.000545
0.517578 0.519531 0.518555 -0.002427
0.517578 0.518555 0.518066 -0.000940
0.517578 0.518066 0.517822 -0.000197
0.517578 0.517822 0.517700 0.000174
0.517700 0.517822 0.517761 -0.000012
0.517700 0.517761 0.517731 0.000081
0.517731 0.517761 0.517746 0.000035
0.517746 0.517761 0.517754 0.000011
OUTPUT:
Experiment -10 Program for solving ordinary differential equation by Runge Kutta Method
OUTPUT:
x y
0.000 0.500
0.200 0.632
0.400 0.838
0.600 1.133
0.800 1.538
1.000 2.077
1.200 2.780
1.400 3.683
1.600 4.829
1.800 6.274
2.000 8.083 >>