Robotics & Artificial Intelligence
Write a Python program to solve the following linear equations:
2x + y = 5
x + 3y = 8
Python Modules
1 Like
Answer
import numpy as np
from scipy.linalg import solve
coefficients = np.array([[2, 1], [1, 3]])
constants = np.array([5, 8])
solution = solve(coefficients, constants)
x = solution[0]
y = solution[1]
print("x =", x)
print("y =", y)Output
x = 1.3999999999999997
y = 2.2
Answered By
3 Likes
Related Questions
Create a Python package and one module under it. Write Python code to use this package.
Explain any four functions of the Matplotlib library.
Explore the Matplotlib library for plotting bar charts, line charts and pi charts.
Explore the Pandas library to read the data that is available in .csv or .xlsx files. Plot the data with the help of Matplotlib.