You are on page 1of 2

//program of exponential equation

clc;
close;
clear;
x=[2 4 6 8];disp([x]);
y=[25 38 56 84];disp([y]);
//n=length of x
n=4;
Y=log(y);disp([Y]);
X=x;disp([X]);
X2=X.*X;disp([X2]);
XY=X.*Y;disp([XY]);
a0=(sum(Y)*sum(X2)-sum(X)*sum(XY))/(n*sum(X2)-
(sum(X)^2));
a1=(n*sum(XY)-sum(X)*sum(Y))/(n*sum(X2)-(sum(X))^2);
a=exp(a0);
b=a1;
printf('\ny=%f*e^%f*x',a,b);

solution=

2. 4. 6. 8.

25. 38. 56. 84.

3.2188758 3.6375862 4.0253517 4.4308168

2. 4. 6. 8.

4. 16. 36. 64.

6.4377516 14.550345 24.15211 35.446534


y=16.814818*e^0.201179*x

You might also like