Question: Write a mathlab function that caculates e^-3x ? help me fix my code ----> function y= myexp (-3*x) %the goal is to calculate e^-3x ;

Write a mathlab function that caculates e^-3x ?

help me fix my code ---->

function y= myexp (-3*x)

%the goal is to calculate e^-3x ;

epsilon = 10^(-6);

RPE =1;

sum = 1;

k =1 ;

fprintf ( 'iteration \t\t exp(-3*x) t\t RPE ');

while RPE > epsilon

old_sum = sum;

sum = sum + (-3*x)^k/factorial(k);

fprintf ( ' %d \t\t\t %.6f \t\t %7f ',k,sum,RPE);

RPE = abs ((sum - old_sum)/sum);

k=k+1;

end

y = sum

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!