import numpy as np
import matplotlib.pyplot as plt
f = 900e6
ht = 30
hr = 2
c = 3e8
lam = c / f
d = np.arange(1, 11) * 1000
FS = 20 * np.log10(4 * np.pi * d / lam)
TR = (40 * np.log10(d)
      - 20 * np.log10(ht)
      - 20 * np.log10(hr))
print("Wavelength =", lam, "m")
print("Free Space Loss =", FS[-1], "dB")
print("Two Ray Loss =", TR[-1], "dB")
plt.figure(figsize=(8, 5))
plt.plot(d / 1000, FS, 'o-', label="Free Space")
plt.plot(d / 1000, TR, 'o-', label="Two Ray")
plt.xlabel("Distance (km)")
plt.ylabel("Path Loss (dB)")
plt.title("Path Loss Comparison")
plt.grid(True)
plt.legend()
plt.tight_layout()
plt.show()
