4
$\begingroup$

I want to test the value of a differential equation by replacing a solution and setting random values for r and z variables:

sol = ψ -> Function[{r, z}, Sinh[2 (r + z)^2] + Tan[4/3 + r] + 5 (-r + Tanh[1/r])];

de2 = 1/(4*r^2) - D[ψ[r, z], z]^2 + D[ψ[r, z], z, z] + D[ψ[r, z], r]/(2 r)+ D[ψ[r, z], r]^2 +  D[ψ[r, z], r, r];

If I set for example:

N[de2 /. sol /. r -> -9 /. z -> 4]==0

I get a false result. The value is a very large negative number (-3.16913*10^29).

If I set:

N[de2 /. sol /. r -> -90 /. z -> 4]

I get 0.*10^12836 in red, and a message saying "No significant digits are available to display."

If I compare this last command to zero:

N[de2 /. sol /. r -> -90 /. z -> 4]==0

I get True! What's happening? How could I prevent this from occurring?

Not using PZQ because it is too slow for the number of tests I want to do.

$\endgroup$
8
$\begingroup$

There are large numbers and you need to increase $MaxExtraPrecision, as well as use non-machine arithmetic. E.g.:

$MaxExtraPrecision = 8000;
N[de2 /. sol /. r -> -90 /. z -> 4, 20]

gives

1.4495694130768246652*10^6429

Alternatively, you could do

N[Expand[de2 /. sol /. r -> -90 /. z -> 4]]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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