Hi Everyone, For a couple weeks, I have been developing a pi approximation program and making little upgrades. Right now, the program asks for an input of iterations and then prints out the approximation. Now, I want to have every iteration printed out into an excel file with an approximation accurate to .000001 [50,000 iterations] However, I realized that the current setup of my program does not work well, so I think some rework is in order. So my goal is to eliminate the input process; and instead, base the iterations on accuracy, not input. That is what I would …

Member Avatar
Member Avatar
+0 forum 2

Hello, I have used taylor polynomials to approximate floating-point values before. I am wondering whether there is a way to still apply them to functions with complex arguments, and if there is a way what its constraints would be. For example, to calculate the sine of a floating-point number to a specific precision I keep adding terms until the error value is less than the precision. However, I noticed (by testing it with the taylor expansion of ln(x) ) that this gives the wrong value when I use complex numbers (with the standard operators appropriately defined). For example: ln(0.5)~=-(0.5+(0.5^2)/2+(0.5^3)/3) --- …

Member Avatar
Member Avatar
+0 forum 1

I'm trying to create a program that computes the values of cos using the Taylor Series as long as the absolute value of a term is greater than 0.0001 and prints the number of terms used in the series approximation. My code is the following and as of right now I am getting the wrong result. Please help me fix it! I've spent hours trying to figure it out and don't know what to do. Enter the angle in radians: 3.14 There were 8 numbers of terms used in the series approximation. The calculated cosine of 3.14 is 0.00499852 The …

Member Avatar
Member Avatar
+0 forum 12

A Python code example to find an approximate value for x in f(x) = 0 using Newton's method.

Member Avatar
Member Avatar
+2 forum 1

I have to wirte a code for monte carlo pi approximation for a menu driven calculator. here is my code but when i run it it shows me 1 instead of the pi value. can someone tel me what is wrong. double approximatepi(void) { double x,y,z,pi,randomnumber; double r,p,in; int tries; srand(0); while (tries!=p) {randomnumber=((double)rand())/((double)RAND_MAX)*2*r; x=randomnumber; y=randomnumber; z=r*r; pi=(((double)in/(double)p))*4; if (z>=x*x+y*y) {in++; } } return pi; }

Member Avatar
Member Avatar
+0 forum 2

[CODE] float i = 55 ; float y = 23 ; float u = i / y ; System.out.println(u); [/CODE] i want to print u Round to five decimal places how i can do this approximation ?

Member Avatar
Member Avatar
+0 forum 4

Im new to c++ and this is our first assignment. I dont even know where to start. Help! Your task is to write a main program which asks the user for an error value and then calls a function CalculatePi (error) which returns an approximate value of π. The function CalculatePi should use a loop to calculate the above series (*). It should keep two values, currentApproximation and nextApproximation. Initially currentApproximation = 4. The loop should keep adding and subtracting terms until the difference between currentApproximation and nextApproximation is less than error. It should then return currentApproximation.

Member Avatar
Member Avatar
-1 forum 1

This snippet generates the best rational approximations of a floating point number, using the method of continued fractions (tested with python 2.6 and 3.1).

Member Avatar
Member Avatar
+1 forum 4

Hi, I am developing some code to run on hardware and I am using the sin() and cos() functions inside the standard math.h many times, which slows the program down dramatically. I was wondering if there is a way to "approximate" the sine and cosine of a value (angle is between 0 and 2pi). Apparently there is a way to do it using look up tables but I don't really know how to create one? I would like to do it using just basic arithmetic operators, no math.h functions. Is there a simple way to compute the sine and cosine …

Member Avatar
Member Avatar
+0 forum 5

i need some help on my pi approximation it's really slow. compile it and see for your self. i think my problem is with my math. it comes out with the wrong first few numbers. i'm trying to use gregory's formula or the advanced version of it.[CODE]#include <iostream> #include <conio.h> using namespace std; void main() { long double ans=4,l=1; cout<<ans<<endl; for(int i=1;i<=100000000;i++) { l++; if(i % 2 == 1) { ans=(ans-1/(2*l +1)); } if(i % 2 == 0) { ans=(ans+1/(2*l+1)); } system("cls"); cout<< ans <<endl; } _getch(); }[/CODE]

Member Avatar
Member Avatar
+0 forum 1

The End.