0
$\begingroup$

I have a problem: when I ask something to print with precision P, that is, Print[N[something, P]], it does not print with precision P, just with the usual output precision.

In particular, I have a triple nested while-loop, something of the form

While[p<...,

While[k<... ,

While[n<***+1,

process in which Y[n] is defined

n++ ]

Print[N[Y[***],100]];

k++ ]

p++ ]

Then the output prints Y[***] each time to the default printed precision, not 100. Other than this, my code works as expected.

Does anyone have an idea what I can do to fix this?


(My code is very long and I am doing an assignment where only small hints about parts of the code is allowed, so I don't think I should post my full code here. I hope I've provided enough and not too much detail.)

$\endgroup$
  • 3
    $\begingroup$ Hard to say why without a MWE. It could be a bug, but hard to know. I tried this on 10.3.1 and it works: Print[N[Pi, 100]]. Can't you make a small example to show the problem? I just also add there might not be enough precision in the number itself. $\endgroup$ – Nasser Dec 25 '15 at 0:16
  • 5
    $\begingroup$ OTOH, Print[N[3.14, 100]] will not print 100 digits (as expected). Y[***] must have at least a precision of 100 (or be exact) to get 100 digits of precision. $\endgroup$ – Michael E2 Dec 25 '15 at 0:17
  • $\begingroup$ good example @MichaelE2, but this prints 100 digits: "Print[N[3.14`100, 100]]" :) $\endgroup$ – Nasser Dec 25 '15 at 0:20
  • $\begingroup$ @Nasser Also printing SetPrecision[3.14, 100] would print 100 digits, as would SetPrecision[Y[***], 100], though all beyond the precision of the number should be treated as garbage. (I thought our first comments covered the main points pretty well.) $\endgroup$ – Michael E2 Dec 25 '15 at 0:31
3
$\begingroup$

I suspect this question has little to do with Print. Consider

N[N[Pi, 6], 100]

3.14159

N can reduce the precision of its first argument, but it can't increase it. It seems likely to me that Y[***], whatever it actually is, simply doesn't represent anything that can evaluated to 100 digits of precision.

$\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.