I am new to Python. I am sharing a code snippet which is a part of a code to read data from a file and make the needed calculations. I have 3 nonlinear eqs with 3 unknowns. I wrote the following code to solve it, but the code gives me an error of:
File "<ipython-input-46-bc67ad1b6153>", line 4
eq2 = (y/(1-y) - (5/(8*np.pi * np.cos(z))) * (1 - (np.cot(z)))
^
SyntaxError: invalid syntax
I do not think the syntax is wrong, but I am not sure if this kind of solution works in my case. Also, my variable "x" should be in the rage between 1/4 and 1/3
My code:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import math
from scipy.optimize import fsolve
def equations(vars):
x, y, z = vars
eq1 = (x/(1-x) - (5/(8*np.pi*np.sin(z)**2) * (1 + 4*(np.tan(z))
eq2 = (y/(1-y) - (5/(8*np.pi * np.cos(z))) * (1 - (np.cot(z)))
eq3 = np.tan(z) - ((1-x) / 3 * (1+y))
return [eq1, eq2, eq3]
x, y,z = fsolve(equations, (1, 1, 1))
print(x, y, z)