Professional Documents
Culture Documents
Experiment Number:01 # A 5
Experiment Number:01 # A 5
# a=5
B=4
a*b=20
# x=30
Cos(x)=0.1543
sin(x)=-0.9880
tan(x)=-6.4053
Y=16.89816
Sqrt(y)=4
log(y)=2.7726
exp(y)=808861e+06
round(y)=17
#Circle:
A=𝜋r2
r=5
pi*r^2=78.5398
# 3× 𝟑 Matrix:
A(2,2)=1
A(2,2)=0
A(2,2)=7
Experiment number:02
Program:
x = [0:5:100];
y = x;
plot(x, y)
Program:
x = [1 2 3 4 5 6 7 8 9 10];
x = [-100:20:100];
y = x.^2;
plot(x, y)
Program:
x = [0:0.01:10];
y = sin(x);
Program:
x = [0 : 0.01: 10];
y = sin(x);
g = cos(x);
Polynomials function:
Program:
g = 5 * x.^3 + 9 * x + 2;
Program:
x = [0 : 0.01: 10];
Program:
x = [0:0.01:5];
y = exp(-1.5*x).*sin(10*x);
subplot(1,2,1)
y = exp(-2*x).*sin(10*x);
subplot(1,2,2)
plot(x,y),xlabel('x'),ylabel('exp(–2x)*sin(10x)'),axis([0 5 -1 1])
Experiment number: 03
Program:
x = [1:10];
y = [75, 58, 90, 87, 50, 85, 92, 75, 60, 95];
bar(x,y), xlabel('Student'),ylabel('Score'),
title('First Sem:')
Drawing Contours:
Program:
modify
set(h,'ShowText','on','TextStep',get(h,'LevelStep')*2)
Program:
f=inline(a);
if f(xu)*f(xl)<0
else
end
for i=2:1000
xr=(xu+xl)/2;
if f(xu)*f(xr)<0
xl=xr;
else
xu=xr;
end
if f(xl)*f(xr)<0
xu=xr;
else
xl=xr;
end
xnew(1)=0;
xnew(i)=xr;
if abs((xnew(i)-xnew(i-1))/xnew(i))<tol,break,end
end
Experiment number:05
syms x;
% Input Section
fa = eval(subs(y,x,a));
fb = eval(subs(y,x,b));
if fa*fb > 0
root.');
else
c = a - (a-b) * fa/(fa-fb);
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;
fb = eval(subs(y,x,b));
else
a =c;
fa = eval(subs(y,x,a));
end
c = a - (a-b) * fa/(fa-fb);
fc = eval(subs(y,x,c));
end
end
a b c f(c)
Experiment number:05
Program:
syms x;
% Input Section
step = 1;
g = diff(y,x);
fa = eval(subs(y,x,a));
while abs(fa)> e
fa = eval(subs(y,x,a));
ga = eval(subs(g,x,a));
if ga == 0
disp('Division by zero.');
break;
end
b = a - fa/ga;
fprintf('step=%d\ta=%f\tf(a)=%f\n',step,a,fa);
a = b;
if step>N
disp('Not convergent');
break;
end
step = step + 1;
end
Root is 0.517757
Experiment number:06
Program:
#include<stdio.h>
#include<conio.h>
#include<math.h>
is to be solved */
int main()
int step=1, N;
clrscr();
/* Inputs */
scanf("%f", &x0);
scanf("%f", &e);
scanf("%d", &N);
do
x1 = g(x0);
f(x1));
step = step + 1;
if(step>N)
printf("Not Convergent.");
exit(0);
x0 = x1;
getch();
return(0);
Experiment number:07
Program:
a=input('Enter function:','s');
f=inline(a)
iteration=0;
for i=3:1000
f(x(i-2))));
iteration=iteration+1;
if abs((x(i)-x(i-1))/x(i))*100<n
root=x(i)
iteration=iteration
break
end
end
f=
Inline function:
Root = -0.6593
Iteration = 6