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 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...

  • I am trying to write this code which asks "Write a program that ask the user,...

    I am trying to write this code which asks "Write a program that ask the user, the question: What is a^b? //The program generates two signed integers and gives the user four attempts to get the correct answer //a=- , b = + //a= + , b = - " So far this what I wrote. I am not sure how to do this correctly. #include<iostream> #include<cstdlib> #include<ctime> using namespace std; int main() {    srand(time(0));    int guess,a,ans,b, k;...

  • Part 1: Exponential Fourier series The following MATLAB code calculates the exponential Fourier series coefficient for...

    Part 1: Exponential Fourier series The following MATLAB code calculates the exponential Fourier series coefficient for the signal x(t) shown in the figure below, plots it's double sided amplitude spectrum IDn l, double sided phase spectrem LDn, and the resulting signal xn(t). 4r 4a Periodic signal x(t) 1.1 Show that the complex Fourier Series Coefficients written as: D 1.2 Use the following Matlab to general the two sided spectral line. 1.3 Execute the Matlab code with To = 2π and...

  • 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')...

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
ADVERTISEMENT