pi Questions
3
Solved
how do you overwrite the previous print in python 2.7?
I am making a simple program to calculate pi. here is the code:
o = 0
hpi = 1.0
i = 1
print "pi calculator"
acc= int(raw_input("enter accurac...
Hypoploid asked 25/3, 2012 at 13:55
9
Solved
One of the challenges on w3resources is to print pi to 'n' decimal places. Here is my code:
from math import pi
fraser = str(pi)
length_of_pi = []
number_of_places = raw_input("Enter the number...
3
Solved
I could not find any information about mathemtical constants in the Tensorflow API
neither in Basic Math functions nor in Math Ops.
I was able to get it by
import math as m
pi = tf.constant(m.pi...
Committal asked 1/9, 2017 at 7:44
3
Solved
I came across some weird behavior by math.cos() (Python 3.11.0):
>>> import math
>>> math.cos(math.pi) # expected to get -1
-1.0
>>> math.cos(math.pi/2) # expected to get...
Cobwebby asked 26/2, 2023 at 1:35
3
Solved
23
Solved
I'm looking for the fastest way to obtain the value of π, as a personal challenge. More specifically, I'm using ways that don't involve using #define constants like M_PI, or hard-coding the number ...
Yacano asked 1/8, 2008 at 5:21
6
Solved
I'm trying to add a repository to ppa with the add-apt-repository commands but the _gi module from Python is not found.
I did this command : sudo add-apt-repository ppa:s-mankowski/ppa-kf5
Here i...
1
I recently made a Pi calculator in Java and when I run it, it defines Pi down to the same amount incredibly fast but then it gets stuck at 3.141592653589787 and only outputs that. Here's my code if...
6
Solved
I tried to use this code to calculate pi to many decimal places:
def pi():
pi = 0
for k in range(350):
pi += (4./(8.*k+1.) - 2./(8.*k+4.) - 1./(8.*k+5.) - 1./(8.*k+6.)) / 16.**k
return pi
...
11
Solved
How can I write a function which will return pi (π) to a given number of decimal places?
Speed is not a concern. I've been looking at http://bellard.org/pi/, but I still don't understand how to ge...
2
Solved
I'm looking to compute the nth digit of Pi in a low-memory environment. As I don't have decimals available to me, this integer-only BBP algorithm in Python has been a great starting point. I only n...
6
Solved
I was trying various methods to implement a program that gives the digits of pi sequentially. I tried the Taylor series method, but it proved to converge extremely slowly (when I compared my result...
Lysol asked 11/1, 2013 at 17:15
3
Solved
I have always wanted to find an algorithm that did this. I do not care how slow it is, just as long as it can return the nth digit of Pi:
ex:
size_t piAt(long long int n)
{
}
Preferably, not us...
5
Solved
I have written a function that takes in a long long value n and uses that as the number of iterations to go through. The function should give a good estimate of pi, however, all the values for larg...
Kraus asked 13/3, 2019 at 18:19
4
Solved
Is there a way to calculate pi in Javascript? I know there you can use Math.PI to find pie like this:
var pie = Math.PI;
alert(pie); // output "3.141592653589793"
but this is not accurate. What ...
Stygian asked 10/6, 2015 at 4:40
2
How can you display pi superscript if it's not in Unicode? It's for a javascript program I'm making. I can't think of any way around it.
Thrombophlebitis asked 19/4, 2020 at 14:16
1
Solved
What's the most accurate rational pair for Pi representable with two 64 bit integers? Feel free to include other int types if you'd like.
Here's what I came up with, but I'm sure it can get more ac...
11
Solved
I have been thinking about this issue and I can't figure it out. Perhaps you can assist me. The problem is my code isn't working to output 1000 digits of pi in the Python coding language.
Here's ...
3
Solved
I have U and V wind component data and I would like to calculate wind direction from these values in R.
I would like to end up with wind direction data on a scale of 0-360 degrees, with 0° or 360° ...
1
Solved
I do understand why we have this in standard headers:
#define M_PI 3.14159265358979323846 // pi
However, I don't see much benefit in having these:
#define M_PI_2 1.57079632679489661923 //...
3
Solved
The hash of infinity in Python has digits matching pi:
>>> inf = float('inf')
>>> hash(inf)
314159
>>> int(math.pi*1e5)
314159
Is that just a coincidence or is it inte...
Nathanialnathaniel asked 20/5, 2019 at 20:0
3
Solved
I am a python beginner and I want to calculate pi. I tried using the Chudnovsky algorithm because I heard that it is faster than other algorithms.
This is my code:
from math import factorial
from...
1
Solved
In R I have written this function
ifun <- function(m) {
o = c()
for (k in 1:m) {
o[k] = prod(1:k) / prod(2 * (1:k) + 1)
}
o_sum = 2 * (1 + sum(o)) # Final result
print(o_sum)
}
This f...
Millimicron asked 5/8, 2018 at 11:20
20
Solved
How can I calculate the value of PI using C#?
I was thinking it would be through a recursive function, if so, what would it look like and are there any math equations to back it up?
I'm not too f...
6
Solved
What is the motivation for defining PI as
PI=4.D0*DATAN(1.D0)
within Fortran 77 code? I understand how it works, but, what is the reasoning?
1 Next >
© 2022 - 2025 — McMap. All rights reserved.