# how to solve $x^2 = 3x + 4$

I am a programmer in the eighth grade taking algebra 1. I am only about a month into the school year, and I need to know how to solve something similar to this equation:

$x^2 = 3x + 4$

However, the problem is that whenever I try to get the square root of both sides of the equation to get rid of the $x^2$, I get something like this:

$x = \sqrt{3x + 4}$

After this, I couldn't figure out what to do, because my only option was to square both sides of the equation, which would get me back where I started. So, how would I solve this? Please make the answer simple enough so that an algebra 1 student would understand. Also, sorry for the tag that probably isn't great, my rep is so low I cant create a new tag (I would probably tag this as algebra 1).

• – user228113 Sep 7 '16 at 20:51
• @G.Sassatelli that is overkill for someone who is just starting algebra 1. – Doug M Sep 7 '16 at 20:52
• Use a fixed point method, you should have learned about this in your numerical analysis class. – Thoth Sep 7 '16 at 20:56
• @DougM I get eighth grade is the last year of middle school. I don't remember if I've learnt the formula that year, the year before or the year after. And I really can't be bothered: as far as I know, it's elementary and anyone older than 12 has the tools to learn it by heart and use it effectively. – user228113 Sep 7 '16 at 20:57
• @DougM Seventeen? Oh, God. That's why it's so full of people asking how to solve $3x^2+2x+5=0$ out here. – user228113 Sep 7 '16 at 21:06

## Solving

What you need is called the quadratic formula. It is used to solve quadratic equations, which are of the form $ax^2+bx+c=0$. This could be $x^2+3x+2$, for example. With your equation, what you first need to do get $0$ on one side of the equals sign:

$$x^2=3x+4$$ $$0=-x^2+3x+4$$

Okay, now we clearly have a quadratic equation. A good thing to do when using the quadratic formula is defining $a$, $b$, and $c$ (remember the standard form). So, in this case, you'd have

$$a=-1$$ $$b=3$$ $$c=4$$

Next, we literally just plug the numbers into the formula if doing it by hand. The formula is

$$x=\frac{-b \pm \sqrt{b^2-4ac}}{2a}$$

So, we have $$x=\frac{-3 \pm \sqrt{3^2-4*-1*4}}{2*-1}$$ Which reduces to $$x = \frac{-3 \pm 5}{-2}$$

Now, there are almost always two solutions to the quadratic formula (at least in Algebra I textbook problems), because when graphed, quadratic equations take the form of a parabola:

which crosses the x-axis at two places, and we are solving for $x$.

So, the solution is $$x=-1$$ or $$x=4$$ Honestly, I think this is the easiest way to solve a quadratic (though you should know all of them).

Factoring

Factoring operates off of the zero product property (ZPP). Basically, it just says that in an equation $ax=0$ either $a=0$ or $x=0$. Simple, but powerful. So the purpose of factoring is to find expressions that, when simplified, equal the equation you are trying to factor. So, for example, $x^2 - 8x + 12 = 0$ factors out neatly to $(x-6)(x-2)=0$ which, since this is equal to zero, so we can pull out the ZPP and get $x=6$ or $x=2$.

Now, for a nice method to make this easier (as opposed to plug-and-chug). A good way to do it is saying, okay, $a\cdot c$ is equal to whatever and $b$ is equal to whatever. Then, you find two numbers that multiply to $a\cdot c$ and add to $b$. For example, taking our earlier equation, $x^2-8x+12=0$, we see that $a$ is one, so our number has to multiply to 12 and add to -8 (don't forget the negative signs!) and so we can write out the factors of 12, which are 1, 2, 3, 4, 6, and 12. Now, we can change the sign on these numbers (aka, we can make them -1 or 1, for instance) so keep that in mind. Which pair adds to 8? Well, 12-1=11 and 12+1=13, so that's out. -6+-2=-8...oh, perfect.

Then, you say, okay, this is really equal to $x^2 -6x -2x+12=0$. Then, we put parentheses around it: $(x^2-6x)+(-2x+12)=0$. Then, we factor out the largest common factor from each: $x(x-6)+2(x-6)=0$. Once you are finished factoring you should get the same expression in both sets of parentheses. If not, you have done something wrong. Then, you can say $(x-2)(x-6)=0$. From here, we're home free, and we can solve using the ZPP (see the very first example in this section).

Completing the Square

Okay, completing the square is another method to solve a quadratic. First, let's assume you've already set your equation up so that it is directly equal to $0$. Some quadratics are a bit easier to solve by factoring than others. Take $x^2+6x+9=0$, for instance. You can factor this and get $(x+3)^2=0$, and then take the square root (nothing happens to the zero) and notice that $x=-3$. These types of simple equations are called perfect squares.

A whole method has based off of these wonderfully simple equations. Take, for example, the perfectly hideous equation $x^2 +6x -16=0$. We can actually do something really cool here. Let's move the 16 over to the other side (no, don't look at me weird yet, hold on) to get $x^2+6x=16$. Now, let's say we want to make this a perfect square. To get what number in the place of $c$ will make it a perfect square, simply do $(b/2)^2$. In this case, we get 9. So, add 9 to both sides, getting $x^2+6x+9=25$. Then, we know this reduces to $(x+3)^2=25$. How to do that simply? Take $x$ plus $b/2$ and then get $(x+\frac{b}{2})^2$. Square root both sides, and you get $x+3=\pm 5$. Then, remember the way we did this on the quadratic formula, we can just calculate, getting $x=2$ or $x=-8$. Now obviously not all of them turn out quite this nice, but it is another handy method for the quadratic toolbelt.

The reason I went through all that is so I could explain where the quadratic formula comes from. Remember that wonderful standard form, $ax^2+bx+c=0$? Well, if you complete the square on that, you get the quadratic formula. This is not that bad. So, here we go:

$$ax^2+bx+c=0$$ $$-c=ax^2+b$$ $$\frac{-c}{a}=x^2+\frac{b}{a}x$$ Side note: $\frac{b}{a}$ divided by 2 is $\frac{b}{2a}$, that squared is $\frac{b^2}{4a^2}$. Carrying on... $$\frac{b^2}{4a^2}+\frac{-c}{a}=x^2+\frac{b}{a}+\frac{b^2}{4a^2}$$ Another side note: To simplify further, we need to give the two fractions on the left side of the equation a common denominator, so $\frac{-c}{a}$ is multipled by $\frac{4a}{4a}$ to give $\frac{b^2-4ac}{4a^2}$ (once the two fractions are added). $$\frac{b^2-4ac}{4a^2}=x^2+\frac{b}{a}+\frac{b^2}{4a^2}$$ Complete the square here $$\frac{b^2-4ac}{4a^2}= (x+\frac{b}{2a})^2$$ Square root both sides $$\sqrt{\frac{b^2-4ac}{4a^2}}= \sqrt{(x+\frac{b}{2a})^2}$$ $$\frac{\pm \sqrt{b^2-4ac}}{2a}=x+\frac{b}{2a}$$ $$\frac{-b \pm \sqrt{b^2-4ac}}{2a}=x$$

## Coding

Now, for the coding solution. I used python:

import math

a = 1
b = 3
c = 2

if (b*b >= 4*a*c):
print "There is a solution!"
d = math.sqrt((b*b)-(4*a*c))
solution1 = (-b-math.sqrt(d))/(2*a)
solution2 = (-b+math.sqrt(d))/(2*a)
if (solution1 != solution2):
print (solution1,solution2)
else:
print solution1
else:
print "No solutions, imaginary number"



To plug in the numbers you want, you change a, b, and c (remember the standard equation). The way it works is this. First, there is a function defined that takes in variables a, b, and c. Then, it checks to make sure that the numbers under the square root don't come out negative (if they did, the solution would be an imaginary number). If it passes that, then it literally calculates using the variables, if it doesn't, it tells you so. The other if statement checks to make sure solution 1 and solution 2 aren't equal before printing them both; that's handy on perfect squares.

Hope this helps! Let me know if you have any questions about deriving the quadratic formula, or one of the methods, or anything like that. Finally, one last tip: I had algebra I last year, and the quadratic formula is really important to memorize. Try singing it to the tune of Pop Goes the Weasel; I promise you, you'll have it stuck in your head forever. =)

There are several different techniques to solve this particular equation, which is called a quadratic equation. Here are two methods that you will learn in Algebra 1.

Method 1: Factoring

The equation $$x^2=3x+4$$ can be rewritten as $$x^2 -3x -4=0$$ Now the goal is to factor the left-hand side of the equation -- that is, to write it in the form $$(x + \textrm{something})(x + \textrm{something else}) = 0$$ The "something" and "something else" are to be two numbers whose product is $-4$ and whose sum is $-3$. Since the product is negative, one of the numbers must be positive and the other one is negative. After a little playing around, we find that $$(x+1)(x-4)=0$$ works. (To check this, multiply each term in the first pair of parentheses times each term in the second pair of parentheses, getting four terms; be careful with negative signs, and combine like terms.)

Finally, we use the zero-product property of the real numbers: if the product of two quantities is zero, one of the two quantities must be zero. In this case, the product of $x+1$ and $x-4$ is zero, so either $x+1=0$ (in which case $x=-1$) or $x-4=0$ (in which case $x=4$). We conclude that there are two solutions to the equation: $x=-1$ or $x=4$. You can check that both of these work in the original equation.

Method 2: Completing the square

Rewrite the equation as $$x^2 - 3x = 4$$ Now, look at the coefficient of the $x$ term, divide it by $2$, and square the result. Add this to both sides of the equation. In our case, the coefficient of the $x$ term is $-3$, half of which is $-3/2$, and the square of that is $9/4$, so we add $9/4$ to both sides of the equation: $$x^2 - 3x + \frac{9}{4} = 4 + \frac{9}{4} = \frac{25}{4}$$

Now, why did we do this? We did this because the left-hand side of the equation can now be recognized as the square of $(x - \frac{3}{2})$. That is, we have $$\left(x-\frac{3}{2}\right)^2 = \frac{25}{4}$$ Taking the square root of both sides, we end up with $$x - \frac{3}{2} = \pm \frac{5}{2}$$ so $$x = \frac{3}{2} \pm \frac{5}{2}$$ Reading this equation with the plus sign, we have $x = 8/2 = 4$; reading it with the minus sign, we have $x = -2/2 = -1$.

The standard method is to multiply everything by $4$ and transfer the $x$ term on the left-hand side: $$4x^2-12x=16$$ Now recall $(a+b)^2=a^2+2ab+b^2$ and observe that we can take $a=2x$, so from $2ab=-12x$ we obtain $4bx=-12x$, that's satisfied for $b=-3$. We need the $b^2$ term, so we add it on both sides: $$4x^2-12x+9=16+9$$ The left-hand side can be rewritten $(2x-3)^2$, so we are reduced to $$(2x-3)^2=25$$ that gives us $$2x-3=5\qquad\text{or}\qquad 2x-3=-5$$

A different strategy is to set $x=t+a$ and try to determine $a$ in such a way that some term vanishes: $$t^2+2at+a^2=3t+3a+4$$ If we set $2a=3$, the $t$-term disappears: $$t^2+\frac{9}{4}=\frac{9}{2}+4$$ and so $$t^2=\frac{25}{4}$$ and therefore $t=5/2$ or $t=-5/2$. Thus $$x=\frac{5}{2}+\frac{3}{2} \qquad\text{or}\qquad x=-\frac{5}{2}+\frac{3}{2}$$

You'll learn the “quadratic formula” that can be obtained in the same way as the first method above: if $ax^2+bx+c=0$, then $$x=\frac{-b+\sqrt{b^2-4ac}}{2a} \qquad\text{or}\qquad x=\frac{-b-\sqrt{b^2-4ac}}{2a}$$ provided $b^2-4ac\ge0$. In your case $a=1$, $b=-3$ and $c=-4$.

What you need to get rid of is the term proportional to $x$. How to do this can be seen by looking at the binomial formula $$(x+c)^2 = x^2 + 2cx + c^2$$ You see, on the left hand side there's a pure square, while on the right hand side, there's a term having an $x$. So what you need to figure out is the correct $c$ to use.

Have you learned the distributive law of multplication yet

$3(4+3) = 3\cdot 4 + 3 \cdot3$ If we had an $x$ in there instead of a 4...

$3(x+3) = 3x + 3 \cdot3$

Lets take this up one more degree of difficulty.

$(x+1)(x+3) = (x+1)x + (x+3)3 = x^2 +x + 3x + 9 = x^2 + 4x + 9$

We have to do the same thing in reverse. And, it takes some guesswork and intuition.

$x^2 - 3x - 4 = 0$

We want to find factors $(x+a)(x+b) = 0$ for this such that $ab = -4$ and $a+b = -3$

If the solutions are rational (and they are not always) then $a,b$ need to be factors of $4$ that gives us $4,1$ and $2,2$ to work with, and it turns out one of them works

$x^2 - 3x - 4 = (x-4)(x+1)= 0$

Now, if $(x-4)(x+1)= 0$ then

If $(x-4) = 0$ or if $(x+1)= 0$ then the whole thing equals 0.

$x = 4$ or $x = -1$