Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / [DBP] quadratic equation given two roots and a real number

Author
Message
Neuro Fuzzy
16
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 4th Dec 2009 08:14
So... my algebra teacher kept asking us something like "The roots of this equation are 3 and 5, find the equation". There's no single equation, there are a series of equations (a "line" of equations, because the equation depends on a one dimensional term)
So i decided to figure it out, of course The code's at the bottom of the post, but here's the math:

r1 and r2 are the roots (x intercepts) of f(x)=ax^2+bx+c

m is the x coord of the line of symmetry going through the center of the parabola

since m is equidistant from the x intercepts, we can say

M=(r1+r2)/2

The line of symmetry can also be found using -b/(2*a), so...

M=-b/(2*a)
-2aM=b

so now f(x)=ax^2-2aMx+c

Now, R1 and R2 are solutions of the equation f(x)=0, so...

a(r1)^2-2aM(r1)+c=0
c=-a(r1)^2+2aM(r1)

Plugging that back into f(x)=ax^2-2aMx+c...
f(x)=ax^2-2aMx-a(r1)^2+2aM(r1)
f(x)=a(x2-2Mx-(r1)^2+2M(r1))
which can also be expressed as
f(x)=a(x^2-2Mx+M^2-(r1-M)^2)

so, given two solutions of 0=ax^2+bx+c, you can find a plane [f(x,a)=y] of solutions.

t3h code?



Click to change r1 and r2, the mouse y controls a.




Now... what would be really interesting would be seeing this only given r1. The shape would then be four dimensional (f(x,r2,a)=y), but could probably be easily visualized by a volumetric display (or a plane changing over some user-controlled variable). It might be worth looking into.

Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 15th Dec 2009 21:32
I'm not quite sure what all the math is for.

When given n roots of a polynomial of degree n, the equation can be written as followed:
f(x) = a * (x - x1) * (x - x2) * ... * (x - xn)

in your case:
f(x) = a * (x - x1) * (x - x2)
where x1 and x2 are the roots that are given.

Cheers!
Sven

Neuro Fuzzy
16
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 16th Dec 2009 03:40


Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 16th Dec 2009 15:13
Lol...

Neuro Fuzzy
16
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 26th Jan 2010 06:07
bored, so I decided to simplify the above equation. Guess what???
M=-b/(2*a)
f(x)=a(x^2-2Mx+M^2-(r1-M)^2)
simplifies to

f(x)=-a(x-r1)(x-r2)



Long roundabout way of pretty much the same thing I guess. this was either a huge waste of time and illustration of stupidity on my part or a good practice in logic? Little bit of both?


Madscientist
14
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 27th Feb 2010 02:51
Fun with parabolas!!
(If I can Spell it)

If it hasn't exploded yet, I haven't touched it.

Login to post a reply

Server time is: 2024-04-20 12:39:22
Your offset time is: 2024-04-20 12:39:22