Source Code

AFACTOR.8xp

FACTOR.8xp

By Ben Fisher, 2003

**Explanation:**

A trinomial is an expression, such as

x2 + 7x + 12

Trinomials can be broken up into two binomials, ideally with integers, although this is not always possible.

x2 + 7x + 12 = (x+3)(x+4)

The form with two binomials is more useful for solving or graphing. The goal of the program will be to break up this expression

**Program:**

I'll give each of the coefficients a variable.

Trinomial -- Ax2+ Bx + C

Binomials -- (Dx+E)(Fx+G)

Of course, the goal now will be to find a way to find D,E,F, and G if A,B,and
C are known.

First, I notice that when the binomials are expanded,

D*F = A

E*G= C

(D*G) + (E*F) = B

From here there is no easy way to solve for D,E,F, and G. But we know that D and F are integer factors of A, and E and G are integer factors of C. A very simple, yet slow way to solve the problem is to test every pair of factors of A and C.

*Step 1:*

Create a list of factors of A and C. For example, if A were 45, the program
would return 1,3,5,9,15,45. Even though the last half of the numbers are redundant,
they are necessary to the program because

(Dx+E)(Fx+G) is not
the same as (Gx+E)(Fx+D)

*Step 2:*

Repeat the loop for every item in the list of factors of A. Put the next factor
in the list into the variable D and put A/D into F (It is shown above that A/D
equals F).

Now repeat another loop for every item in the list of factors of C. Put the
next factor in the list into the variable E and put C/E into G.

By trying the possibilites, if there is a way to factor, it will be found. Otherwise we can still solve using the quadratic formula but that is not as pretty.

Back