You are on page 1of 25

Solving

Equations
A quadratic equation is an equation equivalent to one of the form

Where a, b, and c are real numbers and a = 0
0
2
= + + c bx ax
To solve a quadratic equation we get it in the form above
and see if it will factor.
6 5
2
= x x
Get form above by subtracting 5x and
adding 6 to both sides to get 0 on right side.
-5x + 6 -5x + 6
0 6 5
2
= + x x
Factor.
( )( ) 0 2 3 = x x
Use the Null Factor law and set each
factor = 0 and solve.
0 2 or 0 3 = = x x 3 = x 2 = x
So if we have an equation in x and the highest power is 2, it is quadratic.
In this form we could have the case where b = 0.
0
2
= + + c bx ax
Remember standard form for a quadratic equation is:
0
2
= +c ax
0 0
2
= + + c x ax
When this is the case, we get the x
2
alone and then square
root both sides.
0 6 2
2
= x
Get x
2
alone by adding 6 to both sides and then
dividing both sides by 2
+ 6 + 6
6 2
2
= x
2 2
3
2
= x
Now take the square root of both
sides remembering that you must
consider both the positive and
negative root.

3 = x
Let's
check:
( ) 0 6 3 2
2
=
( ) 0 6 3 2
2
=
0 6 6 = 0 6 6 =
Now take the square root of both
sides remembering that you must
consider both the positive and
negative root.
0
2
= + + c bx ax
What if in standard form, c = 0?
0 0
2
= + +bx ax
We could factor by pulling
an x out of each term.
0 3 2
2
= x x Factor out the common x
( ) 0 3 2 = x x
Use the Null Factor law and set each
factor = 0 and solve.
0 3 2 or 0 = = x x
2
3
or 0 = = x x
If you put either of these values in for x
in the original equation you can see it
makes a true statement.
0
2
= + + c bx ax
What are we going to do if we have non-zero values for
a, b and c but can't factor the left hand side?
0 3 6
2
= + + x x
This will not factor so we will complete the
square and apply the square root method.
First get the constant term on the other side by
subtracting 3 from both sides.
3 6
2
= + x x
___ 3 ___ 6
2
+ = + + x x
We are now going to add a number to the left side so it will factor
into a perfect square. This means that it will factor into two
identical factors. If we add a number to one side of the equation,
we need to add it to the other to keep the equation true.
Let's add 9. Right now we'll see that it works and then we'll look at how
to find it.
9 9
6 9 6
2
= + + x x
6 9 6
2
= + + x x
Now factor the left hand side.
( )( ) 6 3 3 = + + x x
two identical factors
( ) 6 3
2
= + x
This can be written as:
Now we'll get rid of the square by
square rooting both sides.
( ) 6 3
2
= + x
Remember you need both the
positive and negative root!

6 3 = + x
Subtract 3 from both sides to get x alone.
6 3 = x
These are the answers in exact form. We
can put them in a calculator to get two
approximate answers.
55 . 0 6 3 ~ + = x 45 . 5 6 3 ~ = x
Okay---so this works to solve the equation but how did we
know to add 9 to both sides?
___ 3 ___ 6
2
+ = + + x x 9 9
( )( ) 6 3 3 = + + x x
We wanted the left hand side to factor
into two identical factors.
When you FOIL, the outer terms and the
inner terms need to be identical and need
to add up to 6x.
+3 x
+3x
6 x
The last term in the original trinomial will then be the middle
term's coefficient divided by 2 and squared since last term
times last term will be (3)(3) or 3
2
.
So to complete the square, the number to add to both sides
is

the middle term's coefficient divided by 2 and squared

By completing the square on a general quadratic equation in
standard form we come up with what is called the quadratic formula.
(Remember the song!! )
a
ac b b
x
2
4
2

=
This formula can be used to solve any quadratic equation
whether it factors or not. If it factors, it is generally easier to
factor---but this formula would give you the solutions as well.
We solved this by completing the square
but let's solve it using the quadratic formula
a
ac b b
x
2
4
2

=
1
(1)
(1)
6
6
(3)
2
12 36 6
=
Don't make a mistake with order of operations!
Let's do the power and the multiplying first.
0
2
= + + c bx ax
0 3 6
2
= + + x x
2
12 36 6
= x
2
24 6
=
6 2 6 4 24 = =
2
6 2 6
=
( )
2
6 3 2
=
There's a 2 in common in
the terms of the numerator
6 3 =
These are the solutions we
got when we completed the
square on this problem.
NOTE: When using this formula if you've simplified under the
radical and end up with a negative, there are no real solutions.
(There are complex (imaginary) solutions, but that will be dealt
with in year 12 Calculus).
SUMMARY OF SOLVING QUADRATIC EQUATIONS
Get the equation in standard form: 0
2
= + + c bx ax
If there is no middle term (b = 0) then get the x
2
alone and square
root both sides (if you get a negative under the square root there are
no real solutions).
If there is no constant term (c = 0) then factor out the common x
and use the null factor law to solve (set each factor = 0).
If a, b and c are non-zero, see if you can factor and use the null
factor law to solve.
If it doesn't factor or is hard to factor, use the quadratic formula
to solve (if you get a negative under the square root there are no real
solutions).
a
ac b b
x c bx ax
2
4
0
2
2

= = + +
If we have a quadratic equation and are considering solutions
from the real number system, using the quadratic formula, one of
three things can happen.
3. The "stuff" under the square root can be negative and we'd get
no real solutions.
The "stuff" under the square root is called the discriminant.
This "discriminates" or tells us what type of solutions we'll have.
1. The "stuff" under the square root can be positive and we'd get
two unequal real solutions
0 4 if
2
> ac b
2. The "stuff" under the square root can be zero and we'd get one
solution (called a repeated or double root because it would factor
into two equal factors, each giving us the same solution).
0 4 if
2
= ac b
0 4 if
2
< ac b
The Discriminant
ac b 4
2
= A
13
5-2 Two-Way Selection

The decision is described to the computer as a
conditional statement that can be answered either true
or false. If the answer is true, one or more action
statements are executed. If the answer is false, then a
different action or set of actions is executed.
ifelse and Null else Statement
Nested if Statements and Dangling else Problem
Simplifying if Statements
Conditional Expressions
Topics discussed in this section:
Computer Science: A
Structured
Programming Approach
Using C
14
FIGURE 5-6 Two-way Decision Logic
Computer Science: A
Structured
Programming Approach
Using C
15
FIGURE 5-7 if...else Logic Flow
Computer Science: A
Structured
Programming Approach
Using C
16
Table 5-2 Syntactical Rules for ifelse Statements
Computer Science: A
Structured
Programming Approach
Using C
17
FIGURE 5-8 A Simple if...else Statement
Computer Science: A
Structured
Programming Approach
Using C
18
FIGURE 5-9 Compound Statements in an if...else
19
5-3 Multiway Selection

In addition to two-way selection, most programming
languages provide another selection concept known as
multiway selection. Multiway selection chooses among
several alternatives. C has two different ways to
implement multiway selection: the switch statement and
else-if construct.
The switch Statement
The else-if
Topics discussed in this section:
Computer Science: A
Structured
Programming Approach
Using C
20
FIGURE 5-19 switch Decision Logic
Computer Science: A
Structured
Programming Approach
Using C
21
FIGURE 5-24 The else-if Logic Design for Program 5-9
Computer Science: A
Structured
Programming Approach
Using C
22
The else-if is an artificial C construct that is only used when
1. The selection variable is not an integral, and
2. The same variable is being tested in the expressions.
Note
General Syntax of else-if
construct

if (expression-1)
statement-1;
else if (expression-2)
statement-2;
..
..
else
statement-n;

















#include<stdio.h>
#include<conio.h>
#include<math.h>
#include<process.h>
void main()
{
float a,b,c,x1,x2,disc;
clrscr();
printf("Enter the co-efficients\n");
scanf("%f%f%f",&a,&b,&c);
if(a==0)
{
printf( equation is not quadratic \n);
exit(0);
}
disc=b*b-4*a*c;/*to find discriminant*/
if(disc>0) /*distinct roots*/
{
x1=(-b+sqrt(disc))/(2*a);
x2=(-b-sqrt(disc))/(2*a);
printf("The roots are distinct\n");

}













else
{
x1=-b/(2*a);/*complex roots*/
x2=sqrt(fabs(disc))/(2*a);
printf("The roots are complex\n");
printf("The first root=%f+i%f\n",x1,x2);
printf("The second root=%f-i%f\n",x1,x2);
getch();
}

} /* end of main function */



















else if(disc==0)/*Equal roots*/
{
x1=x2=-b/(2*a);
printf("The roots are equal\n");
printf("x1=%f\nx2=%f\n",x1,x2);
}

You might also like