1. (C) Program to evaluate 𝑒
𝑥 using infinite series.
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") | |
1. (C) Program to evaluate 𝑒 𝑥 using infinite series.
Reviewed by admin
on
December 24, 2019
Rating:
No comments: