Untitled

 avatar
unknown
plain_text
a year ago
909 B
6
Indexable
import numpy as np
import matplotlib.pyplot as plt

# Define the equations
def equation1(x):
    return -2*x + 6

def equation2(x):
    return x - 3

# Generate x values
x_values = np.linspace(-1, 5, 100)

# Plot the equations
plt.plot(x_values, equation1(x_values), label='2x + y = 6')
plt.plot(x_values, equation2(x_values), label='x - y = 3')

# Plot intersection point
intersection_x = 2
intersection_y = equation1(intersection_x)
plt.plot(intersection_x, intersection_y, 'ro')  # 'ro' for red dot

# Annotate intersection point
plt.text(intersection_x + 0.1, intersection_y - 0.5, f'({intersection_x}, {intersection_y})')

# Set labels and title
plt.xlabel('x')
plt.ylabel('y')
plt.title('Graph of System of Linear Equations')
plt.legend()

# Show plot
plt.grid(True)
plt.axhline(0, color='black',linewidth=0.5)
plt.axvline(0, color='black',linewidth=0.5)
plt.show()
 
Editor is loading...
Leave a Comment