Questions tagged [pi]

π (pi) is a mathematical constant whose value is the ratio of any Euclidean plane circle's circumference to its diameter; this is the same value as the ratio of a circle's area to the square of its radius. It is approximately equal to 3.14159265 in decimal notation. For Raspberry Pi, please tag with "raspberry-pi".

π (pi) is a mathematical constant whose value is the ratio of any Euclidean plane circle's circumference to its diameter; this is the same value as the ratio of a circle's area to the square of its radius. It is approximately equal to 3.14159265 in decimal notation.

For questions related to Raspberry Pi, please use the tag instead.

811 questions
-1
votes
2 answers

Leibniz formula for pi - Java

So, Leibniz's formula for pi is pi/4 = 1 - 1/3 + 1/5 - 1/7 + 1/9... I can't figure out how to use this formula in Java. I just need some help on how to incorporate the second part into it. I know I need a loop and I need the have a divisor…
Zach Fortney
  • 39
  • 1
  • 2
  • 2
-1
votes
1 answer

PHP If else solution

Can it works with this if else or can't i write it so? I need help with the if and else Problem. So can i write if² than if³ and than else³ and else². '; }else { …
Tobias
  • 1
  • 1
-1
votes
1 answer

When I try to map out pi in colors with ChunkyPNG, I get many unexpected results

I am trying to calculate pi and put it into a picture in ruby. It works up until lines 36 (where it doesn't write pi [without a decimal place] to file) and 63 (where it only writes the off white color to pi.png). As a side note, the program doesn't…
Jake L.
  • 19
  • 6
-1
votes
1 answer

Finding a large number of decimal places for irrational number in java

I want to find the value of 22/7 to 10^6 places of decimals in java. Is it possible to do this within a short compile time?
Abhiroop Sarkar
  • 2,251
  • 1
  • 26
  • 45
-1
votes
2 answers

Understanding Mathematical Formula in Java

Im just trying to get back into the way of programming in the Java language after having a rather large break so I decided to write a program that calculates PI to the users input number: e.g. they enter 5, it would return 3.14159. I've come…
Katana24
  • 8,706
  • 19
  • 76
  • 118
-2
votes
1 answer

Function to approximate the value of pi with newton/euler convergence transformation

I am currently working on an exercise where I have to use the sum in the picture to approximate pi. . I have to prompt the user for an integer m which will be the number of terms used to do the calculation. I cannot use any functions from the math…
lolamay
  • 11
-2
votes
1 answer

how to increase number of floating points in python

I need to calculate 100 floating points of phi φ it's defeat showing only 15 floating points but I need 100 of floating points.is there an easy way rather than implement pHi from beginning
-2
votes
1 answer

Calculate the first n digits of pi?

Hi i am trying to code Calculate the first n digits of pi using System; using System.Numerics; namespace PiCalculator { class Program { static void Main(string[] args) { System.Decimal.Precision =…
EGO
  • 9
  • 1
-2
votes
2 answers

Pi estimation using sphere volume

My task is to calculate the approximate value of pi with an accuracy of at least 10^-6. The Monte Carlo algorithm does not provide the required accuracy. I need to use the calculation only through the volume of the sphere. What do you advise? I…
Asan
  • 13
  • 1
-2
votes
1 answer

Tried to implement the Nilakantha algorithm in python

import math from decimal import * pi = Decimal(3) two = 2 three = 3 four = 4 times = 10000 for c in range(times): pi += Decimal(4)/two * three * four pi -= Decimal(4)/two + 2 * three + 2 * four + 2 * three two += 2 three += 2 …
-2
votes
2 answers

Approximate pi using series

def approximate_pi(): EPSILON = 1.0e-7 term = 1 n = 0 sum_pi = 0 while term > EPSILON: term = 4 * (((-1) ** (n)) / (2 * n + 1)) sum_pi += term n += 1 print(float(round(sum_pi,10))) This is the code I…
-2
votes
1 answer

My pi approximation using the wallis' method doesn't work and I have no idea what's going on

I'm working in Python 3.7 and part of my assignment is to define Wallis' approach to approximating pi. I'm a maths student, not cut out for doing computer science and could really use some help, this is worth 40% of my grade in total and I can't do…
TomGG98
  • 3
  • 2
-2
votes
1 answer

Binary Matrix Reduction in CUDA

I have to traverse all cells of an imaginary matrix m * n and add + 1 for all cells that meet a certain condition. My naive solution was as follows: #include __global__ void calculate_pi(int center, int *count) { int x = threadIdx.x; …
-2
votes
2 answers

python3 calculate N digits of PI python cut the long number

i need to write a script that get input from client of an number and i need to print back the PI number until client number for example: client number is 52 --> 3.14159265358979323846264338327950288419716939937510 so far i write this: sum = 0 for i…
dor
  • 29
  • 5
-2
votes
2 answers

How convert user inputted constant (pi,e) to float in python?

I'm writing a code which must compute definite integral of a function. I'll provide code in the below. How can I urge computer to understand user input "pi" or "e" for constant numbers? Problem is that I must convert the type of input to float, for…
Mher Khachatryan
  • 35
  • 1
  • 1
  • 5