• 1
• 2
• 3
• 4
• 5
• 9 Collector
Topic Author
Posts: 4651
Joined: August 21st, 2001, 12:37 pm

### Mathematica high precision question

In my recent working paper I needed to calculate

$v=c\sqrt{1-\frac{l_p^2}{\bar{\lambda}_e^2}}$

well c is known so basically I needed a numerical value for  $\sqrt{1-\frac{l_p^2}{\bar{\lambda}_e^2}}$

where $l_p$ is the Planck length and $\bar{\lambda}_e$ is the reduced Compton wavelength of the electron.

First I tried

N [Sqrt[1 (1.616 * 10^ (-33))^ 2/(3.862* 10^ (-13))^ 2], 50]

This did not give me the precision needed, but when I changed to write it on the following form, then mathematica gave me the precision needed. I played around with a few other ways that confirmed the result.

N [Sqrt[1 (1616*10^ (-36))^ 2/(3862 *10^ (-16))^ 2], 50]

Still I wonder why the N [Sqrt[1 (1.616 * 10^ (-33))^ 2/(3.862* 10^ (-13))^ 2], 50]  not could handle it? It return 1 while the answer should be .99999999999999999999999999999999999999999999912416

I could naturally have increased precision further by adding more known digits to the Planck length and the reduced Compton wavelength of the electron, but I was mostly interested in when the first few digits goes down from 9 to see if LHC was anything close to these velocities needed in according to my theory. Well here a electron, in my paper also a proton.

Well my main question why can N [Sqrt[1 (1.616 * 10^ (-33))^ 2/(3.862* 10^ (-13))^ 2], 100] not handle it? only returns 1.

any other simple ways to do this in mathematica? Alan
Posts: 10211
Joined: December 19th, 2001, 4:01 am
Location: California
Contact:

### Re: Mathematica high precision question

You need a high precision calculation. But, once you put a decimal point in any number, Mathematica reverts to Machine Precision.

In general, if you want any function evaluated at high precision, as you discovered, all is well when all the inputs are 'exact' numbers (whole numbers, exact rational fractions, built-in's like Pi, etc.), or numbers which are not exact, but have the necessary working precision.

Other forms that would also have worked:

N[Sqrt[1- (1616/1000*10^(-33))^2/(3862/1000*10^(-13))^2],50]
0.99999999999999999999999999999999999999999124556387

N[Sqrt[1- (SetPrecision[1.616*10^(-33),50])^2/(SetPrecision[3.862*10^(-13),50])^2],50]
0.99999999999999999999999999999999999999999124556387 Collector
Topic Author
Posts: 4651
Joined: August 21st, 2001, 12:37 pm

### Re: Mathematica high precision question

Thank you Alan, that was useful!  I need to read more up on Mathematica as I use it for more and more.

As I dig deeper and deeper I need higher and higher precision. Cuchulainn
Posts: 62408
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

### Re: Mathematica high precision question

Hi Collector,
http://www.boost.org/doc/libs/1_61_0/li ... index.html ppauper
Posts: 70239
Joined: November 15th, 2001, 1:29 pm

### Re: Mathematica high precision question

one of the rivals is maple, which has the Digits command which controls the number of digits that Maple uses when making calculations with software floating-point numbers. Collector
Topic Author
Posts: 4651
Joined: August 21st, 2001, 12:37 pm

### Re: Mathematica high precision question

Thanx, yes I also use a C++ as well as Maple from time to time (getting rusty on these), mostly using Mathematica these days (and excel, but not for high precision). AVt
Posts: 1074
Joined: December 29th, 2001, 8:23 pm

### Re: Mathematica high precision question

BTW one can do that using Excel as well, "remembering" sqrt(1-t) has the series 1 - t/2 - t^2/8 ... for t ~ 0, so it is 1 minus 1.616^2 / 3.862^2 * 0.5 * 10^(2*a-2*b) = 1 minus 0.087544361250292 * 10(-40)

As a matter of taste one can fill up 1 - 0.875443612502920 = 0.1245563874970800 with the leading 9's Collector
Topic Author
Posts: 4651
Joined: August 21st, 2001, 12:37 pm

### Re: Mathematica high precision question

BTW one can do that using Excel as well, "remembering" sqrt(1-t) has the series 1 - t/2 - t^2/8 ... for t ~ 0, so it is 1 minus 1.616^2 / 3.862^2 * 0.5 * 10^(2*a-2*b) = 1 minus 0.087544361250292 * 10(-40)

As a matter of taste one can fill up 1 - 0.875443612502920 = 0.1245563874970800 with the leading 9's
Excellent! Thnx! Collector
Topic Author
Posts: 4651
Joined: August 21st, 2001, 12:37 pm

### Re: Mathematica high precision question

BTW one can do that using Excel as well, "remembering" sqrt(1-t) has the series 1 - t/2 - t^2/8 ... for t ~ 0, so it is 1 minus 1.616^2 / 3.862^2 * 0.5 * 10^(2*a-2*b) = 1 minus 0.087544361250292 * 10(-40)

As a matter of taste one can fill up 1 - 0.875443612502920 = 0.1245563874970800 with the leading 9's
if using for example 2 terms instead of one in the series expansion: 1-t/2-t^2/8-t^4/8  I get  1 - 1.616^2/2/3.862^2 - 1.616^4/2/3.862^4/8 = 0.9086 . I guess this indicates Mathematica (functions discussed above) only is using the first term of the series expansion, that gives 0.9125 (0.99999999999999999999999999999999999999999124556387)  ? and better to use the series expansion directly so one has better control of precission one get?

Series expansion

1          0.91241560253
2          0.90858008918
3          0.90824415806
4          0.90820738015
5          0.90820287051
6          0.90820227805
7          0.90820219651
8          0.90820218491
9          0.90820218321
10        0.90820218296

Stupid question of the day, is there a general rule for how many digits accurancy one get for each term one add in the series expansion? One term per digit? or dependent on function one series expand?

I never needed much precission before, I used to handle big  well with (love) low precission, did not care much about sub-pennies, and now I have moved into the Planck world: sub-pennies and high precission..
Last edited by Collector on September 8th, 2016, 7:36 pm, edited 2 times in total. Collector
Topic Author
Posts: 4651
Joined: August 21st, 2001, 12:37 pm

### Re: Mathematica high precision question

A related question. Is there a simple standard for writing where first non 9 digit starts ? (well above I should have lp=1.616*10^(-35) LambdaBar  still 3.862*10^(-13)

and the max speed using 6 terms in the series expansion wold then be

0.9999999999 9999999999 9999999999 9999999999 99999 08202

Is there a standard to write this in much more compact form?

like 082022*10^(-45,9)   indicating forty five 9's in front before decimal point. Well I guess there must be some other standard already? 082022E9-45

082022E9-45 = 0.9999999999 9999999999 9999999999 9999999999 99999 082022
082022E4-45 = 0.4444444444 4444444444 4444444444 4444444444 44444 082022
082022E7-45 = 0.7777777777 7777777777 7777777777 7777777777 77777 082022

or simply

082022H9-45 = 0.9999999999 9999999999 9999999999 9999999999 99999 082022
082022H4-45 = 0.4444444444 4444444444 4444444444 4444444444 44444 082022
082022H7-45 = 0.7777777777 7777777777 7777777777 7777777777 77777 082022 Cuchulainn
Posts: 62408
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

### Re: Mathematica high precision question

so, we can expect numbers soon?
https://en.wikipedia.org/wiki/Numerical_relativity

If it uses Hamiltonian stuff even better  AVt
Posts: 1074
Joined: December 29th, 2001, 8:23 pm

### Re: Mathematica high precision question

Your t is (p/1000*10^(-a))^2/(q/1000*10^(-b))^2 = 652864/3728761*10^(-2*a+2*b) with p=1616,q=3862, you forgot the decimal powers, I guess.

So you have 1 minus (t/2 + t2/8) = 1 minus (.875443612502920e-1*10^(-2*a+2*b)+ .383200759336081e-2*(10^(-2*a+2*b))^2), a=33, b=13

Both the floats can be done by Excel. The 2nd term is ~ 0.38 * 10(-40)^2, so it would not contribute in double precision if adding both, so you stop.

Best you increase MMA / Maple / ... to desired digits for 'careless' work beyond the suggestion. Collector
Topic Author
Posts: 4651
Joined: August 21st, 2001, 12:37 pm

### Re: Mathematica high precision question

ohh yes I see that now! Thx! Collector
Topic Author
Posts: 4651
Joined: August 21st, 2001, 12:37 pm

### Re: Mathematica high precision question

seems to work and gives same as mathematica  http://www.espenhaug.com/maxspeed2test.xls (if a electron cloud is moving faster than this speed, then run, run at the speed of light! )  Collector
Topic Author
Posts: 4651
Joined: August 21st, 2001, 12:37 pm

### Re: Mathematica high precision question

I am working with something similar now that require even higher precision (seems like I am running into some limitations also in Mathematica possibly, but yes I will be able to calculate it).

The question is how to present my numerical results in compact form. For example how do I write the following number on compact form?: (must be a simple standard for it, just me that not used to work with such numbers)

0.999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999989

what about something like 89*10^(-137;9)  Don't tell me there is no simple standard for this?

(and I will need many more 9's for what I am looking at now, I don't want a single output number to go over 30 pages (printing cost is too high) )
Last edited by Collector on November 17th, 2016, 1:22 pm, edited 3 times in total.  