# EMH reciting pi

In "Virtuoso" (https://memory-alpha.fandom.com/wiki/Virtuoso_(episode)), the EMH is adored by his "fans" of a Delta Quadrant planet. One of them sends him a subspace message, asking to how many digits he can recite pi.

Since pi is an unending decimal, and since the Doctor is essentially a walking computer, could the EMH recite pi indefinitely? Or would he come to a point where he simply could not recite any more digits?

• I don't know how you could prove it, but I have to imagine Star Trek era computers can calculate the next digit of pi quicker than they can say it, which is all you really need to do it indefinitely. Commented Sep 14, 2014 at 17:33
• Good point. Even if the EMH (or Data, for example), didn't know pi to x amount of digits, they surely could calculate it as they recited!
– user30592
Commented Sep 14, 2014 at 17:35
• Knowing π to 10 decimal places is as accurate as anyone would need, unless you were trying to navigate to another galaxy. I postulate that the EMH would probably consult a database for whatever level of decimal points it has available, then ask "How many digits do you want?" before continuing. Personally I use 3 as π for ballpark figures, and 3.14 if I need more accuracy. After that I use a calculator that has a π button. Commented Jun 13, 2016 at 1:16

Obviously his fans are treating him as if he is an organic which has limited memory, calculating ability, or limitations to his energy / waking / regeneration span.

On the other hand, I do not believe that there is a canonical answer as to whether the EMH has access to pure math functions or the ability to write and execute a recursive algorithm. B'elana could easily reprogram him, but we know how "Joe" feels about that.

• `whether the EMH has access to pure math functions` He'd be a terrible doctor if he couldn't calculate dosages for patients. Commented Sep 14, 2014 at 17:56
• There's a difference between calculating mg per kg (a simple calculation) and calculating pi (which requires a subroutine). Since he uses the sick bay computers, PADDs, and consoles for other functions, we can assume that not all functions are programmed in him. Commented Sep 14, 2014 at 18:16

In VOY : Virtuoso, the EMH doctor states that he is well versed in a wide variety of medical practices;

Abarca: When we agreed to be examined by this ship's medical officer, we didn't know that you were a primitive computer matrix.

The Doctor: [irritated] I assure you, there is nothing primitive about me. I am programmed to perform more than five million medical procedures.

Since the ability to calculate π is essential for the study of DNA, the distribution curve of disease profiles, for eye surgery and many other medical functions it seems reasonable to assume that the Doctor would possess the ability to calculate Pi to a very substantial level.

• We organics can study DNA, calculate the distribution curve of disease profiles, and perform eye surgery without internally (organically) being able to calculate pi. Commented Sep 14, 2014 at 18:17
• You don't see an organic doctor stopping to do so either. Commented Sep 14, 2014 at 18:19
• @RoboKaren - Then how do you explain this picture; insurancejournal.com/wp-content/uploads/2013/05/…? Commented Sep 14, 2014 at 18:25
• Check but not mate. That's a picture of a doctor in his office doing insurance payout calculations, not treating patients. We all know that the Federation has single-payer healthcare so it would not apply to Joe the EMH. Your move. Commented Sep 14, 2014 at 20:36
• @RoboKaren, further, it's extremely likely that the Doctor simply has some finite approximation of pi stored in his memory as a constant, rather than recalculating it every time it's needed. It's not like the value of pi changes... Commented Sep 15, 2014 at 14:47

A program that calculates pi must keep track of the position of the digit that it is currently calculating.

Any computer will have a hard limit on how large that number can be. Therefore the number of digits that the EMH can recite isn't indefinite, but could probably go on for trillions of years.

He would probably stop long before he reached this theoretical maximum, as soon as the running program began to noticeably impair his ability to provide medical care.

• I'm voting you down for being factually incorrect. There are algorithms for calculating the nth digit of pi without having to calculate preceding digits ( math.hmc.edu/funfacts/ffiles/20010.5.shtml). Thus the only limitation for machine generated digits of pi are mechanical (power supply) rather than computational. Commented Sep 14, 2014 at 22:44
• Note that even 512-bytes (which is a trivial amount) can store a bigger number (2^512) than the number of atoms in the universe or milliseconds in a millenia. Commented Sep 14, 2014 at 23:25
• @RoboKaren The complexity of calculating that digit still increases logarithmically with the position of the digit, which I think is what Kevin means. But, yes, because the complexity is only logarithmic, there is, physically speaking, no upper bound. Commented Sep 15, 2014 at 1:52
• @Thomas Are you sure that the growth is logarithmic. The current record is 10 trillion digits using an off-the-shelf computer. It'd be hard to imagine that there's any growth in complexity with the algorithm used. Commented Sep 15, 2014 at 2:03
• @RoboKaren A 512-byte quantity can store a maximum value of 2^(8*512) = 2^4096, assuming eight-bit bytes and a one-to-one mapping between value stored and value represented. (Note that in the electronics industry, memory chip sizes are often specified in terms of bits, not bytes!) Storing the number of milliseconds in a millennium (about 3.15e13 if my math is right) requires 45 bits in binary representation. 2^4096 is approximately 1e1233.
– user
Commented Sep 15, 2014 at 8:48

I think the answer lies in the fact that the doctor needs to use the same tools as a medical practitioner.

For instance, consider the tricorders and the computers in sick bay. Starfleet could have built the EMH as a self-contained walking computerized sick bay, but they didn't. Instead the EMH also needs to use tricorders and computers in the same way as any non-holographic medical officer would.

In that vein, I wouldn't expect the EMH to have the ability to calculate pi in his 'head'. At most, we expect the EMH to memorized pi in no more, no less a capacity as any non-holographic medical officer would.

If required, the EMH could simply use a computer to lookup or calculate pi rather than do it himself.

• "memorized pi in no more, no less a capacity as any non-holographic medical officer would" -- well, probably more. I doubt there are that many practicing doctors who have memorized a large number of the digits of pi, while it would be beyond trivial to code the Doctor with whatever the standard of precision is in the programming language he was developed with. Commented Sep 15, 2014 at 14:53