import numpy as np
import matplotlib.pyplot as plt
from IPython.display import display,Math
print('Logarithm and multiplication')
display(Math('\\log(a \\times b) = \\log(a) + \\log(b)'))
display(Math('\\log \\left( \\frac {a}{b} \\right) = \\log(a) - \\log(b)'))
a = 3
b = 4
res1 = np.log(a*b)
res2 = np.log(a) * np.log(b)
res3 = np.log(a) + np.log(b)
display(Math('\\log(%g \\times %g) = %g' %(a,b,res1)))
display(Math('\\log(%g) \\times \\log(%g) = %g' %(a,b,res2)))
display(Math('\\log(%g) + \\log(%g) = %g' %(a,b,res3)))
display(Math('\\log(%g \\times %g) = \\log(%g) + \\log(%g)' %(a,b,a,b)))
display(Math('\\log(%g \\times %g) \\neq \\log(%g) * \\log(%g)' %(a,b,a,b)))
res1 = np.log(a/b)
res2 = np.log(a) / np.log(b)
res3 = np.log(a) - np.log(b)
display(Math('\\log \\left(\\frac{%g}{%g} \\right) = %g' %(a,b,res1)))
display(Math('\\frac {\\log(%g)}{\\log(%g)} = %g' %(a,b,res2)))
display(Math('\\log(%g) - \\log(%g) = %g' %(a,b,res3)))
display(Math('\\log \\left(\\frac{%g}{%g} \\right) = \\log(%g) - \\log(%g)' %(a,b,a,b)))
display(Math('\\log \\left(\\frac{%g}{%g} \\right) \\neq \\frac{\\log(%g)}{\\log(%g)}' %(a,b,a,b)))
Exercise
display(Math('\\log \\left(a^b \\right) = {b \\log(a)}'))
expr1 = np.log(a**b)
expr2 = b*np.log(a)
expr3 = np.log(a) + np.log(a) + np.log(a) + np.log(a)
print(expr1-expr2)
print(expr1,expr2,expr3)