Is there anyway of diagnosign a syntax error in python?

  python, scipy

I’m trying to solve a system of 4 non-linear equations using fsolve, but I’m getting a consistent syntax error on the last 3 equations, which I’m not able to identify the root cause of. I’ve tried rewriting the expression multiple times with multiple editors, but the error keeps popping up. What am I doing wrong?

import numpy as np

def f(p):

f0 = (p[0] + ((p[1] ** 2) / (2 * 1005)) - 300
f1 = (50000 * (p[0] / 300) ** -3.5) - p[3]
f2 = (p[3] / (8.3 * p[1])) - p[2]
f3 = (p[2] * p[1] * 500) - 5

return np.array([f0, f1, f2, f3])

p_guess = np.array([300, 231, 0.5, 50000])

p = fsolve(f, p_guess)

print("T_in = ", p[0], "v_in = ", p1, "rho_in = ", p[2] ,"p_in = ", p[3])

error output

Source: Python Questions

LEAVE A COMMENT