Group Abstract Group Abstract

Message Boards Message Boards

0
|
251 Views
|
1 Reply
|
2 Total Likes
View groups...
Share
Share this post:

Struggling with arbitrary precision in a calculation involving very large and very small numbers

Hi, I am attempting to run a simulation of a complex mathematical equation from Equation. The simulation is run from 0-1 second in 0.01 second steps. The exponential terms are causing serious issues, as the integral in the exponent becomes a very large value very quickly. Because of this i am attempting to use arbitrary precision to calculate with tens of thousands of decimal places, however i am getting errors telling me e^-73000 (approximately) cannot be represented as a machine number even though i am not trying to represent it as a machine number. I am also having trouble inside the large integral, as the exponential term in there goes towards infinity. I know there is likely a very simple solution, but i just cant seem to work out what im doing wrong and it is somewhat time sensitive. I would appreciate any help anyone can offer.
This is the code i am currently using to compute the equation:

input[v_] := N[A0*Sin[(w*v) + \[Theta]] + A0];
term1[j_] := N[(\[Sigma]*input[j])/(R*\[CurlyEpsilon]0), 100000];
term2[x_] := N[(d + input[x])/(R*S*\[CurlyEpsilon]0), 100000];
negintegrand[f_]  := 
  NIntegrate[(d + input[a])/(R*S*\[CurlyEpsilon]0), {a, 0, f}, 
   AccuracyGoal -> Infinity];
term3[y_] := N[Exp[-negintegrand[y]], 100000];
innerintegrand[g_] := N[Exp[negintegrand[g]], 100000];
integrand[h_] := 
  N[(\[Sigma]*input[h])/(R*\[CurlyEpsilon]0)*innerintegrand[h], 
   100000];
term4[z_] := 
  N[NIntegrate[integrand[n], {n, 0, z}, AccuracyGoal -> Infinity], 
   100000];
output[t_] := N[term1[t] - term2[t]*term3[t]*term4[t], 100000];

Wolfram Notebook

POSTED BY: Adam Worthington

A calculation that has a machine-precision number in it generally results in a machine-precision result.

In particular, if expr is machine precision, then N[expr, 5000] does not change it. The precision has been lost and cannot be recovered.

NIntegrate[] without a WorkingPrecision option uses machine precision.

N[expr] uses machine precision, so input[v] results in a machine-precision expression.

Your range table is machine precision.

All this means that most, and maybe all, of your N[..., 5000] calls have no effect.

For high-precision results, I mainly use exact input (e.g. Table[x, {x, 0, 1, 1/10}] or Range[0, 1, 1/10]) and WorkingPrecision (e.g. WorkingPrecision -> 5000) in functions that have such an option. Beware, such a high setting for NIntegrate[] will probably take a long time to compute. I usually use N[expr, 5000] on exact expressions, since N[] generally cannot increase the precision of a result; and it won't change machine precision to arbitrary precision.

POSTED BY: Michael Rogers
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard