# Hiermee bereken je de parameters in het geval dat D < 0 import numpy as np E = 0.9 J = 5 Rs = 1 K = E U = 1 - K**2 a = Rs b = -1 c = Rs / J**2 d = - U / J**2 D = 18 * a * b * c * d - 4 * a * c**3 - 27 * a**2 * d**2 + b**2 * c**2 - 4 * b**3 * d n1a = 1 / (3 * Rs) n1b = 1 / (27 * Rs**3) + 1 / (3 * Rs * J**2) - E**2 / (2 * Rs * J**2) n1c = np.sqrt (E**4 / (4 * Rs**2 * J**4) - E**2 / (3 * Rs**2 * J**4) - E**2 / (27 * Rs**4 * J**2) \ + 1 / (27 * J**6) + 2 / (27 * Rs**2 * J**4) + 1 / (27 * Rs**4 * J**2)) n1d = n1b + n1c n1e = n1b - n1c if n1d < 0: n1d = - (- n1d)**(1/3) else: n1d = n1d**(1/3) if n1e < 0: n1e = - (- n1e)**(1/3) else: n1e = n1e**(1/3) n1 = n1a + n1d + n1e r1 = 1 / n1 print ("J = ", J) print ("Rs = ", Rs) print ("E = ", E) print ("K = ", K) print ("U = ", U) print ("a = ", a) print ("b = ", b) print ("c = ", c) print ("d = ", d) print ("D = ", D) print ("n1 = ", n1) print ("r1 = ", r1)