# [JASS]Fun with Arcs (parabola!)

#### wd40bomber7

Level 11
Ok everybody loves a good quadratic, right? Anyway I understand how to take two points and get a linear equation. I understand how to make a parabola along the X or Y axis using quadratics. What I want is to use three points to find a quadratic equation.

(See diagram)

#### Attachments

• Equ.JPG
11 KB · Views: 125

#### Eleandor

Level 21
ax² + bx + c = y

Let's say we have 3 points, For example:
(1,1)
(2,3)
(3,5)

Then all we need to do is fill in the x and y of our points in order to get the right equation.

In this example, we get:
a (1)² + b (1) + c = 1
a (2)² + b (2) + c = 3
a (3)² + b (3) + c = 5

Thus

a + b + c = 1
4a + 2b + c = 3
9a + 3b + c = 5

then just mess around with those 3 lines and you should get a corresponding a, b and c...

#### wd40bomber7

Level 11
There must be an easier way then guessing. Perhaps kramer's rule? Maybe not, I'm not sure if it works with quadratics.... Then again the quadratic dissapears, so it probably does. I'll get back to you on that.

#### Eleandor

Level 21
It's not guessing... It's just doing the same you do when solving a linear equation.

a + b + c = 1
4a + 2b + c = 3
9a + 3b + c = 5

Thus:
c = 1 - a - b
4a + 2b + c = 3
9a + 3b + c = 5

Thus:
c = 1 - a - b
4a + 2b + 1 - a - b = 3
9a + 3b + 1 - a - b = 5

Thus
c = 1 - a - b
3a + b = 2 ==> b = 2 - 3a
9a + 3b + 1 - a - b = 5 ==> 9a +6 - 9a + 1 -a - 2 +3a = 5
==> 2a +6 +1 -5 = 0 ==> 2a +2 = 0 ==> a = -1

If a = -1 then:
b = 2 - 3a ==> b = 2 + 3 = 5
then c = 1 - a - b ==> c = 1 +1 -5 = -3

Thus:
a = -1
b = 5
c = -3

Thus the equation is -x² +5x -3 = 0

It's just basic maths...

#### wd40bomber7

Level 11
Kramer's rule would have done the same thing, except I prefer kramer's rule. Anyway thanks for the help. Problem solved.

#### wd40bomber7

Level 11
Sorry for the double post, but the problems not solved. If its so easy Eleandor, why doesn't it work? First of all -x² +5x -3 does not equal zero. Its supposed to equal y (I'm assuming) But it doesn't equal Y either.

ax² + bx + c = y

Let's say we have 3 points, For example:
(1,1)
(2,3)
(3,5)

So lets put 3 in for x.
-(3)² +(5*3) -3
Simplify
-9 + 15 -3
15 - 12 = 3 (not 5)
Next lets try 2
-(2)²+(5*2)-3
-4+10-3
10-7=3 (Hey that worked!)
Finally lets try 1
-(1)²+(5*1)-3
-1+5-3
5-4 = 1(Hey that worked two!)

So you got 2/3, close but no cigar.

Since you only got the last one wrong, I'm assuming you screwed some arithmetic in the last step. So much for 'easy'

#### PurplePoot

Level 40
He meant y, yes, and it works fine for his equation. Post the code (or your calculations assuming it's constant)

#### wd40bomber7

Level 11
I edited my previous post with my assumptions.

#### PurplePoot

Level 40
Hmm, guess I messed something up when I calculated it, but yeah.

#### gralamin

Level 3
Those points aren't quadratic, they are a line, thus A=0.
Proof:
C=1-A-B
4A+2B+1-A-B=3
3A+B+1=3
B=2-3A
C=1-A-2-3A
C=-1-4A
9A+3(2-3A)-1-4A=5
9A-9A-4A+6-1=5
-4A+5=5
-4A=0
A=0
B=2
C=-1
Thus the line Y=2x-1 follows that pattern.

#### Mechanical Man

Level 34
Interpolation with linear equation is not efficent. Use Newton interpolation instead.

#### Eleandor

Level 21
Sorry, my fault

Anyway, the principle is the same, so...

Replies
9
Views
1K
Replies
6
Views
1K
Replies
9
Views
991
Replies
0
Views
2K
Replies
9
Views
781