2
$\begingroup$

We ran into a question on a computer science test that basically asked what is $\pi^3$ rounded up to the nearest whole number. The value of $\pi$ as defined by the programming language was $3.141592653589793$ and afterwards, we found out we would've needed to go to $3.1415$ to get the right answer. The difficult part is that the test allows no calculator, and you get on average one minute per question. Maybe there's some easy trick to solve this?

EDIT: Exact question:

What is the output by the code to the right?

System.out.println(Math.ceil(Math.pow(Math.PI, (int) Math.round(Math.max(3.45, 3.3)))));

(The language is Java)

$\endgroup$
  • 3
    $\begingroup$ I'm concerned about the word "basically"... do you happen to have the exact text of the question? $\endgroup$ – The Count Mar 1 '18 at 0:49
  • $\begingroup$ With a calculator $\pi^3 = 31.006...$ so clearly not a reasonable exam question. I concur with @TheCount - we need the exact wording. $\endgroup$ – Ethan Bolker Mar 1 '18 at 0:52
  • 1
    $\begingroup$ Now that you have the edit: I am strictly not at all a computer scientist, but you may get more slick answers over on the CS site. $\endgroup$ – The Count Mar 1 '18 at 0:59
  • 1
    $\begingroup$ @TheCount There are some slick math answers under Proving $\pi^3 \gt 31$. $\endgroup$ – dxiv Mar 1 '18 at 1:15
  • 2
    $\begingroup$ I hate it. If you ceiling up $\pi$ you get $32$ but it's so close to $31$ that any approximations $3\frac 18$ or $\sqrt 10$ or $3\frac 17$ won't give you a very good idea whether it goes over $31$ or not. $\endgroup$ – fleablood Mar 1 '18 at 1:24
3
$\begingroup$

Remember that $\sqrt{10}=3.1622$ is close to $\pi =3.1415$.

Therefor $\pi ^3 $ is approximated by $10\pi =31.4159$ which is closest to the integer $31$.

The ceiling of $\pi ^3 $ is then $32.$

$\endgroup$
  • $\begingroup$ I suppose this depends on knowing $\sqrt{10}$ to four decimals as common knowledge, but I do like it. $\endgroup$ – The Count Mar 1 '18 at 0:58
  • 3
    $\begingroup$ Don't need to know $\sqrt {10}$ at all. If $\pi\approx \sqrt{10}$ then $\pi^2 \approx 10$ and $\pi^3 \approx 10\pi$. What I don't like about this is that we are expected to trust that $\pi \approx \sqrt 10$ is within acceptable margin of error? And that $3.1$ and $3.2$ are not? $\endgroup$ – fleablood Mar 1 '18 at 1:01
  • 1
    $\begingroup$ It is the other way around $ \sqrt{10} \approx \pi $ $\endgroup$ – Mohammad Riazi-Kermani Mar 1 '18 at 1:08
  • 2
    $\begingroup$ 31.4159 which is closest to the integer 31 But rounds up to $32$, which is what the question was asking for. The result is still correct, but the justification is not obvious. $\endgroup$ – dxiv Mar 1 '18 at 1:36
  • 3
    $\begingroup$ @EthanBolker May be interesting to note that the roughest rational approximation gives the much better estimate $\,(22/7)^3 = 31.04\ldots\,$, which hints at the correct answer of $\,32\,$, but is still not enough to prove it. $\endgroup$ – dxiv Mar 1 '18 at 1:38

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.