Hot answers tagged precision
14
What is wrong: a) you're using exact arithmetic. b) You keep iterating even if the point seems to be escaping.
Try this
ClearAll@prodOrb;
prodOrb[c_, maxIters_: 100, escapeRadius_: 1] :=
NestWhileList[#^2 + c &,
0.,
Abs[#] < escapeRadius &,
1,
maxIters
]
prodOrb[0. + 10. I]
prodOrb[0. + .1 I]
(if you don't need the entire list but ...
11
This is how you manually invoke "LevinRule" when you know part of the integrand is a rapidly oscillatory function satisfying a linear ODE:
First, a rapidly oscillatory function:
In[25]:= osc =
y /. NDSolve[{y''[x] - (x^2 - 3 x) y'[x] + 10000 y[x] == 0,
y[0] == 3, y'[0] == 1}, y, {x, 0, 5}] // First
Out[25]= ...
11
The documentation states:
N does not raise the precision of approximate numbers in its input
163.0 (or 163., or 163`) is a machine precision number, and Mathematica will not fake a higher precision when a certain number of digits are requested with N.
See this answer and this tutorial for more.
These questions may also be of interest:
Converting to ...
8
The problem is that the precision of a and b are set by the form of their input.
a = 1234567891234567889998.5; b = 1234567891234567889999.5;
Precision[a]
22.0915
And 0.5 by default has MachinePrecision, these days typically Log10[2^53] or just under 16 digits.
Precision[0.5]
MachinePrecision
Neither setting the precision of 0.5 to 200 or ...
7
NumberForm can be used to control the number of decimal places.
Plot[0, {x, 8.5, 9.3}, PlotRange -> {{7.9, 11}, {0, 0}},
Axes -> {True, False},
Ticks -> {({#, NumberForm[N@#, {Infinity, 1}]} & /@
Range[0, 11, 1/5]), {}}, PlotStyle -> {Red, Thickness[0.02]}]
6
To make the result of NSum more precise you can use also the NSumTerms option (15 by default, see e.g. Numerical Evaluation of Sums and Products) appropriately increased.
Let's try e.g. :
a1 = NSum[ HarmonicNumber[2 m]/m^3, {m, 1, Infinity}, WorkingPrecision -> 140,
PrecisionGoal -> 70, NSumTerms -> 2000]
...
6
With a compiled version you get it so fast, that you can manipulate it in real time.
fc = Compile[{{in, _Complex, 0}, {c, _Complex, 0}},
Module[{iter = 0, max = 10, z = in},
While[iter++ < max,
If[Abs[z = z^2 + c] > 2.0,
Break[]
]
];
{Abs[z], iter}
], CompilationTarget -> "C", Parallelization -> True,
...
6
One might consider using the simple-minded strategy of splitting the known oscillatory part over its roots (or extrema), evaluating the integral over the intervals determined by the roots, and summing all those integrals to arrive at the actual integral you need.
Now, finding the roots of an oscillatory function that is only known through its differential ...
5
Can do as follows. First generate the matrix of machine numbers.
size = 100;
min = 10*^7;
max = 10*^8;
ltm = Table[
If[j <= i, RandomReal[{min, max}], 0], {i, size}, {j, size}];
matrix = ltm.Transpose[ltm];
Now set the precision, invert, check the product. use the higher prec matrices throughout.
mat2 = SetPrecision[matrix, 30];
inv2 = ...
4
As @acl mentioned in chat, your question really indicates that you should read some fundamental sources. Two that I'd recommend are:
A First Course in Chaotic Dynamical Systems by Bob Devaney for a good overview of the mathematical theory.
Mathematica in Action by Stan Wagon, specifically Chapter 11, for a more condensed overview but with specific ...
4
You are going to get clobbered by an ugly blend of cancellation and roundoff error here. Those fixed points are on the order of epsilon away from one. If you work at machine precision then at epsilon around 10^(-8) you can expect:
8 digits at the front lost to cancellation
Some number lost at the back to roundoff error. With default settings of NIntegrate ...
3
I think your problem arises because the value of $MinPrecision is not distributed correctly (If I remember correctly none of the variables in the System context are distributed automatically).
So we have to do this by hand
ParallelEvaluate[$MinPrecision = 40]
Parallelize[{dGenBessE[1/10, 0], dGenBessE[1/10, 1]}] // AbsoluteTiming
Should now work without ...
3
This is not an answer, just too long for a comment.
To start of with your NIntegrate call looks peculiar, the f(r) part is not a function call but is interpreted as f*r a function call looks like f[r]
(* Obtained by doing ToExpression[...I pasted latex stuff here..., TeXForm]
and replaced e with E ( /.e->E) *)
g[r_] := -((3^(1/3) (E^(-2 ...
3
Arbitrary precision can be a tricky thing, particularly when you start to mix numbers at various levels of precision. As the was pointed out in the comments, if you mix quantities Mathematica will coerce the results to be of the lower precision. For example:
{Sin[Pi/4], Sin[0.25 Pi]}
(* Out: {1/Sqrt[2], 0.707107} *)
Note that Sin[Pi/4] returns the ...
3
Is SetAccuracy what you want?
a = N[10/3, {∞, 3}]
3.33
b = 3``3
3.00
a + 1
4.33
b + 1
4.00
394.985674``3
394.99
Please note Accuracy is a different concept from Precision.
3
Use the $PrePrint global parameter:
$PrePrint = If[MatchQ[#, _?NumericQ], NumberForm[#, {4, 2}], #] &;
Note: if you dont want the way rationals will be represented after setting the global variable (e.g. $3.00/4.00$) then use this instead
$PrePrint = If[MatchQ[#, Except[_Rational,_?NumericQ]], NumberForm[#, {4, 2}], #] &;
Update:
if you ...
2
You must set the option PrintPrecision to a higher value (The default is 6 digits).
This can be done with the Option Inspector very easily.
This can also be done programmatically :
SetOptions[SelectedNotebook[], PrintPrecision -> 16]
It works too with Style[]:
Style[N[\[Pi]], PrintPrecision -> 10]
--> 3.141592654 (instead of default 6 digits ...
2
Next time it would be really nice of you to give actual Mathematica code for your function definitions. Well, for now, thanks to @ssch and ToExpression we have the following definition of g[r]:
g[r_]=-((3^(1/3) (E^(-2 r))^(1/3))/\[Pi]^(2/3))-
(2 \[Pi])^(1/3)/(5 (E^(-2 r))^(1/3) (1+(3 \[Pi]^(1/3)
ArcSinh[(2 (2 \[Pi])^(1/3))/(E^(-2 r))^(1/3)])/(5 2^(2/3) ...
1
cf = Compile[{{a, _Real, 1}},
Module[{z = 0 I, i = 0, max = 100},
While[i++ < max && Abs[z] <= 2,
z = z^2 + a[[1]] + a[[2]]*I]; {Log[i], Abs[z]}],
RuntimeAttributes -> {Listable}, CompilationTarget -> "C",
RuntimeOptions -> "Speed", Parallelization -> True];
t1 = AbsoluteTime[];
data = Table[{i, j}, {j, -2, ...
1
Of course, one should also remember that the Method options of NSum[] accept sub-options as well. For instance,
NSum[HarmonicNumber[2 m]/m^3, {m, 1, Infinity},
Method -> {"EulerMaclaurin", "ExtraTerms" -> 50,
Method -> {NIntegrate, Method -> "DoubleExponential"}},
NSumTerms -> 50, PrecisionGoal -> 90, ...
1
I haven't used TikZ, so I don't know how you can deal with the exported data by Export["xxx.txt",data] in TikZ directly. At least, the data exported in this way cannont be used in Origin, because the txt file exported directly as you did, in fact, is the InputForm of plotting the curve in Mathematica.
So, it is necessary to pretreat the Plot result. I do it ...
1
Here is a very simple way of expressing my problem and gives the answer I found for this setup:
The ODE:
eq1 := y''[x] + (2 (x - 1))/(x (x - 2))
y'[x] + ((100 x^2)/(x - 2)^2 - 2/(x (x - 2))) y[x] == 0;
Solve it:
osc = y /. NDSolve[{eq1, y[5] == 3, y'[5] == 1}, y, {x, 5, 10}] //
First;
Plot[osc[x], {x, 5, 10}]
Give a Levin amplitude
f[x_] := ...
Only top voted, non community-wiki answers of a minimum length are eligible



