Introduction to Mathematical Software

M21-126, Spring 1999
Professor Walkington

Lesson 14

Simplification, Exponentials and Trigs

Simplification

Frequently we will end up with an expression that we want to "simplify". Normally this means that its too long to read and we want a shorter version. This is the approach taken by Simplify[]; it tries a few things and returns the shortest answer it found.

Simplify[x^2 + 4 x + 4]

Here the factored form was "simplist"; in other cases it may not be

Simplify[x^2 + 4 x + 3]

Factor[%]

Consider the following example

Simplify[ Sqrt[x^2] ]

Mathematica knows that simplifing this to x may be wrong, since the answer may also be -x. Frequently you will know that x > 0, so only care about the positive answer. In this situation PowerExpand[] can be used.

PowerExpand[ Sqrt[x^2] ]

A simlar problem exists with expressins like Sqrt[ab]. If a < 0 and b < 0 we shouldn't write this as Sqrt[a] Sqrt[b], and Simplify[] doesn't.

Simplify[ Sqrt[a b] ]

PowerExpand[ Sqrt[a b] ]

In general, PowerExpand[] will formally expand powers (think of Sqrt[x] as x^(1/2)) in a formal fashion. Most of the time this is what you want, but be think before you use it. (Actually, I simply use it, and if it simplifies things greatly I then think.)

Students taking calculus will learn about logarithms, and PowerExpand[] will also expand these too.

PowerExpand[ Log[a b] ]

The problem of finding the "simplist" (e.g. shortest) form of an expression is an impossible task. To illustrate this, consider the following expression.

f = 1 + 9 x + 45 x^2 + 120 x^3 + 210 x^4 + 252 x^5 + 
				210 x^6 + 120 x^7 + 45 x^8 + 10 x^9 + x^10

Simplify[f]

You probably haven't guessed that a very sort form can be found by writing adding and subtracting x to this expression.

Factor[f + x] - x

Trigonometry

Mathematica has all of the standard trigonometric functions available. Recall that Mathematica's default mode of operation is to do exact arithmetic, so Mathematica will only give exact values for a few arguments to the trig functions.

Sin[Pi / 4]

Sin[Pi / 12]

ArcCos[ Sqrt[3] / 2 ]

To get numerical values you can always use N[]

Tan[ 2 ]
Tan[ 2 ] // N

The trig functions also know about themselves, so compositions of functions can sometimes be evaluated. Consider for example, a 3-4-5 triangle:

Cos[ ArcTan[3/4] ]

The Simplify[] command knows many of the standard trionometric identities and will use them to simplify expressions.

Simplify[ Sin[x]^2 + Cos[x]^2 ]

Simplify[ Sin[2 x] / Sin[x] ]

This last simplification involved writing sin(2x) as 2 sin(x) cos(x). Note however, that Simplify[] doesn't necessarily write such trig functions as products since the result may not be "simpler" when expanded.

Simplify[ Sin[2 x] ]

The commands Factor[] and Expand[] with the Trig option set to True are used to control how trig expressions are written. In general, Factor[] will write a trig expression as many products (2 sin(x) cos(x) instead of sin(2x)), and Expand[] eliminates products and powers of trig expressions.

Factor[Sin[2 x]]
Factor[Sin[2 x], Trig-> True]

Expand[Sin[x]^2 + Cos[2 x]^2 - 1]
Expand[Sin[x]^2 + Cos[2 x]^2 - 1, Trig->True]

Factor[] and Expand[] are'nt inverses, and often it's very difficult to get symbolic packages to write such expressions in "exactly the way you want".

Factor[%, Trig->True]

Solve[] will attempt to find the solution of equations involving trigonomentric quantities. Frequently an infinite number of solutions exist, and on a good day Mathematica will find one of them.

Solve[Sin[x] == 1/2,x]

Mathematica at least warned us that "some" solutions may not be found which is somewhat of an understatement.

Solve[] is essentally designed to solve polynomial type equations, so it doesn't take much to tangle it up.

Solve[3 Cos[x] + 4 Sin[x] == 2, x]

Of course to solve this equation we simply want to write the left hand side as r cos(x-phi) for sutiable vaules of r and phi to get a solution of x = phi + arccos(2/r) (for this example r = 5 and phi = arctan(-4/3)).

Exercises

1) Show that

(Cos[x+y]^2 - Cos[x-y]^2) / (Cos[x+y]^2 + Cos[x-y]^2)

is equal to

-2 Cos[x] Cos[y] Sin[x] Sin[y] / 
				(Cos[x]^2 Cos[y]^2 + Sin[x]^2 Sin[y]^2)

2) The following quantity is equal to 5 + Sqrt[15]

e = (13 Sqrt[15] + 45) / (2 Sqrt[15] + 3)

First, show that the two are equal, and then find the Mathematica commands to transform e to the simplified result.