The Museum of HP Calculators

HP Forum Archive 18

[ Return to Index | Top of Index ]

[OT] (Cos x)^x
Message #1 Posted by Chuck on 30 Nov 2007, 4:11 p.m.

Getting my students ready for their calculus Final I had them differentiate y = (cos x)^x to find the slope when x=0. We then graphed the original function and analyzed all its behaviors (though not using calculus). Most calculators and computers had a difficult time producing an adequate graph of this. A good little exercise with a few suprises.

      
Re: [OT] (Cos x)^x
Message #2 Posted by Karl Schneider on 1 Dec 2007, 12:47 a.m.,
in response to message #1 by Chuck

Hi, Chuck --

This isn't really OT.

I believe that you'd posted earlier this year about other math functions/calculations such as i^i.

(cos x)x produces no real-valued result for non-integer values of x that give negative cosines (if I stated that right), which may account for the difficulty in computer plotting. I should try that on Matlab for practice; I haven't used it in a long while.

For those who are interested, the derivative is

(cos x)x [ln(cos x) - x tan x]

(Very minor programming "challenge": Calculate the derivative function assuming a stack loaded with x (as with SOLVE or INTEG), without executing "cos x" twice and without using a storage register.)

-- KS

Edited: 1 Dec 2007, 4:00 p.m. after one or more responses were posted

            
Re: [OT] (Cos x)^x
Message #3 Posted by Chuck on 1 Dec 2007, 8:54 a.m.,
in response to message #2 by Karl Schneider

Hi Karl. It's actually defined when negative, as long as the values aren't complex. Also, it resembles secant for x<0. The spikes and "U"'s get narrower for large x's. Crazy function. Here's what I get with Mathematica.

CHUCK

Edited: 1 Dec 2007, 10:08 a.m.

                  
Re: (Cos x)^x plot
Message #4 Posted by Karl Schneider on 1 Dec 2007, 2:19 p.m.,
in response to message #3 by Chuck

Hi, Chuck --

Thank you for the plot, which would be laborious to produce using an HP-15C and graph paper...

Quote:
It's actually defined when negative, as long as the values aren't complex.

The function is defined continuously in the real domain for positive or negative x as long as "cos x" is positive. If "cos x" is negative, then only integer values of x can produce a real-valued result.

Quote:
Also, it resembles secant for x<0.

Since cosine is "even", [cos x = cos(-x)], for negative x we can write

(cos x)x = 1 / [(cos |x|)|x|

Of course, sec x = 1 / cos x.

Quote:
The spikes and "U"'s get narrower for large x's.

As expected, since larger exponents "reduce" smaller arguments. That is, xa < x for x < 1 and a > 1.

I understand the solid lines of the plot, where the function has a real-valued result, but the dotted parts (e.g., between pi/2 < x < 3*pi/2) don't seem to represent Re[f(x)].

-- KS

Edited: 1 Dec 2007, 3:35 p.m.

                        
Re: (Cos x)^x plot
Message #5 Posted by Chuck on 1 Dec 2007, 8:45 p.m.,
in response to message #4 by Karl Schneider

The places where (Cos x)^x is negative is where the interesting pieces are. For my mathematica plot, I used a step size of 1/35 to "see" those parts. Depending on the numerator, the results will be either positive or negative (skipping over all of the complex results. For example

F(71/35) = -0.190819

F(72/35) = 0.209171

and since 71/35 < 2.04 < 72/35

F(2.04) = .1965 + .0248i

Wherever F(X) is negative, the function will be everywhere discontinuous (however, infinite positive values, infinite negative, and infinite complex.)

If you graph the function on the TI-84 and use "Zoom Decimal" you can get a fairly decent graph of this behavior.

CHUCK

Edited: 1 Dec 2007, 8:47 p.m.

                              
Re: (Cos x)^x plot
Message #6 Posted by Karl Schneider on 2 Dec 2007, 3:23 a.m.,
in response to message #5 by Chuck

Chuck --

I'm beginning to understand the discontinuous portion of the plots.

Quote:
The places where (Cos x)^x is negative is where the interesting pieces are.

The only negative real-valued results, it seems to me, are those for which (cos x) is negative, and x is an odd integer. E.g.,
f(3) = -0.970277.

The two data points you listed (71/35 and 72/35) have only complex-valued function results. The magntitudes of those complex-valued solutions are equal to the values you listed. I'm not sure what determines why f(71/35) would be negative.

-- KS

Edited: 2 Dec 2007, 5:08 p.m.

                        
Re: (Cos x)^x plot
Message #7 Posted by Stefan K. on 3 Dec 2007, 1:39 p.m.,
in response to message #4 by Karl Schneider

Quote:
The function is defined continuously in the real domain for positive or negative x as long as "cos x" is positive. If "cos x" is negative, then only integer values of x can produce a real-valued result.

Not only for real values, a^(-p/q)=1/a^(p/q) has also a real value for negative a (and integer p and q). Depending on odd or even p, the result is negative or positive. And since rational numbers are dense in the real space (and there are infinitely many of them in every interval), you see two branches whereever (cos q) is negative. Since computers don't know real real numbers...

Stefan

                              
Re: (Cos x)^x plot
Message #8 Posted by Karl Schneider on 4 Dec 2007, 12:13 a.m.,
in response to message #7 by Stefan K.

Aha! Thank you, Stefan, for clearing that up. Yes, I should have evaluated the powers (71, 72) and root (35) separately, using the HP-32SII for example. I wasn't seeing the true point of the rational input arguments, believing it to be just discretization for plotting. Also, I trust the HP-15C and HP-42S best for calculations involving complex numbers -- accuracy, completeness, and rigor. However, they don't have the root function.

Still, the function is not strictly continuous for arguments producing negative (cos x), as not all numbers are rational.

-- KS

                                    
Re: (Cos x)^x plot
Message #9 Posted by Stefan K. on 4 Dec 2007, 3:51 a.m.,
in response to message #8 by Karl Schneider

Quote:
Still, the function is not strictly continuous for arguments producing negative (cos x), as not all numbers are rational.

Yes, I think you can't get more discontinuous. In every (however small) interval, you have infinitely (but still countable) many jumps, and in between are uncountable many points with no (real) function value at all.

Stefan

                  
Re: [OT] (Cos x)^x
Message #10 Posted by Egan Ford on 12 Dec 2007, 4:50 p.m.,
in response to message #3 by Chuck

Chuck,

What exactly did you tell Mathematica to get that plot?

I have been unable to get Gnuplot, Sage, or the 50g to get the same results. All produce a plot of just the continuous real parts.

If I change the function to (cos(x)^(x*35))^(1/35) and use a loop from -10 to 10 step 1/35 as you suggest I get the same plot as above but only for y > 0.

The principal root of cos(even/35)^even)^1/35 is real, but the principal root of cos(odd/35)^odd)^1/35 is complex. This explains my plot, but not yours.

To add to my confusion the 50g returns a real root for even or odd, yet does not produce the same plot. I find it interesting that the 50g returns -.19081 (a real) for (cos(71/35)^71)^(1/35), yet a complex for (-8)^(1/3). The principal root for cos(71/35)^71)^(1/35) should be 0.1901+ 0.0171i.

I understand why the 83+ was able to plot it, it only returns real roots.

Edited: 12 Dec 2007, 4:52 p.m.

      
Re: [OT] (Cos x)^x
Message #11 Posted by Nenad (Croatia) on 1 Dec 2007, 4:17 a.m.,
in response to message #1 by Chuck

As far as I remember:

(COS x)^x=EXP(x LN COS x)

In a more general case: a^x=EXP(x LN a)

usually showed to be a useful transformation.

            
Re: [OT] (Cos x)^x
Message #12 Posted by Karl Schneider on 1 Dec 2007, 1:48 p.m.,
in response to message #11 by Nenad (Croatia)

Quote:
(COS x)^x=EXP(x LN COS x)

Indeed, that's the first step in finding the derivative. Then, the "chain rule" and derivative of a product function.

-- KS


[ Return to Index | Top of Index ]

Go back to the main exhibit hall