Question: Write a program to estimate pi by the above series using the Newton-Raphson sequence to calculate the square root factor. Use the code in java
Write a program to estimate pi by the above series using the Newton-Raphson sequence to calculate the square root factor.
Use the code in java to write it in jasmin code . jfile, use the Java code below. Simple code thanks
public class FastestPIest { public static void main(String[] args){
// First term of series is initialized in pi double pi=1, numerator=1, denominator=1; // Calculate sum for(int k=1;k<25;k++){ numerator *= k; denominator *= (2*k)*(2*k+1); pi += numerator * numerator / denominator; } // calculate sqrt(6.75) double s=6.75, sqrt_s=2; for(int i=0;i<5;i++) sqrt_s = .5*(sqrt_s + s/sqrt_s); // Print pi estimate pi *= sqrt_s; System.out.println(pi); } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
