I wrote code to solve five equations with five variables. Once I run the code there is no result and no errors. could anyone fix the problem?
###This is the code###
from sympy import symbols, Eq, solve
Define the variables
A,B,C,D,E = symbols('A B C D E')
eq1 = Eq((0.1638*A + 0.1831*B)/(0.16617*C + 0.7679*D) + E ,0.317 )
eq2 = Eq((0.1130*A + 0.1126*B)/(0.4766*C + 0.6885*D) + E ,0.256 )
eq3 = Eq((0.2465*A + 0.2922*B)/(0.4562*C + 0.6312*D) + E ,0.533 )
eq4 = Eq((0.077*A + 0.0594*B)/(0.4849*C + 0.6147*D) + E ,0.177 )
eq5 = Eq((0.0743*A + 0.074*B)/(0.3666*C + 0.5413*D) + E ,0.178 )
Solve the system of equations
solution = solve((eq1, eq2, eq3, eq4, eq5),(A, B, C, D, E))
Print the solution
print(solution)`your text`
>Solution :
You can use numpy.
Here’s an example;
import numpy as np
# Define the coefficients of the equations
coefficients = np.array([[2, 1, -3, 4, 1],
[1, -1, 2, 3, -2],
[3, -2, 1, -5, 3],
[2, 4, -1, 3, -1],
[1, 3, -4, -2, 1]])
# Define the constants on the right-hand side of the equations
constants = np.array([4, -3, 9, 8, 2])
# Solve the equations
solution = np.linalg.solve(coefficients, constants)
# Printing
print("Solution:", solution)
This prints;
Solution: [0.97900262 2.64304462 2.41732283 0.64829396 4.05774278]