Java-Gaming.org Hi !
 Featured games (90) games approved by the League of Dukes Games in Showcase (714) Games in Android Showcase (214) games submitted by our members Games in WIP (787) games currently in development
 News: Read the Java Gaming Resources, or peek at the official Java tutorials
Pages: [1]
 ignore  |  Print
 Quadratic equations  (Read 4813 times) 0 Members and 1 Guest are viewing this topic.
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.
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
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 -

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.
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?
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.
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.
ra4king

JGO Kernel

Medals: 471
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?!

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.
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
Porlus

Junior Devvie

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

Thanks for the reply. 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.
Jimmt
« League of Dukes »

JGO Kernel

Medals: 167
Projects: 5
Exp: 6 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.
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.
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.
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?

Jimmt
« League of Dukes »

JGO Kernel

Medals: 167
Projects: 5
Exp: 6 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.
HeroesGraveDev

JGO Kernel

Medals: 382
Projects: 11
Exp: 4 years

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

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

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.

pjt33

« JGO Spiffy Duke »

Medals: 40
Projects: 4
Exp: 7 years

 « 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.
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.
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.

Jimmt
« League of Dukes »

JGO Kernel

Medals: 167
Projects: 5
Exp: 6 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.

 Rule (80 views) 2017-03-19 12:43:22 Rule (66 views) 2017-03-19 12:42:17 Rule (76 views) 2017-03-19 12:36:21 theagentd (87 views) 2017-03-16 05:07:07 theagentd (87 views) 2017-03-15 22:37:06 theagentd (83 views) 2017-03-15 22:32:18 theagentd (81 views) 2017-03-15 22:31:11 ral0r2 (136 views) 2017-03-03 11:52:41 ral0r2 (134 views) 2017-03-03 11:42:24 Archive (316 views) 2017-02-27 19:41:49
 basil_ 20x philfrei 14x Apo 11x dime26 10x Archive 9x FrozenShade 9x bornander 7x KaiHH 7x FabulousFellini 7x SteveSmith 7x princec 7x Riven 6x CJC 6x Spasi 6x orangepascal 5x Ecumene 5x
 List of Learning Resourcesby elect2017-03-13 14:05:44List of Learning Resourcesby elect2017-03-13 14:04:45SF/X Librariesby philfrei2017-03-02 08:45:19SF/X Librariesby philfrei2017-03-02 08:44:05SF/X Librariesby SkyAphid2017-03-02 06:38:56SF/X Librariesby SkyAphid2017-03-02 06:38:32SF/X Librariesby SkyAphid2017-03-02 06:38:05SF/X Librariesby SkyAphid2017-03-02 06:37:51
 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