• Aucun résultat trouvé

Understanding Complex Output

Dans le document This page intentionally left blank (Page 176-181)

Graphics Primitives

2. Factor the following expressions and explain the differences in the resulting factorizations

4.4 Understanding Complex Output

You’ve noticed by now that complex numbers sometimes appear in Mathematica’s output. They can pop up in a variety of places, even when you don’t expect them. In Section 3.2 on page 57, for instance, we saw that Mathematica regards the cube root of a negative number as a complex number.

In[1]:= +8/1s3ssN

Out[1]= 1.1.73205Ç

In high school and early college courses it is more common to work with the real-valued cube root function, which would return the value 2 (instead of the complex number above) as the cube root of 8. Here are a few other instances where complex numbers can pop up in the context of a real computation:

In[2]:= Log#2'

Out[2]= Ç S Log#2'

In[3]:= ArcSin#2.'

Now this sort of output ought to make you hungry to learn about the complex numbers. If you are even a bit curious, ask your instructor about them. And even if you are not particularly interested in such matters be mindful that you are now using a grown-up software package, so you are going to have to deal with them from time to time. Let’s deal with the inputs above individually. We’ll discuss the cube root function at length later in this section. The next two inputs simply extend the domains of the logarithm and inverse sine functions beyond what we ordinarily allow. Doing so results in complex output. In a precalculus or calculus course, the likelihood of encountering com-plex numbers in this way is small. The next outputs, however, will be more difficult to avoid. We have already seen instances in which Solve and NSolve will find complex solutions to equations, even when every quantity appearing in those equations is real. Whereas Solve and NSolve are designed to always report complex solutions when they exist, the command Reduce allows one to specify that only real values are to be considered. Simply set the optional third argument of Reduce to Reals. If there are no real solutions, it will return False.

In[6]:= Reduce$Æxm 2, x, Reals(

Out[6]= False

In[7]:= Reduce#Sin#x'm2, x, Reals'

Out[7]= False

4.4 Understanding Complex Output 163

In[8]:= Reduce$x2m 4, x, Reals(

The lesson here is that if you are interested only in real solutions to equations, using Reduce with Reals as its third argument is a good strategy.

Another subtle issue that can arise from time to time is illustrated below:

In[11]:= Reduce$x315x2 0, x, Reals, Cubics‘True(

Here we have asked only for real roots, and yet Reduce has returned three expressions involving Ç.

The output is correct; each of these numbers is indeed a real number (one could verify this with a plot of this cubic—its graph crosses the x-axis three times). But just as one can write the real number 1 as Ç2, it is possible to express other real numbers in a manner that makes use of the complex number Ç. That’s what has happened here. In some cases it is possible to algebraically manipulate such numbers so that all the Ç’s go away. The command that can accomplish this is calledComplexg Expand. It will attempt to break a knotty complex number into its real and imaginary components.

In this case, the imaginary part of each of the numbers above should be exactly zero. One could apply simply append //ComplexExpand to the previous input, but we will apply it just to the first root reported above to make the output easier to read:

In[12]:= ComplexExpand% 5 better be the case that b 0. Now your first impression upon seeing intricate output like this may be to both marvel at what Mathematica can do, and simultaneously to glaze over and fail to examine the output critically. Pause for a moment to take a good look at it, and focus your attention on the imaginary component b. You will find that b is indeed zero. It is of the form 5sin+c/ 5sin+c/, and since sin+c/ sin+c/, the entire quantity is zero. In the next section the Simplify command will be discussed. It can be invoked to carry out this simplification as well:

In[13]:= Simplify% 5 Sin%1

3 S ArcTan%2 31 ) ) 5 Sin%1

3 S ArcTan%2 31 ) ))

Out[13]= 0

Note also that the opposite issue can arise—certain non-real complex numbers may be expressed using only real numbers. At first glance they don’t betray their complexity:

In[14]:= Reduce$x3m1, x(

Out[14]= xm1««xm +1/1s3««xm+1/2s3

Again, ComplexExpand is the ticket for putting a complex number into standard form:

In[15]:= ssComplexExpand

We have already noted that there are different definitions of the cube root function. In precalculus and calculus courses, where the complex number system is not utilized, one defines the cube root of any real number to be its real cube root. So, for instance, +8/1s3 2. Mathematica uses a different definition, which we will discuss in this section. Under this definition +8/1s3 1 Ç 3.

4.4 Understanding Complex Output 165

In[16]:= ComplexExpand$+8/1s3(

Out[16]= 1 Ç 3

The reality is that when complex numbers are taken into account, there are three numbers whose cube is 8:

In[17]:= Reduce$x3m 8, x(

Out[17]= xm 2««xm1 Ç 3 ««xm1 Ç 3

So in defining the cube root, one of these three must be chosen. Mathematica chooses the last of these. Note that the underlying command used to raise a number to a power is called Power:

In[18]:= xpssFullForm

Out[18]//FullForm=

Power$x, p(

It is the definition of this basic arithmetic operation that is at issue. When a negative number is raised to a rational power, and the denominator of that rational power is an odd number (e.g., 3, for the rational power 1s3), you might like to have a power expression evaluate to a real number, as would be expected in a a precalculus or calculus course. In Section 3.2 on page 58 an alternate power command called realPower was defined that can be used to emulate the real-valued power func-tions commonly encountered in such a course.

We now discuss a topic that falls outside of the standard precalculus and calculus curricula: why on earth does Mathematica report that +8/1s3 1 3Ç when it would be so much simpler to say that the cube root of 8 is just 2? What possible reason could there be for such insanity? This will take a bit of careful thought, and a page or two of explanation, so make yourself comfortable before reading on. We’ll see that there is indeed a compelling reason.

Let’s suppose, for the sake of argument, that the cube root of 8 is 2. What consequences follow?

Well, raising any negative real number to the power 1s3 would, in a similar manner, produce a negative real number. In fact, raising any negative real number to the power 1sn, where n is an odd positive integer, would produce a negative real number. Now suppose we raise this result to the mth power, where m is a positive integer; that is, our original negative number is raised to the rational power msn. If m is odd the result is another negative number, while if m is even the result is a posi-tive number (since squaring a negaposi-tive number results in a posiposi-tive number). To summarize: raising a negative number to a positive rational power with odd denominator produces a real number. This number is negative or positive according to the parity (odd or even) of the numerator. So far so good, but there’s a problem.

Just as the exponential function g+x/ 2x is continuous, in a just world we would also expect the function f+x/ +2/x to be continuous. What happens when x is a rational number with odd denomi-nator? Are we to accept a state of affairs in which +2/311s99 is a negative real number, but +2/312s99 is

a positive real number? The two exponents are very close to each other, yet they are producing values that are not close to each other (you can check this). Furthermore, noting that 311

99 S 31299,

Dans le document This page intentionally left blank (Page 176-181)