| |
 |
|
|
Science Forum Index » Math - Symbolic Forum » Mathematica precision for a^b
Page 1 of 1
|
| Author |
Message |
| Guest |
Posted: Tue Feb 20, 2007 5:57 am |
|
|
|
|
Hallo
I am new to mathematica. I have mathematica 5.1.
If I have the expresion a^b where a is an arbitrary double precision
decimal number and b is an exact number say a list from 1-10. How can
I see that the precision of this expression changes when raising a to
these powers?
Many thanks in advance
Sonya |
|
|
| Back to top |
|
| Jean-Marc Gulliet |
Posted: Tue Feb 20, 2007 7:05 am |
|
|
|
Guest
|
sonyaBabken@yahoo.de wrote:
Quote: Hallo
I am new to mathematica. I have mathematica 5.1.
If I have the expresion a^b where a is an arbitrary double precision
decimal number and b is an exact number say a list from 1-10. How can
I see that the precision of this expression changes when raising a to
these powers?
Many thanks in advance
Sonya
Hi Sonya,
The precision of the results does not change: since you have a mix of
hardware precision numbers and exact numbers the overall precision is
lowered to machine precision and the computations are done using the
functions implemented in the hardware. Detailed explanations are given in
"The Mathematica Book Online / Advanced Mathematics in Mathematica /
Numbers / 3.1.4 Numerical Precision", available at
http://documents.wolfram.com/mathematica/book/section-3.1.4
To see the precision of a Mathematica expression, you can use the
built-in function Precision [1]. For instance,
In[1]:=
a = 2.;
In[2]:=
Precision[a]
Out[2]=
MachinePrecision
In[3]:=
b = Range[10]
Out[3]=
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
In[4]:=
Precision /@ b
Out[4]=
{Infinity, Infinity, Infinity, Infinity, Infinity,
Infinity, Infinity, Infinity, Infinity, Infinity}
In[5]:=
a^b
Out[5]=
{2., 4., 8., 16., 32., 64., 128., 256., 512., 1024.}
In[6]:=
Precision /@ %
Out[6]=
{MachinePrecision, MachinePrecision, MachinePrecision,
MachinePrecision, MachinePrecision,
MachinePrecision, MachinePrecision,
MachinePrecision, MachinePrecision, MachinePrecision}
In[7]:=
$MachinePrecision
Out[7]=
15.9546
In[8]:=
$Version
Out[8]=
5.2 for Microsoft Windows (June 20, 2005)
Regards,
Jean-Marc
[1] http://documents.wolfram.com/mathematica/functions/Precision |
|
|
| Back to top |
|
| Guest |
Posted: Tue Feb 20, 2007 7:23 am |
|
|
|
|
On 20 Feb., 12:05, Jean-Marc Gulliet <jeanmarc.gull...@gmail.com>
wrote:
Quote: sonyaBab...@yahoo.de wrote:
Hallo
I am new tomathematica. I havemathematica5.1.
If I have the expresion a^b where a is an arbitrary doubleprecision
decimal number and b is an exact number say a list from 1-10. How can
I see that theprecisionof this expression changes when raising a to
these powers?
Many thanks in advance
Sonya
Hi Sonya,
Theprecisionof the results does not change: since you have a mix of
hardwareprecisionnumbers and exact numbers the overallprecisionis
lowered to machineprecisionand the computations are done using the
functions implemented in the hardware. Detailed explanations are given in
"TheMathematicaBook Online / Advanced Mathematics inMathematica/
Numbers / 3.1.4 NumericalPrecision", available at
http://documents.wolfram.com/mathematica/book/section-3.1.4
To see theprecisionof aMathematicaexpression, you can use the
built-in functionPrecision[1]. For instance,
In[1]:> a = 2.;
In[2]:=Precision[a]
Out[2]> MachinePrecision
In[3]:> b = Range[10]
Out[3]> {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
In[4]:=Precision/@ b
Out[4]> {Infinity, Infinity, Infinity, Infinity, Infinity,
Infinity, Infinity, Infinity, Infinity, Infinity}
In[5]:> a^b
Out[5]> {2., 4., 8., 16., 32., 64., 128., 256., 512., 1024.}
In[6]:=Precision/@ %
Out[6]> {MachinePrecision, MachinePrecision, MachinePrecision,
MachinePrecision, MachinePrecision,
MachinePrecision, MachinePrecision,
MachinePrecision, MachinePrecision, MachinePrecision}
In[7]:> $MachinePrecision
Out[7]> 15.9546
In[8]:> $Version
Out[8]> 5.2 for Microsoft Windows (June 20, 2005)
Regards,
Jean-Marc
[1]http://documents.wolfram.com/mathematica/functions/Precision
Hi Jean
Thank you very much for quick response. I have done exactly the above
and as you could see
In[1]:a=2.;
In[2]:Precision[a]
Out[2]MachinePrecision
In[3]:b=Range[10]
Out[3]{1,2,3,4,5,6,7,8,9,10}
In[4]:Precision/@b
Out[4]{∞,∞,∞,∞,∞,∞,∞,∞,∞,∞}
In[5]:Precision/@%
Out[5]{∞,∞,∞,∞,∞,∞,∞,∞,∞,∞}
In[6]:$Version
Out[6]5.1 for Microsoft Windows (October 25, 2004)
What does this difference mean?
Many thanks |
|
|
| Back to top |
|
| Guest |
Posted: Tue Feb 20, 2007 7:31 am |
|
|
|
|
On 20 Feb., 12:23, sonyaBab...@yahoo.de wrote:
Quote: On 20 Feb., 12:05, Jean-Marc Gulliet <jeanmarc.gull...@gmail.com
wrote:
sonyaBab...@yahoo.de wrote:
Hallo
I am new tomathematica. I havemathematica5.1.
If I have the expresion a^b where a is an arbitrary doubleprecision
decimal number and b is an exact number say a list from 1-10. How can
I see that theprecisionof this expression changes when raising a to
these powers?
Many thanks in advance
Sonya
Hi Sonya,
Theprecisionof the results does not change: since you have a mix of
hardwareprecisionnumbers and exact numbers the overallprecisionis
lowered to machineprecisionand the computations are done using the
functions implemented in the hardware. Detailed explanations are given in
"TheMathematicaBook Online / Advanced Mathematics inMathematica/
Numbers / 3.1.4 NumericalPrecision", available at
http://documents.wolfram.com/mathematica/book/section-3.1.4
To see theprecisionof aMathematicaexpression, you can use the
built-in functionPrecision[1]. For instance,
In[1]:> > a = 2.;
In[2]:=Precision[a]
Out[2]> > MachinePrecision
In[3]:> > b = Range[10]
Out[3]> > {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
In[4]:=Precision/@ b
Out[4]> > {Infinity, Infinity, Infinity, Infinity, Infinity,
Infinity, Infinity, Infinity, Infinity, Infinity}
In[5]:> > a^b
Out[5]> > {2., 4., 8., 16., 32., 64., 128., 256., 512., 1024.}
In[6]:=Precision/@ %
Out[6]> > {MachinePrecision, MachinePrecision, MachinePrecision,
MachinePrecision, MachinePrecision,
MachinePrecision, MachinePrecision,
MachinePrecision, MachinePrecision, MachinePrecision}
In[7]:> > $MachinePrecision
Out[7]> > 15.9546
In[8]:> > $Version
Out[8]> > 5.2 for Microsoft Windows (June 20, 2005)
Regards,
Jean-Marc
[1]http://documents.wolfram.com/mathematica/functions/Precision
Hi Jean
Thank you very much for quick response. I have done exactly the above
and as you could see
In[1]:> a=2.;
In[2]:=Precision[a]
Out[2]> MachinePrecision
In[3]:> b=Range[10]
Out[3]> {1,2,3,4,5,6,7,8,9,10}
In[4]:=Precision/@b
Out[4]> {∞,∞,∞,∞,∞,∞,∞,∞,∞,∞}
In[5]:=Precision/@%
Out[5]> {∞,∞,∞,∞,∞,∞,∞,∞,∞,∞}
In[6]:> $Version
Out[6]> 5.1 for Microsoft Windows (October 25, 2004)
What does this difference mean?
Many thanks
Sorry Jean. Just neglect my previous message please.
Thank you |
|
|
| Back to top |
|
| Paul Abbott |
Posted: Tue Feb 20, 2007 8:54 am |
|
|
|
Guest
|
In article <1171965456.017093.124290@m58g2000cwm.googlegroups.com>,
sonyaBabken@yahoo.de wrote:
Quote: I am new to mathematica. I have mathematica 5.1.
If I have the expresion a^b where a is an arbitrary double precision
decimal number and b is an exact number say a list from 1-10. How can
I see that the precision of this expression changes when raising a to
these powers?
If a is a machine precision number, the precision does not change:
mp = 1.3 ^ Range[6,8]
{4.826809000000003, 6.274851700000004, 8.157307210000003}
Precision /@ mp
{MachinePrecision, MachinePrecision, MachinePrecision}
If a is an arbitrary precision number, the precision does change:
ap = 1.3`30 ^ Range[6,8];
Precision /@ ap
{29.221848749616356, 29.15490195998574, 29.096910013008056}
Note that 1.3`30 is a shorthand way of entering 1.3 followed by 28 zeros.
1.3`30
1.300000000000000000000000000000
Cheers,
Paul
_______________________________________________________________________
Paul Abbott Phone: 61 8 6488 2734
School of Physics, M013 Fax: +61 8 6488 1014
The University of Western Australia (CRICOS Provider No 00126G)
AUSTRALIA http://physics.uwa.edu.au/~paul |
|
|
| Back to top |
|
| Richard J. Fateman |
Posted: Tue Feb 20, 2007 1:33 pm |
|
|
|
Guest
|
The story is not so simple for arbitrary powers. Consider 10.0 ^ 1000000
which comes out as
1.00000000000155 * 10*^1000000
with precision 14.1484 and accuracy -999986.
Perhaps others can explain what this means. It might be a bug, since the
two inputs can be represented (easily) exactly. The output can be
represented exactly in Mathematica, too. Choosing an appropriate
precision and attributing some accuracy to it seems to me to be somewhat
arbitrary: what is the default precision used when a number overflows?
Or perhaps something else is going on. (in Mathematica 5.1)
RJF
Paul Abbott wrote:
Quote: In article <1171965456.017093.124290@m58g2000cwm.googlegroups.com>,
sonyaBabken@yahoo.de wrote:
I am new to mathematica. I have mathematica 5.1.
If I have the expresion a^b where a is an arbitrary double precision
decimal number and b is an exact number say a list from 1-10. How can
I see that the precision of this expression changes when raising a to
these powers?
If a is a machine precision number, the precision does not change:
mp = 1.3 ^ Range[6,8]
{4.826809000000003, 6.274851700000004, 8.157307210000003}
Precision /@ mp
{MachinePrecision, MachinePrecision, MachinePrecision}
If a is an arbitrary precision number, the precision does change:
ap = 1.3`30 ^ Range[6,8];
Precision /@ ap
{29.221848749616356, 29.15490195998574, 29.096910013008056}
Note that 1.3`30 is a shorthand way of entering 1.3 followed by 28 zeros.
1.3`30
1.300000000000000000000000000000
Cheers,
Paul
_______________________________________________________________________
Paul Abbott Phone: 61 8 6488 2734
School of Physics, M013 Fax: +61 8 6488 1014
The University of Western Australia (CRICOS Provider No 00126G)
AUSTRALIA http://physics.uwa.edu.au/~paul |
|
|
| Back to top |
|
| Daniel Lichtblau |
Posted: Tue Feb 20, 2007 2:54 pm |
|
|
|
Guest
|
On Feb 20, 11:33 am, "Richard J. Fateman" <fate...@eecs.berkeley.edu>
wrote:
Quote: The story is not so simple for arbitrary powers. Consider 10.0 ^ 1000000
which comes out as
1.00000000000155 * 10*^1000000
with precision 14.1484 and accuracy -999986.
Perhaps others can explain what this means. It might be a bug, since the
two inputs can be represented (easily) exactly. The output can be
represented exactly in Mathematica, too. Choosing an appropriate
precision and attributing some accuracy to it seems to me to be somewhat
arbitrary: what is the default precision used when a number overflows?
Or perhaps something else is going on. (in Mathematica 5.1)
RJF
[...]
In Mathematica when a number overflows in machine arithmetic the
computation is instead done with bignums, at $MachinePrecision digits
(typically a hair under 16). I think each power of 10 gives rise to
precision loss of Log[10.,2] or 0.301 digits (try upping the power
from 10^6 to 10^7 and then 10^ .
Daniel Lichtblau
Wolfram Research |
|
|
| Back to top |
|
| |
|
Page 1 of 1
All times are GMT - 5 Hours
The time now is Tue Dec 02, 2008 12:22 am
|
|