Quantcast
Viewing all articles
Browse latest Browse all 589

Rationality, and MS Excel (and other calculators)

(This article was first published on Freakonometrics » R-english, and kindly contributed to R-bloggers)

This morning, Mathieu had a nice experience in his course on computational method in actuarial science. But let us start with some mathematical formal definitions.

First, recall that Image may be NSFW.
Clik here to view.
http://latex.codecogs.com/gif.latex?y^x
is – somehow – a standard expression. No one should be surprised to see such an expression. Generally (as explained in http://en.wikipedia.org/… ), this function is defined only when Image may be NSFW.
Clik here to view.
http://latex.codecogs.com/gif.latex?y\in\mathbb{R}_+
. The idea is that the definition of Image may be NSFW.
Clik here to view.
http://latex.codecogs.com/gif.latex?y^x
is that

Image may be NSFW.
Clik here to view.
http://latex.codecogs.com/gif.latex?y^x%20=%20\exp\left(x\log[y]\right)

And it is a definition. Such a function exists only if Image may be NSFW.
Clik here to view.
http://latex.codecogs.com/gif.latex?y\in\mathbb{R}_+
(maybe excluding Image may be NSFW.
Clik here to view.
http://latex.codecogs.com/gif.latex?0
). This would be a standard definition in real-analysis.

Now, this ‘power’ function appears also in complex analysis, when dealing with unit roots. From instance, if  Image may be NSFW.
Clik here to view.
http://latex.codecogs.com/gif.latex?z=y^{\frac{1}{k}}e^{i%20\frac{2n\pi}{k}}
, where Image may be NSFW.
Clik here to view.
http://latex.codecogs.com/gif.latex?y\in\mathbb{R}_+
and Image may be NSFW.
Clik here to view.
http://latex.codecogs.com/gif.latex?k\in\mathbb{N}_\star
, for some Image may be NSFW.
Clik here to view.
http://latex.codecogs.com/gif.latex?n\in\mathbb{N}
, then Image may be NSFW.
Clik here to view.
http://latex.codecogs.com/gif.latex?z^k=y
. Thus, in complex-analysis it might be more complex to define properly Image may be NSFW.
Clik here to view.
http://latex.codecogs.com/gif.latex?y^x
since it might not be unique. But we can relate (sometimes, when Image may be NSFW.
Clik here to view.
http://latex.codecogs.com/gif.latex?x
is the inverse of an integer, or maybe a rational number ?) with roots of polynomial functions. So far, nothing new…

Let us get back to Mathieu’s problem. Actually, in his course, he wanted to compute Image may be NSFW.
Clik here to view.
http://latex.codecogs.com/gif.latex?(-8)^{\frac{1}{3}}
. With a French version of Excel, entering

Image may be NSFW.
Clik here to view.

you do get Image may be NSFW.
Clik here to view.
http://latex.codecogs.com/gif.latex?-2
. If you look at the ‘help’ window, you have some more details

Image may be NSFW.
Clik here to view.

It looks like this hat function can be used to define objects such as Image may be NSFW.
Clik here to view.
http://latex.codecogs.com/gif.latex?y^x
. But with

Image may be NSFW.
Clik here to view.

you get

Image may be NSFW.
Clik here to view.

(meaning that this is a problem…). It is also possible to use the power (puissance in French) function of Excel,

Image may be NSFW.
Clik here to view.

Here, you also get

Image may be NSFW.
Clik here to view.

The weird part here is that, in the ‘help’ window, you can read that this power function can be used with any number in Image may be NSFW.
Clik here to view.
http://latex.codecogs.com/gif.latex?\mathbb{R}
.

Image may be NSFW.
Clik here to view.

Another point… what about Image may be NSFW.
Clik here to view.
 ? Somehow, it is just the square of the previous one (with the fraction)… Here, typing

Image may be NSFW.
Clik here to view.

you get

Image may be NSFW.
Clik here to view.

(similarly with the power function). So clearly, it is not that simple to use this power function. Now, if you use Google (which is now my new online calculator when I am in class, when I cannot use R), if the power is a fraction (or to be more specific the inverse of an integer), then it works as Excel

Image may be NSFW.
Clik here to view.
  Image may be NSFW.
Clik here to view.

you get

Image may be NSFW.
Clik here to view.

 But if you type (which should be close, from a continuity property of the power function)

Image may be NSFW.
Clik here to view.
  Image may be NSFW.
Clik here to view.

you get

Image may be NSFW.
Clik here to view.

and similarly

Image may be NSFW.
Clik here to view.

On Wolfram Mathworld, enter

Image may be NSFW.
Clik here to view.

Mathematica does recognize that we try to deal with unit roots: the result is here

Image may be NSFW.
Clik here to view.

with – as expected – a numerical approximation

Image may be NSFW.
Clik here to view.

With Matlab, Mathieu did obtain the same as Mathematica (its decimal approximation). And to conclude, with R, Mathieu did obtain

> (-8)^(1/3)
[1] NaN
> (-8)^(.333333333333333)
[1] NaN

So for R, you cannot use this hat function on negative numbers.

Now, how can we interpret those outputs ?

1) My understanding is that clearly, with MS Excel, Image may be NSFW.
Clik here to view.
http://latex.codecogs.com/gif.latex?x^{ab}\neq%20\left(x^a\right)^b
since

Image may be NSFW.
Clik here to view.
http://latex.codecogs.com/gif.latex?(-8)^{\frac{2}{3}}\neq%20\left((-8)^{\frac{1}{3}}\right)^2

which is problematic. For instance, in insurance, with monthly discounts, we do have functions like Image may be NSFW.
Clik here to view.
http://latex.codecogs.com/gif.latex?u^{\frac{k}{12}}
. What if

Image may be NSFW.
Clik here to view.
http://latex.codecogs.com/gif.latex?u^{\frac{k}{12}}\neq%20\left(u^{\frac{1}{12}}\right)^k

2) The problem comes – probably (MS Excel is not an open software, so it might be hard to check) -  from the fact that Image may be NSFW.
Clik here to view.
http://latex.codecogs.com/gif.latex?y^{\frac{1}{n}}
is interpreted as an inverse of a (possibly) bijective function. To be more specific, Image may be NSFW.
Clik here to view.
http://latex.codecogs.com/gif.latex?x=y^{\frac{1}{n}}
means that Image may be NSFW.
Clik here to view.
http://latex.codecogs.com/gif.latex?x^n=y
. When Image may be NSFW.
Clik here to view.
http://latex.codecogs.com/gif.latex?n
is an odd integer, then (in real-analysis) there is a unique inverse, and thus, Image may be NSFW.
Clik here to view.
http://latex.codecogs.com/gif.latex?y^{\frac{1}{n}}
is uniquely defined, since Image may be NSFW.
Clik here to view.
http://latex.codecogs.com/gif.latex?x\mapsto%20x^n
is a bijective Image may be NSFW.
Clik here to view.
http://latex.codecogs.com/gif.latex?\mathbb{R}\rightarrow\mathbb{R}
function. This is what MS Excel (and Google) is doing: Image may be NSFW.
Clik here to view.
http://latex.codecogs.com/gif.latex?x\mapsto%20x^3
is a bijective Image may be NSFW.
Clik here to view.
http://latex.codecogs.com/gif.latex?\mathbb{R}\rightarrow\mathbb{R}
function, so Image may be NSFW.
Clik here to view.
http://latex.codecogs.com/gif.latex?(-8)^{\frac{1}{3}}
means that we need to find the unique (real) value Image may be NSFW.
Clik here to view.
http://latex.codecogs.com/gif.latex?x
such that Image may be NSFW.
Clik here to view.
http://latex.codecogs.com/gif.latex?x^3=-8
. Thus, somehow, it makes sense to return Image may be NSFW.
Clik here to view.
http://latex.codecogs.com/gif.latex?-2
.

3) There is still a problem with Google, and Mathematica. That is fine to return unit roots in Image may be NSFW.
Clik here to view.
http://latex.codecogs.com/gif.latex?\mathbb{C}
. But how comes there is only one value ? I mean, yes Image may be NSFW.
Clik here to view.
http://latex.codecogs.com/gif.latex?1+\sqrt{3}%20\%20i
is a possible answer, since

Image may be NSFW.
Clik here to view.
http://latex.codecogs.com/gif.latex?(1+\sqrt{3}%20\%20i)^3=-8

but one can also observe that , and similarly, Image may be NSFW.
Clik here to view.
http://latex.codecogs.com/gif.latex?(-2)^3=-8
and

Image may be NSFW.
Clik here to view.
http://latex.codecogs.com/gif.latex?(1-\sqrt{3}%20\%20i)^3=-8

One can check with

Image may be NSFW.
Clik here to view.

With R, since we do not deal with power function here, but with roots, if we want to find Image may be NSFW.
Clik here to view.
http://latex.codecogs.com/gif.latex?x
such that Image may be NSFW.
Clik here to view.
http://latex.codecogs.com/gif.latex?x^3=-8
, the function is

> polyroot(c(8,0,0,1))
[1]  1+1.732051i -2+0.000000i  1-1.732051i

Which is different… Weird isn’t it ?

Image may be NSFW.
Clik here to view.

Arthur Charpentier

Arthur Charpentier, professor in Montréal, in Actuarial Science. Former professor-assistant at ENSAE Paristech, associate professor at Ecole Polytechnique and assistant professor in Economics at Université de Rennes 1.  Graduated from ENSAE, Master in Mathematical Economics (Paris Dauphine), PhD in Mathematics (KU Leuven), and Fellow of the French Institute of Actuaries.

More Posts - Website

Follow Me:
Image may be NSFW.
Clik here to view.
Twitter
Image may be NSFW.
Clik here to view.
LinkedIn
Image may be NSFW.
Clik here to view.
Google Plus

To leave a comment for the author, please follow the link and comment on his blog: Freakonometrics » R-english.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series,ecdf, trading) and more...

Viewing all articles
Browse latest Browse all 589

Trending Articles