Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (524)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (592)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Quadratic equations  (Read 2046 times)
0 Members and 1 Guest are viewing this topic.
Offline Porlus

Junior Devvie





« Posted 2013-06-12 23:39:40 »

Hi all, I'm trying to learn how to solve quadratic equations but I've ran into a problem.
On the wikipedia page: http://en.wikipedia.org/wiki/Quadratic_equation
It explains the step by step process of solving a quadratic equation using the "Complete the square" method. The fourth step states: "Write the left side as a square, and simplify the right side, if necessary."
And this appears to change the expression "x² + 2x + 1" into "(x + 1)²" and I'm not exactly sure how that's come about. Could somebody explain it to me?

Thanks!

Paul
Offline Agro
« Reply #1 - Posted 2013-06-12 23:46:24 »

If its for a program, just use the quadratic equation that solves it all:

x1,x2 = (-b (+/-) sqrt(b^2-4ac)) /2a

you have to do it twice, one for the + and another for the -

Offline Geemili

Senior Devvie


Medals: 9
Projects: 1
Exp: 2 years


No Games Finished


« Reply #2 - Posted 2013-06-12 23:48:52 »

Basically,you multiply (x+1) by (x+1). So you go
First, (x+1)(x+1), which is x*x, or x^2
Outside, (x+1)(x+1), which is x*1, or simply x
Inside, (x+1)(x+1), which is 1*x, or simply x
Last, (x+1)(x+1), which is 1*1, or 1
Then you put it together and it becomes x^2 + x + x + 1, which is then simplified to x^2 + 2x + 1. This process is called FOIL.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Porlus

Junior Devvie





« Reply #3 - Posted 2013-06-12 23:55:04 »

Thanks for the replies guys! So Geemili, is what I described just FOIL in reverse?
Offline Geemili

Senior Devvie


Medals: 9
Projects: 1
Exp: 2 years


No Games Finished


« Reply #4 - Posted 2013-06-13 00:12:05 »

Oh, I didn't read your post closely enough. I don't know the process of getting from "x² + 2x + 1", how I remember solving it in math class is by plugging in random numbers into (ax + b)(cx + d), until it would form the quadratic equation through FOIL.  I'm sure there's a better way, I just don't know it.  Tongue
Offline Porlus

Junior Devvie





« Reply #5 - Posted 2013-06-13 00:18:55 »

Yeah, I keep re-reading this instructions thinking I'm missing a subtle wording, but that step completely throws me. The other steps are fairly trivial.
Offline ra4king

JGO Kernel


Medals: 355
Projects: 3
Exp: 5 years


I'm the King!


« Reply #6 - Posted 2013-06-13 01:08:26 »

Holy crap you don't know Algebra (yet hopefully?)........how old are you Porlus?!

Offline Porlus

Junior Devvie





« Reply #7 - Posted 2013-06-13 01:18:43 »

Old enough for it to be embarrassing. ): I'm alright with other areas of algebra. This has just stumped me.
Offline tyeeeee1
« Reply #8 - Posted 2013-06-13 01:23:49 »

I'll second what Agro said about the quadratic formula. It's really easy, you just plug in the numbers and out comes the answer.
 (-b±√(b²-4ac)) / (2a)
As far as I remember you use this with a trinomial or something like that... I haven't used it in a while. =P
Offline Porlus

Junior Devvie





« Reply #9 - Posted 2013-06-13 01:32:22 »

Thanks for the reply. Smiley Yeah, all I remember from secondary school with regards to quadratic equations was that formula. I'm just trying to look at the other methods of solving it to help me get a better understanding. Completing the square is the method that I recall the teacher saying takes too long to work out in an exam. Hurray for the British education system. D: So now I'm trying to learn it on my own and struggling a bit.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Jimmt
« League of Dukes »

JGO Kernel


Medals: 138
Projects: 4
Exp: 3 years



« Reply #10 - Posted 2013-06-13 01:33:20 »

Oh, I didn't read your post closely enough. I don't know the process of getting from "x² + 2x + 1", how I remember solving it in math class is by plugging in random numbers into (ax + b)(cx + d), until it would form the quadratic equation through FOIL.  I'm sure there's a better way, I just don't know it.  Tongue
The "plug in numbers" method is bullshit, but all the schools teach it. I don't think that's his question though...
"x² + 2x + 1"
To be able to simplify, your equation needs to be in the form  a^2 + 2ab + b^2 which it already is. Now "a^2 + 2ab + b^2" simplifies into "(a+b)^2", so looking at your equation, the root of x² is x and the root of 1 is 1. Thus you have (x+1)^2.
Offline Longarmx
« Reply #11 - Posted 2013-06-13 03:33:41 »

Oh, I didn't read your post closely enough. I don't know the process of getting from "x² + 2x + 1", how I remember solving it in math class is by plugging in random numbers into (ax + b)(cx + d), until it would form the quadratic equation through FOIL.  I'm sure there's a better way, I just don't know it.  Tongue
The "plug in numbers" method is bullshit, but all the schools teach it. I don't think that's his question though...
"x² + 2x + 1"
To be able to simplify, your equation needs to be in the form  a^2 + 2ab + b^2 which it already is. Now "a^2 + 2ab + b^2" simplifies into "(a+b)^2", so looking at your equation, the root of x² is x and the root of 1 is 1. Thus you have (x+1)^2.

I dot know what your talking about. The quadradic formula is great for getting values of x that aren't whole for polynomials with degrees of two. It doesn't help in factoring at all, but if you already have x, why factor?

Offline Jimmt
« League of Dukes »

JGO Kernel


Medals: 138
Projects: 4
Exp: 3 years



« Reply #12 - Posted 2013-06-13 03:37:09 »

And this appears to change the expression "x² + 2x + 1" into "(x + 1)²" and I'm not exactly sure how that's come about. Could somebody explain it to me?
He's asking someone to explain why "x² + 2x + 1" can be factored into "(x + 1)²" and how. He never asked anything about finding what x was, or how to use it in a program.
Offline HeroesGraveDev

JGO Kernel


Medals: 296
Projects: 11
Exp: 3 years


┬─┬ノ(ಠ_ಠノ)(╯°□°)╯︵ ┻━┻


« Reply #13 - Posted 2013-06-13 04:34:24 »

Solving Quadratic Equations (by brain):

You have to make one side equal zero. Because if one side is zero, one (or both) of the factors has to be zero. Then you find the 2 (or sometimes 1) value(s) of x, and you take the one you want.

1. If the equation is in the form (ax + b)^2 = 0

This means that ax + b = 0
-> ax = -b
-> x = (-b)/a

2. If the equation is in the form (ax + b)(cx + d) = 0

This means that either ax + b = 0 or cx + d = 0
First, assume ax1 + b = 0 (x1 and x2 are the possible values of x)
-> x1 = (-b)/a
and then cx2 + d = 0
-> x2 = (-d)/c

So now you have x1 and x2. But you only want one. This is where it comes down to common sense. (eg: can't have negative amounts of people etc.) Look back to the situation.

3. If the equation is in the form ax^2 + bx + c = 0

You need to get this into factorised form.

Find two numbers (d and e) that match the following equations:
de = ac (and therefore: d/a = e/c, which is important later)
d+e = b

Now you can rearrange the formula to this:
ax^2 + dx + ex + c = 0

Factorise the first two terms, and the last two terms seperately:
ax^2 + dx = ax(x + d/a)
ex + c = e(x + c/e)

And because d/a = c/e (as shown above), we'll make it easier by having f = d/a = c/e.
The new equations:
ax(x + f)
e(x + f)

And now to add them together again:
ax(x + f) + e(x + f) = 0
(ax + e)(x + f) = 0

Now continue with method #2 above.

4. For other equations

Rearrange into ax^2 + bx + c = 0, then use method #3.

Note: For programming purposes, use the quadratic formula.

Offline pjt33
« Reply #14 - Posted 2013-06-13 07:36:59 »

Completing the square is the method that I recall the teacher saying takes too long to work out in an exam.
It doesn't take that long, and it's the way that the formula you memorise was derived.

If you're needing to solve quadratic equations for a game, be aware that there are numerical issues with one half of -b +/- sqrt(b^2 - 4ac) when 4ac is small. The way to handle this is to have a case split on the sign of b and then to use the fact that the product of the roots is c/a.
Offline Sammidysam
« Reply #15 - Posted 2013-06-13 12:41:03 »

Completing the square is way easier if the variable a in the quadratic equation does not have coefficients, e.g. x2 + 3x + 2.  Then it's by far way simpler than having to write out the whole quadratic formula and solve it.  But if you have a coefficient for the variable a, it takes way too long.
Offline Longarmx
« Reply #16 - Posted 2013-06-13 14:12:50 »

And this appears to change the expression "x² + 2x + 1" into "(x + 1)²" and I'm not exactly sure how that's come about. Could somebody explain it to me?
He's asking someone to explain why "x² + 2x + 1" can be factored into "(x + 1)²" and how. He never asked anything about finding what x was, or how to use it in a program.

Ah, I understand now. I guess just the way you worded it made me think differently. 

Offline Jimmt
« League of Dukes »

JGO Kernel


Medals: 138
Projects: 4
Exp: 3 years



« Reply #17 - Posted 2013-06-13 16:12:14 »

Completing the square is way easier if the variable a in the quadratic equation does not have coefficients, e.g. x2 + 3x + 2.  Then it's by far way simpler than having to write out the whole quadratic formula and solve it.  But if you have a coefficient for the variable a, it takes way too long.
Not necessarily true. The multiples of the coefficient of "a" you can plugin on the left of a matrix - and the multiples of "c" you can plug in on the right. For example: 5x2 + 12x + 4
----
5|2
----
1|2
----
Cross multiply and add 5*2 + 2*1 = 12. Which means this is the solution, because it equals the coefficient of x (middle term) - to convert into 2 binomials just do (5x + 2)(x + 2). Obviously, you still have to plug in some numbers, but this way is a lot faster.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

toopeicgaming1999 (55 views)
2014-11-26 15:22:04

toopeicgaming1999 (48 views)
2014-11-26 15:20:36

toopeicgaming1999 (8 views)
2014-11-26 15:20:08

SHC (24 views)
2014-11-25 12:00:59

SHC (24 views)
2014-11-25 11:53:45

Norakomi (26 views)
2014-11-25 11:26:43

Gibbo3771 (23 views)
2014-11-24 19:59:16

trollwarrior1 (36 views)
2014-11-22 12:13:56

xFryIx (75 views)
2014-11-13 12:34:49

digdugdiggy (52 views)
2014-11-12 21:11:50
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!