In [1]:
import numpy as np
import matplotlib.pyplot as plt
from IPython.display import display,Math
In [2]:
display(Math('y = e^x'))
display(Math('y = log(x)'))
$\displaystyle y = e^x$
$\displaystyle y = log(x)$
In [3]:
x = np.linspace(-3,3,99)

plt.plot(x,np.exp(x))
plt.xlabel('x')
plt.ylabel('$e^x$')
plt.show()

plt.plot(x,np.log(x))
plt.xlabel('x')
plt.ylabel('log(x)')
plt.show()
/anaconda3/lib/python3.6/site-packages/ipykernel_launcher.py:8: RuntimeWarning: divide by zero encountered in log
  
/anaconda3/lib/python3.6/site-packages/ipykernel_launcher.py:8: RuntimeWarning: invalid value encountered in log
  

Exercise

In [4]:
display(Math('x = log(e^x)'))
display(Math('x = e^{log(x)}'))
$\displaystyle x = log(e^x)$
$\displaystyle x = e^{log(x)}$
In [5]:
x = np.linspace(.0001,10,10)
print(x)

y1 = np.log(np.exp(x))
y2 = np.exp(np.log(x))

plt.plot(x,y1,label='$\\log(e^x)$')
plt.plot(x,y2,'o',label='$e^{\\log(x)}$')

plt.axis('square')
plt.legend()
plt.show()
[1.0000e-04 1.1112e+00 2.2223e+00 3.3334e+00 4.4445e+00 5.5556e+00
 6.6667e+00 7.7778e+00 8.8889e+00 1.0000e+01]