Question

I'm trying to write this code that calculates pi using the adamchik series to a 10^-3...

I'm trying to write this code that calculates pi using the adamchik series to a 10^-3 precision. Something is wrong with it though and I cant seem to figure out how to get it to work. Any help?

def adamchik():
M=3
pi=3.1415926535897932384626433832795028841971
  
m=0
myAdamchik=1
while (abs(myAdamchik-pi)>(10**(-M))):
myAdamchik+=((4)/((8*n+1)))-((2)/((8*n+4)))-((1)/((8*n+5)))-((1)/((8*n+6)))*(pow((1)/((16)))
m+=1
return(m)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Pirat decimal place s g the number Pl ilh5o 9RC535 8 97 9323846асч338 327-... ratfonal and trans cendental Tt Ts an 1ts decim

Add a comment
Know the answer?
Add Answer to:
I'm trying to write this code that calculates pi using the adamchik series to a 10^-3...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I'm learning how to write loops in Python 3+ but need help in solving this function...

    I'm learning how to write loops in Python 3+ but need help in solving this function with another function: def babylonian_square_root(N, estimate, precision): new_estimate = (estimate + (N / estimate)) / 2 # I need to complete this using this function close_enough(). def close_enough(x, y, maximum_allowable_difference): ''' Returns True if x and y are within maximum_allowable_difference of each other. ''' # Note: "maximum" implies that we should use <= , but for this to work mathematically we need to use...

  • I'm trying to prove using the Virial theorem that the He+ atom has the energy of...

    I'm trying to prove using the Virial theorem that the He+ atom has the energy of E(He+) = -(1/2) * 2e^2 / (4*pi*e0*r) I can't seem to get it using PE = Q1*Q2 / (4 * pi*e0*r) and E = -(1/2) PE. Specifically I don't get where the 2 in front of e^2 comes from. Please help!

  • I'm taking a C programming class and I've been just playing around with the code (very...

    I'm taking a C programming class and I've been just playing around with the code (very beginner stuff!) and I was trying to figure out how to add something in the middle of a printf(). What I was trying to do was put a $ symbol in front of an amount while setting the width and precision at the same time, but I'm finding myself stumped and there's nothing in the textbook that discusses it. More just curiosity on my...

  • C++ question I'm trying to write a code that takes in n number of variables between...

    C++ question I'm trying to write a code that takes in n number of variables between 00 and 99. The program should be able to output the 1st and 2nd lowest digits as well as the highest and second highest digits. So if the input is 4 - 50 20 10 70 it should output 10 20 50 70. I think I've gotten the basic code but I can't seem to get the last digit to shift. #include <iostream> #include...

  • I'm trying to write a program that can ask a user about what type of solid...

    I'm trying to write a program that can ask a user about what type of solid they have and to be able to enter values like radius and length of the shape so the program can calculate the volume of a shape and print the result. I also want to give them a repeating option to input another shape if they want to. I'm trying to use at least 7 functions that can display an output, the volumes of a...

  • I'm trying to write in C++ a way to have the user input an double one...

    I'm trying to write in C++ a way to have the user input an double one at a time and have the program output (on entering 0) the number of times those variables differ by at least 1. For example if I enter 1, 1.7, 0.8, -0.1, -1, 0 ... I should get back 4. (or if I just input 0, the output should just be 0). I'm having trouble understanding how to use a while/for operation to make this...

  • I'm trying to model the velocity over time of a given time interval in python, but...

    I'm trying to model the velocity over time of a given time interval in python, but my code won't work. I need to solve the problem using the Euler method. import numpy as np from matplotlib import pyplot as plt def car(x0, v0, Cd, p, A, m, facc, T, dt): n = 0 t = np.arange(0, T, dt) x = np.array([x0]) v = np.array([v0]) while x[n] > 0: x = np.append(x, x[n]+v[n]*dt) v = np.append(v, v[n]+(facc/m-(1/(2*m))*Cd*A*p*v[n])*dt) t = np.append(t, t[n]+dt)...

  • I'm trying to solve this differential equations by using matlab and I've got a plot from the code attached. But...

    I'm trying to solve this differential equations by using matlab and I've got a plot from the code attached. But I wanna get a plot of completely sinusoidal form. If I can magnify the plot and expand x-axis, maybe we can get the sinusoidal form. So help me with this problem by using matlab. Example is attached in below. One is the plot from this code and another is example. function second_order_ode2 t=[0:0.001:1]; initial_x=0; initial_dxdt=0; [t,x]=ode45(@rhs,t,[initial_x initial_dxdt]); plot(t,x(:,1)) xlabel('t') ylabel('x')...

  • This is a MATLAB Question. Below is my base code for a Fourier Series of a...

    This is a MATLAB Question. Below is my base code for a Fourier Series of a half triangle wave. So I am being asked to isolate the first 8 components so that only those first 8 components of the half triangle function are calculated by MATLAB fft function, and then afterwards I am asked to do the same thing but with the first 20 components rather than the first 8. How do I isolate the first x number of components...

  • C. Execute the following statements in MATLAB: 1. A=3*5 2. A=2^10 3. A-abs(3 + i*4) 4.x=pi/2;...

    C. Execute the following statements in MATLAB: 1. A=3*5 2. A=2^10 3. A-abs(3 + i*4) 4.x=pi/2; A = 10*sin(x) 5.x=pi/4; A = 5*cos(x) 6. A=2*exp(4) 7. A=2*exp(i 2) 8. A-20*sin(pi/4)*exp(-2) C. Execute the following statements in MATLAB: 1. A=3*5 2. A=2^10 3. A-abs(3 + i*4) 4.x=pi/2; A = 10*sin(x) 5.x=pi/4; A = 5*cos(x) 6. A=2*exp(4) 7. A=2*exp(i 2) 8. A-20*sin(pi/4)*exp(-2)

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT