Talk:Pi: Difference between revisions

9,266 bytes added ,  2 years ago
→‎Python: new section
(→‎Time to delete: deleted, and more)
(→‎Python: new section)
 
(25 intermediate revisions by 9 users not shown)
Line 1:
==stopping the program==
Why "until a key is pressed"? That's an annoyingly non-portable construct. --[[User:Rdm|Rdm]] 22:20, 25 March 2011 (UTC)
 
Line 7 ⟶ 8:
 
I agree. There are computers without a keyboard, and special industrial keyboards with the break key removed. If there is no facility to terminate the process, then it should run for infinity for the purposes of this task. I have updated the wording to clarify this point.
 
: There are keyboards without a break key. Not all keyboards are hooked up to a PC or an ASCII computer. -- [[User:Gerard Schildberger|Gerard Schildberger]] 08:44, 27 March 2012 (UTC)
 
[[User:Markhobley|Markhobley]] 10:57, 26 March 2011 (UTC)
Line 54 ⟶ 57:
Hi Mark, I think it is time you just deleted the GUISS solution. Stating it generates the digits of Pi in sequence does not make it so, and the consensus is against you. --[[User:Paddy3118|Paddy3118]] 07:15, 25 July 2011 (UTC)
: It's been days, so I removed it. On a semi related note, there should be a way to discourage prople from translating the D (and Tcl/Icon/C#/Basic/etc) solution which only calculates a fixed number of digits when there are the Ada/ALGOL/Go solutions that can be translated. I'm very tempted to slap incorrect tags on them now. --[[User:Ledrug|Ledrug]] 22:11, 1 August 2011 (UTC)
:: I'm not sure he'll be back. I think he's been scared off. --[[User:Short Circuit|Michael Mol]] 03:10, 2 August 2011 (UTC)
::: Nm; I see he's been doing some minor edits today. --[[User:Short Circuit|Michael Mol]] 03:15, 2 August 2011 (UTC)
 
== Task split ==
Line 64 ⟶ 69:
:::Hm. It might be worth scrapping the task and creating more defined ones, such as [[Pi/Bailey-Borwein-Plouffe]], and leave the "Pi/" namespace available to other specific implementations.--[[User:Short Circuit|Michael Mol]] 15:03, 26 July 2011 (UTC)
:::[[Pi]] can be implemented without use of a spigot algorithm regardless of efficiency, because that algorithm is not good at being efficient at all. The C program I wrote continuous generates Pi digits faster than the unbound spigot, despite the algorithm used was totally unsuitable for the task. --[[User:Ledrug|Ledrug]] 00:07, 27 July 2011 (UTC)
:I would favour leaving the task as it is (but with the impossible requirement to continue 'forever' replaced with something like 'until resources are exhausted'). Specifying only that the digits are generated 'in succession' gives a choice between using an unbounded Spigot algorithm (which requires support for arbitrary-precision arithmetic) and a 'bounded' algorithm configured to use all the available memory (which better suits languages with fixed-size integers). Whichever approach is used, the number of digits that can be generated is limited by memory size. [[User:RichardRussell|RichardRussell]] 14:37, 12 November 2012 (UTC)
::::If we create more defined tasks, we might want to consider using [http://tauday.com tau] instead of Pi. --[[User:Rdm|Rdm]] 12:57, 1 August 2011 (UTC)
 
:::::Ugh. Can we not have that debate here? The ''only'' significant difference between pi and tau is the impact they may have on the readability and intuitive extrapolation of formulas. I see enough difficulty agreeing on task spec as is, and pi vs tau is not clearly resolvable. For the time being, I would far prefer to stick with pi, as that's the most common and mass way of representing the number, and so that's what people are more likely to recognize and understand. When [http://googlefight.com/index.php?&word1=pi&word2=tau tau beats pi by a 2:1 margin], I might be more interested. --[[User:Short Circuit|Michael Mol]] 14:21, 1 August 2011 (UTC)
== C# - incorrect solution ==
::::::That's not exactly an argument on merits. And there's no reason for the use of tau to exclude the use of pi any more than the use of the number 1 excludes the use of the number 0.5. That said, if googlefight meant anything to me, I might use a smaller set of numbers? --[[User:Rdm|Rdm]] 19:58, 1 August 2011 (UTC)
The C# version produces output where only first 30% is correct, then goes garbage. For example, here's what it outputs when asked for 50 digits:
:::::::No, it's not an argument on the merits. The best thing I've read on the merits of the subject is [http://esr.ibiblio.org/?p=3481 here], and all that tells me is that we don't know which is really better than the other. The trouble with pi vs tau on RC is that your average ''non''-mathematician isn't yet likely to be familiar with tau, and so using tau in tasks is very likely to confuse what should be a simple subject; to resolve the confusion, use of tau would need annotations like "tau is 2*pi", and that would strike me as too trivial to warrant further complicating the task description. In short, even if we posit tau to be a more elegant symbol than pi, right ''now'', it's not a more elegant way to write task descriptions. --[[User:Short Circuit|Michael Mol]] 21:07, 1 August 2011 (UTC)
3141592653589792800649014751202138549699509907712322 while correct digits are
::::::: But there's no exact arguments on merits. Tau vs Pi is really a matter of radius vs diameter of a circle, and you can't argue which is of more merit than the other. A well defined constant should convey most symmetry or invariance of a system, where radius is arguably better because one end of r is always at the origin--but in real world diameters are almost always easier to measure: try directly tell the radius of a ball bearing with a caliper. In any event, for calculating digits of pi, the tau debate is not even relevant, where the most useful constant is probably Pi/4 any way. --[[User:Ledrug|Ledrug]] 21:55, 1 August 2011 (UTC)
3141592653589793238462643383279502884197169399375105.
The D version which uses similar but slightly different algorithm is correct.
--[[User:thedeemon|thedeemon]] 24 October 2012
 
 
: I split the two above values of &nbsp; <big><big><math>\pi</math></big></big> &nbsp; (sans a decimal point) &nbsp; so that it can be easily compared, and I also added an up arrow &nbsp; (↑) &nbsp; indicating to the unequal (different) decimal digit. &nbsp; I realize that (normally) editing other people's edits are frowned on and considered a no-no, &nbsp; but the intent is to easily compare two different values of &nbsp; <big><big><math>\pi</math></big></big>. &nbsp; &nbsp; -- [[User:Gerard Schildberger|Gerard Schildberger]] ([[User talk:Gerard Schildberger|talk]]) 09:45, 24 September 2018 (UTC)
 
== Pi vs tau ==
::::If we create more defined tasks, we might want to consider using [http://tauday.com tau] instead of Pi. --[[User:Rdm|Rdm]] 12:57, 1 August 2011 (UTC)
:::::Ugh. Can we not have that debate here? The ''only'' significant difference between pi and tau is the impact they may have on the readability and intuitive extrapolation of formulas. I see enough difficulty agreeing on task spec as is, and pi vs tau is not clearly resolvable. For the time being, I would far prefer to stick with pi, as that's the most common and mass way of representing the number, and so that's what people are more likely to recognize and understand. When [http://googlefight.com/index.php?&word1=pi&word2=tau tau beats pi by a 2:1 margin], I might be more interested. --[[User:Short Circuit|Michael Mol]] 14:21, 1 August 2011 (UTC)
::::::That's not exactly an argument on merits. And there's no reason for the use of tau to exclude the use of pi any more than the use of the number 1 excludes the use of the number 0.5. That said, if googlefight meant anything to me, I might use a smaller set of numbers? --[[User:Rdm|Rdm]] 19:58, 1 August 2011 (UTC)
:::::::No, it's not an argument on the merits. The best thing I've read on the merits of the subject is [http://esr.ibiblio.org/?p=3481 here], and all that tells me is that we don't know which is really better than the other. The trouble with pi vs tau on RC is that your average ''non''-mathematician isn't yet likely to be familiar with tau, and so using tau in tasks is very likely to confuse what should be a simple subject; to resolve the confusion, use of tau would need annotations like "tau is 2*pi", and that would strike me as too trivial to warrant further complicating the task description. In short, even if we posit tau to be a more elegant symbol than pi, right ''now'', it's not a more elegant way to write task descriptions. --[[User:Short Circuit|Michael Mol]] 21:07, 1 August 2011 (UTC)
::::::: But there's no exact arguments on merits. Tau vs Pi is really a matter of radius vs diameter of a circle, and you can't argue which is of more merit than the other. A well defined constant should convey most symmetry or invariance of a system, where radius is arguably better because one end of r is always at the origin--but in real world diameters are almost always easier to measure: try directly tell the radius of a ball bearing with a caliper. In any event, for calculating digits of pi, the tau debate is not even relevant, where the most useful constant is probably Pi/4 any way. --[[User:Ledrug|Ledrug]] 21:55, 1 August 2011 (UTC)
::: That http://esr.ibiblio.org/?p=3481 argument (and the pi manifesto it referenses) suggests that this whole thing is just about conciseness, and not about some of the other issues (like constant 1/2 in simple r^2 equations and 1/6 in simple r^3 equations). I can understand that conciseness has advantages, and I also agree that pi's familiarity/popularity can be a major advantage in a cookbook equation context. Anyways, the "pi is wrong" slogan, while catchy and motivating is itself wrong. "Pi is useful, but pi can also occasionally be misleading or confusing" would be a more accurate (though boring) phrasing. There's room in the world for both constants, and I dislike reasoning (even from its advocates) that suggest that there can be only one. And "tau is 2*pi" is simple, but too trivial? We have "Goodbye, world" here. And, 99 bottles of beer -- how can "tau is 2*pi" be too trivial? (Though, ok, I can understand not wanting to like to a "pi is wrong" page.) --[[User:Rdm|Rdm]] 11:48, 2 August 2011 (UTC)
:::: First, "constant 1/2 in simple r^2 equations" and "1/6 in simple r^3 equations" are ''exactly'' questions of conciseness; which is more concise? <math>\frac{1}{2}\pi r^2</math> or <math>\tau\pi</math>? For these equations, <math>\tau</math> is easily more concise. (And this is the area of debate I really wanted to avoid)--[[User:Short Circuit|Michael Mol]] 13:37, 2 August 2011 (UTC)
::::: Ok, yes, that can be a question of conciseness. But it's also a simplicity issue and, thus, a mnemonic issue. It's the same reasoning behind the coefficients in a taylor series. For the n-space analog of area of an n-space analog of a sphere, the equation would be <math>\scriptstyle 2\pi x^n \div n! \equiv \tau x^n \div n! </math>. By optimizing for second degree equations you obscure the simplicity of the issue for every other degree. And optimizing for second degree equations can be the right thing to do, in some contexts, but not for all contexts. Meanwhile, I am uncomfortable talking with someone on a subject that they say they do not want to talk about, but I am also uncomfortable leaving alone the issues that you bring up. --[[User:Rdm|Rdm]] 14:38, 2 August 2011 (UTC)
::::: Curiously, I think we're in total agreement in {{pi}} vs {{tau}}. Level of knowledge of the reader being equal, it really does depend on the use case which representation of the value is more appropriate. As in all non-trivial things, the answer to "which is better" is "it depends..." --[[User:Short Circuit|Michael Mol]] 16:05, 2 August 2011 (UTC)
:::: Second, I was far more concerned about scenarios involving geometric tasks which chose to use {{tau}} rather than {{pi}}, as each of those tasks would need to note how to derive {{tau}} from {{pi}}, which would complicate them. (A trivial complication yes, but still a reduction in their simplicity)--[[User:Short Circuit|Michael Mol]] 13:37, 2 August 2011 (UTC)
:::: Third, I really wouldn't mind a [[Pi/Pi and Tau]] which showed how convert from pi to tau and back. That kind of triviality isn't something that bothers me, though it may tend to bother contributors who are completeness-driven. --[[User:Short Circuit|Michael Mol]] 13:37, 2 August 2011 (UTC)
: I prefer <math>\pi</math>, because of [[wp:Euler's identity|Euler's awesome identity]]:
:: <math>e^{i\pi} + 1 = 0</math>
: That is an amazingly significant formula, “simply” linking 5 of the key constants into one piece. There is no way that <math>\tau</math> would work nearly so well in it; it's not coupled to the transcendental functions in such a direct fashion. (Also, you use <math>\pi</math> directly when working with circular areas, and neither <math>\pi</math> nor <math>\tau</math> is great for spherical volumes or their equivalents in higher dimensions.) –[[User:Dkf|Donal Fellows]] 21:28, 11 February 2012 (UTC)
:: Well, of course -- if you replace the terms in the equation with something different, you need to change the equation if you want the result to be valid. That's just basic math. In this case, a valid pair of changes are: "replace pi with tau (or vice versa)" and "swap the positions of the + and the =". In other words: '''<math>e^{i\tau} = 1 + 0</math>'''. You might also want to swap <math>i</math> and <math>\tau</math> depending on the font you are using (<math>e^{\tau i} = 1 + 0</math>), but multiplication is commutative with complex numbers, so that will not change the equation's validity.
:: As for the general case of n dimensions... I was going to look that up, but currently wikipedia says that the proportionality constant for volume of a [[wp:N-sphere|hypersphere]] is <math>V_n (R) = C_n R^n</math> where <math>C_n = \frac{\pi^\frac{n}{2}}{\Gamma(\frac{n}{2} + 1)} \,</math> but that gives the same result for <math>C_n</math> for both n=2 and n=3 so it can't be right. So, for now, I will take your word that it gets messy. It's been ages since I thought about this issue. Still, as motivation for a task? I do not think that we exclude tasks based on this kind of mathematical popularity issue... --[[User:Rdm|Rdm]] 16:34, 12 February 2012 (UTC)
 
== Julia Output ==
 
I'm not sure there's necessarily anything wrong with the code, so I didn't want to mark it incorrect, but the output for the Julia sample is clearly wrong - there are several places in the sequence where the character 'e' appears. Is there a more appropriate template that can be used to mark it as needing attention. I'm not a Julia programmer myself, so it's not something I can easily confirm as correct or incorrect. --[[User:J4 james|j4_james]] ([[User talk:J4 james|talk]]) 16:47, 3 October 2015 (UTC)
 
 
== Formula for JAVA ==
By what formula did you calculate pi in JAVA? I searched hard in wikipedia, and found nothing this good. What formula do you use?
 
Also - the first 50 digits are exact - but is the whole formula exact? Or is it diverges after some digits? [[User:DeatH StaR|DeatH StaR]] ([[User talk:DeatH StaR|talk]]) 20:55, 13 October 2016 (UTC)
 
== pascal ==
when i compile i get: Error: Identifier not found "result"
 
=== different output ===
i solved the above problem by adding oneloop:=result before the end of the function but:
when i run the program to calculate thousand digits of pi i get an output with the last digits 62429841642 which is completely different from the output published at the wiki page.
 
== my password ==
My password is the last 8 digits of &nbsp; <big><big><math>\pi</math></big></big>. &nbsp; &nbsp; &nbsp; &nbsp; -- [[User:Gerard Schildberger|Gerard Schildberger]] ([[User talk:Gerard Schildberger|talk]]) 13:29, 29 November 2019 (UTC)
 
 
=== Happy Pi Day! ===
--[[User:Xdv|xarilaos]] ([[User talk:Xdv|talk]]) 14:31, 14 March 2022 (UTC)
 
== javascript ==
 
webpage version is working!
(Note for javascript developers: please provide webpage versions, we are not professionals.)
 
== Java ==
 
It works!--[[User:Xdv|xarilaos]] ([[User talk:Xdv|talk]]) 14:04, 15 March 2022 (UTC)
 
== Python ==
 
It works!--[[User:Xdv|xarilaos]] ([[User talk:Xdv|talk]]) 14:06, 15 March 2022 (UTC)
Anonymous user