You are encountering an error in the line plt.plot(ib_by_ith, 20*math.log10(RIN12)) because the math.log10() function is unable to handle array operations. To resolve this, you can replace math.log10() with np.log10() from the NumPy library, which can handle array calculations. Here's the revised code:
import math
import matplotlib.pyplot as plt
import numpy as np
%matplotlib inline
# Variable declaration
ib_by_ith1 = 1.5 # injection current1 > 1.2
ib_by_ith2 = 1.6 # injection current2
ib_by_ith3 = 1.7 # injection current3
f = 100.0 * 10 ** 6 # frequency (hz)
# Calculation
RIN1 = ((ib_by_ith1 - 1) ** -3) / f
RIN2 = ((ib_by_ith2 - 1) ** -3) / f
RIN3 = ((ib_by_ith3 - 1) ** -3) / f
RIN_dB1 = 20 * np.log10(RIN1) # noise to signal power ratio1(dB/Hz)
RIN_dB2 = 20 * np.log10(RIN2) # noise to signal power ratio2(dB/Hz)
RIN_dB3 = 20 * np.log10(RIN3) # noise to signal power ratio3(dB/Hz)
# Result
print("Index guided lasers lie between", round(RIN_dB1, 0), "dB/Hz,", round(RIN_dB2, 0), "dB/Hz, and",
round(RIN_dB3, 1), "dB/Hz")
# Plot
f1 = 1.0 * 10 ** 8 # several hundred MHz
ib_by_ith = np.arange(0.0, 2.5, 0.1)
RIN12 = ((ib_by_ith - 1.0) ** -3) / f1
plt.plot(ib_by_ith, 20 * np.log10(RIN12))
plt.ylabel('RIN(dB/Hz)')
plt.xlabel('Ib/Ith')
plt.title('Plot of relative intensity. The noise level = 100MHz')
plt.show()
By utilizing np.log10() instead of math.log10(), the array calculations will be handled correctly, resolving the error you encountered.