Draw the graphs of $y=x-1$, $y=x$, $y=x+1$, & $y=xe^{\frac{-1}{|x|}}$ for , $-\infty< x< \infty$ using the same $X$ and $Y$ axes.

92 Views Asked by At

In the above question, I could easily plot the linear equations. But I don't know how to plot $y=xe^{\frac{-1}{|x|}}$. Can you please explain me, how to draw this exponential curve?

Thank you

1

There are 1 best solutions below

5
On BEST ANSWER

With MatLab :

for k=1:1999
     x(k)=-5+k*5/1999;
     y(k)=x(k)-1;
     z(k)=x(k);
     w(k)=x(k)+1;
     t(k)=x(k)*exp(1/(x(k)));
end

x(2000)=0;
y(2000)=-1;
z(2000)=0;
w(2000)=1;
t(2000)=0;

for k=2001:4000
     x(k)=(k-2000)/400;
     y(k)=x(k)-1;
     z(k)=x(k);
     w(k)=x(k)+1;
     t(k)=x(k)*exp(-1/(x(k)));
end

plot(x,y,x,z,x,w,x,t)

The result is this (after adding legend and magnification of the lines) : enter image description here

Maybe your problem is the absolute value $|x|$. Don't forget that $|x|=-x$ when $x<0$ and $|x|=x$ when $x>0$. To avoid any problem at $x=0$, you can just enter yourself the values for this point.