In question Solving Systems of Linear Equations, quesion C32 asks to find the solution of the following system of equations:
x + 2y = 8
x - y = 2
x + y = 4
My classmate, Jean, demonstrated how by creating a matrix in r and using the solve() function - they found that the solution does not exist. I wanted to show this graphically. I wrote the equations in terms of y, and then graphed them.
y = (-1/2)x + 4
y = x + 2
y = -x + 4
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.2.3
eq = function(x){-(1/2)*x + 4}
eq2 = function(x){x + 2}
eq3 = function(x){-x + 4}
ggplot(data.frame(x = c(-10,10)), aes(x=x)) + stat_function(fun = eq) +
stat_function(fun = eq2) +
stat_function(fun = eq3)
Based on the graph it is clear that the equations do not all intersect at one point.