NSM PRACTICAL Sem4
NSM PRACTICAL Sem4
OUTPUT :-
1
AIM :- Program to evaluate 𝑒^x using infinite series.
PRACTICAL :- 1:C Date:
function y=f(x);
y=exp(x);
endfunction
sum=1;
test=0;
i=0;
term=1;
x=input("input value of x:");
while sum~=test
disp(sum,"sum:",term,"term:",i,"i:");
disp("...................");
i=i+1;
term=term*x/i;
test=sum;
sum=sum+term;
end
disp(f(x),"exact value");
2
OUTPUT :-
3
4
PRACTICAL :- 2:A Date:
AIM :- Program to solve algebraic and transcendental equation by bisection
method.
CODE:-
deff('y=f(x)','y=x^3-x-1');
x1=1,x2=2; // f(1) is negative and f(2) is positive
d=0.0001; // for accuracy of root
c=1;
5
printf('successive approximations \tx1 \t \tx2 \t \tm \t \f f(m) \n');
while abs (x1-x2)>d
m=(x1+x2)/2;
printf('\t%f \t%f \t%f \t%f \n',x1,x2,m,f(m));
if f(m)*f(x1)>0
x1=m;
else
x2=m;
end
c=c+1; // to count number of iterations
end
printf(' the solution of equation after %i iteration is %g',c,m);
OUTPUT :-
OUTPUT :-
OUTPUT :-
OUTPUT:-
OUTPUT :-
INDEX
Sr no Practical name Page no date sign
10
1C Program to evaluate 𝑒^x using
infinite series.
11