I am trying to plot the following function...
f(k) = Re[k - 0.5*(sqrt(1 - 4*k) + 1)]
for k = [-2, 2]
, but the best I can do is...
import matplotlib.pyplot as plt
import numpy as np
k = np.linspace(-2, 2, 100)
f = np.real(k - 0.5*(np.sqrt(1 - 4*k) + 1))
plt.plot(k, f)
plt.axis([-2,2,-10,10])
which plots fine for k = [-2, 1/4)
but nothing for complex results. Can I do this some other way?