freeCodeCamp/guide/english/mathematics/equation-of-a-line/index.md

38 lines
1.3 KiB
Markdown

---
title: Equation of a Line
---
## Equation of a Line
### For a Given Slope and y-intercept (Standard Form):
Let `m` be the slope of the line, and `b` be the y-intercept. (Note that the y-intercept is the point at which the given line crosses the y-axis). Then the equation of a line is:
`y = mx+b`
Keep in mind that you still have `y` which is the Dependant Variable and `x` the Independant Variable meaning that `x` can be any value, whereas `y` will be a value based off of what `x` is.
### For a Given Slope and One Point through which the Line Passes (Point-Slope Form):
Let `m` be the slope of the line and `(x1, y1)` be the co-ordinate of the point through which the given line passes. Then the equation of a line is:
`(y - y1) = m(x - x1)`
To break this down a bit, substitute your slope value (ex. 2) in for m:
`y=(2)x+b`
Next, substitute your point (ex. (3,2)) in for `x` and `y`. Remember that the points are `(x,y)` in that order. Always.
`(2)=2(3)+b`
Solve for `b`. Then put the equation back into `y=mx+b`.
`-4 = b`
Therefor your final answer is: `y=2x-4`
### For Two Points through which the Line Passes:
Let `(x1, y1)` and `(x2, y2)` be the co-ordinates of two points through which the given line passes. Then the equation of a line is:
`(y - y1)(x2 - x1) = (y2 - y1)(x - x1) `