Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Is it possible to force Mathematica to perform computations with hardware supported quadruple-precision? The following test suggest, that all of the computations with fixed precision, different than $MachinePrecision=15.9546, are performed via the same arbitrary precision algorithm. Am I right? Is it possible to speed up 34 digit accurate computations?

num = RandomInteger[{1, 100}, 5 10^5];
First@AbsoluteTiming[
  Sin[N[num]];
]
(* ==> 0.273485 *)

{#, First@AbsoluteTiming[
 Sin[N[num, #]];]} & /@ Range[32, 36]

(* ==>
{{32, 10.224581}, {33, 9.942714}, {34, 10.043138},
{35, 9.856203}, {36, 9.929918}}
*)
share|improve this question
9  
Not possible to the best of my knowledge. –  Daniel Lichtblau May 9 '12 at 23:30
4  
I'm curious, which hardware platform are you using? –  sebhofer May 9 '12 at 23:37
    
@sebhofer I'm also curious about that. According to this, 128-bit floats are not natively supported on the x86 architecture. Maybe he meant 80-bit precision? This could be the reason why Mma doesn't support quadruple precision. A little googling shows that on Intel processors 128-bit precision is implemented in software (when certain compilers support it). –  Szabolcs May 10 '12 at 7:56
add comment

1 Answer 1

As the comments indicate, there is no completely hardware-based solution - but that doesn't mean you can't do some tweaking. The trick is always: stick with machine precision as long as you can, then switch to arbitrary precision only to refine your results.

Instead of making up an example (which is hard because Mathematica implements the above principle automatically in many cases, as observed in the comment - which caused me to delete an earlier example), I'll address the problem given in your question some more. It can also be sped up considerably by deferring the use of arbitrary precision (in this case the application of N[...,36] etc.) to the end:

{#, First@AbsoluteTiming[N[Sin[num], #];]} & /@ Range[32, 36]

{{32, 0.931845}, {33, 0.871302}, {34, 0.858584}, {35, 0.852693}, {36, 0.849243}}

All I did was to move the N outside the Sin, and the timing is an order of magnitude faster.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.