# Khan/khan-exercises

### Subversion checkout URL

You can clone with
or
.
Fetching contributors…

Cannot retrieve contributors at this time

103 lines (102 sloc) 7.379 kB
 Completing the square 2
randRange( 1, 4 ) / randRangeNonZero( -2, 2 ) ( randRange( -3, 3 ) * 2 + 1 ) / 2 ( X1 + X2 ) * -1 B > 0 ? "+" : "-" X1 * X2 getLCM( toFraction( B )[1], toFraction( C )[1] ) new Polynomial( 0, 2, [MULT*C, MULT*B, MULT], "x" ) POLY.text()

Solve for x by completing the square.

POLY_TEXT = 0

X1
X2

integers, like 6

simplified proper fractions, like 3/5

simplified improper fractions, like 7/4

and/or exact decimals, like 0.75

( randRange( -4, 4 ) * 2 + 1 ) / 2 X1

x = {}X1

integers, like 6

simplified proper fractions, like 3/5

simplified improper fractions, like 7/4

and/or exact decimals, like 0.75

randRangeNonZero( -8, 8 ) randRange( -4, 4 ) * 2 + ( X1 % 2 - 1 )

First, divide the polynomial by MULT, the coefficient of the x^2 term.

x^2 + decimalFraction( B, 1, 1 )B_SIGNx + decimalFraction( C, 1, 1 ) = 0

Move the constant term to the right side of the equation.

x^2 + decimalFraction( B, 1, 1 )B_SIGNx = decimalFraction( C * -1, 1, 1 )

We complete the square by taking half of the coefficient of our x term, squaring it, and adding it to both sides of the equation. The coefficient of our x term is decimalFraction( B, 1, 1 ), so half of it would be decimalFraction( B / 2, 1, 1 ), and squaring it gives us \color{blue}{decimalFraction( pow( B / 2, 2 ), 1, 1 )}.

x^2 + decimalFraction( B, 1, 1 )B_SIGNx \color{blue}{ + decimalFraction( pow( B / 2, 2 ), 1, 1 )} = decimalFraction( C * -1, 1, 1 ) \color{blue}{ + decimalFraction( pow( B / 2, 2 ), 1, 1 )}

We can now rewrite the left side of the equation as a squared term.

( x + decimalFraction( B / 2, 1, 1 ) )^2 = decimalFraction( C * -1 + pow( B / 2, 2 ), 1, 1 )

Note that the left side of the equation is already a perfect square trinomial. The coefficient of our x term is decimalFraction( B, 1, 1 ), half of it is decimalFraction( B / 2, 1, 1 ), and squaring it gives us \color{blue}{decimalFraction( pow( B / 2, 2 ), 1, 1 )}, our constant term.

Thus, we can rewrite the left side of the equation as a squared term.

( x + decimalFraction( B / 2, 1, 1 ) )^2 = decimalFraction( C * -1 + pow( B / 2, 2 ), 1, 1 )

Take the square root of both sides.

x + decimalFraction( B / 2, 1, 1 ) = \pmdecimalFraction( sqrt( C * -1 + pow( B / 2, 2 ) ), 1, 1 )

Isolate x to find the solution(s).

x = decimalFraction( -B / 2, 1, 1 )\pmdecimalFraction( sqrt( C * -1 + pow( B / 2, 2 ) ), 1, 1 )

x = decimalFraction( -B / 2 + sqrt( C * -1 + pow( B / 2, 2 ) ), 1, 1 ) \text{ or } x = decimalFraction( -B / 2 - sqrt( C * -1 + pow( B / 2, 2 ) ), 1, 1 )

x = decimalFraction( -B / 2 + sqrt( C * -1 + pow( B / 2, 2 ) ), 1, 1 ) \text{ or } x = decimalFraction( -B / 2 - sqrt( C * -1 + pow( B / 2, 2 ) ), 1, 1 )

Something went wrong with that request. Please try again.