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.

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.

share|improve this question

1 Answer 1

up vote 8 down vote accepted

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]]
share|improve this answer

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.