Win a copy of Functional Reactive Programming this week in the Other Languages forum!

# Need some basic algebra methods....

Will Carpenter
Greenhorn
Posts: 26
Given two points on a graph (you know, each with a x-coordinate and a y-coordinate) which method could I use to determine the slope of a line between those two points?
Which method could I use to determine the distance between those two points?
Given three integer coefficients, A, B, C, which method could I use to solve a quadratic function of the form: Ax^2 + Bx + C = 0 ?
Given four integer coefficients, A, B, C, D which method could I use to find the derivative of a cube polynomial function: Ax^3 + Bx^2 + Cx + D?

Carlos Failde
Ranch Hand
Posts: 84

Given two points on a graph (you know, each with a x-coordinate and a y-coordinate) which method could I use to determine the slope of a line between those two points?

If point one has coordinates x1,y1 and point two has coords x2,y2
then the slope is
(y2 - y1) / (x2 - x1)

Which method could I use to determine the distance between those two points?

Pythagoras's Theorem:
distance = sqrt[ (y2-y1)^2 + (x2 - x1)^2 ]

Given three integer coefficients, A, B, C, which method could I use to solve a quadratic function of the form: Ax^2 + Bx + C = 0 ?

Oh dear how embarrassing that I had to look that one up
One root is x = [ -B + sqrt( B^2 - 4*A*C) ] / (2*A)
The other is x = [ -B - sqrt( B^2 - 4*A*C) ] / (2*A)

Given four integer coefficients, A, B, C, D which method could I use to find the derivative of a cube polynomial function: Ax^3 + Bx^2 + Cx + D?

Yikes... er ... .... hey what's that thing behind you !? .... *RUNS* (hee hee hee)
[ March 20, 2004: Message edited by: Carlos Failde ]

chi Lin
Ranch Hand
Posts: 348
derivative function would be 3Ax^2+2Bx+C for each x.

Given four integer coefficients, A, B, C, D which method could I use to find the derivative of a cube polynomial function: Ax^3 + Bx^2 + Cx + D?

Will Carpenter
Greenhorn
Posts: 26
Thanks Carlos and Chi Lin!
(Although I though for sure there would be some methods that did those. You know, something like slope(int a, int b, int c, int d). Now I guess I'll have to do some work. )

Tim West
Ranch Hand
Posts: 539
There's a proof in number theory that there's no formula for the zeroes of an order-5 polynomial (ie, p(x) = ax^5 + bx^4 + cx^3 + dx^2 + ex + f), or any polynomial of greater order.
OK, when I say "formula", I mean a function f(a, b, c, d, e, f) which yields the zeroes to p(x) above.
IIRC there are formulae for the zeroes of polynomials of orders 3 and 4, but they're sufficiently complex that in almost all circumstances an approximation is better.

--Tim