| | |
help needed to compute maclaurin series using c
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Jul 2008
Posts: 20
Reputation:
Solved Threads: 0
Hi, this is the algorithm to calculate pi,
Pi = 4-4/3+4/5-4/7+4/9...= 4*((-1)^n+1)/2n-1
It's very similar to your need
I hope I helped you
BTW… the delta must be les then zero
Pi = 4-4/3+4/5-4/7+4/9...= 4*((-1)^n+1)/2n-1
It's very similar to your need
C Syntax (Toggle Plain Text)
#include<stdio.h> #include<math.h> int main() { float delta; //precision float pi=0,temp; int n=1; scanf("%f",&delta); do { temp = (pow(-1.0,n+1)/(2*n-1)*4); pi+=temp; n+=1; if (temp<0) temp*=-1; }while (temp>delta); printf("%f",pi); return 0; }
BTW… the delta must be les then zero
Last edited by stewie griffin; Jul 25th, 2008 at 9:33 am.
![]() |
Other Threads in the C Forum
- Previous Thread: Do i need a better compiler?
- Next Thread: Quadratic Formula
Views: 2272 | Replies: 10
| Thread Tools | Search this Thread |
Tag cloud for C
#include * .net append array arrays asterisks binarysearch calculate changingto char character cm command copyimagefile cprogramme creafecopyofanytypeoffileinc database directory dynamic execv feet fgets file fork forloop framework function functions givemetehcodez grade graphics gtkwinlinux hacking histogram homework include incrementoperators input intmain() iso kernel keyboard km lazy license linked linkedlist linux list lists locate logical_drives looping loopinsideloop. lowest matrix microsoft mqqueue mysql number oddnumber odf opensource overwrite owf pdf performance pointer pointers posix probleminc process program programming radix recursion recv recvblocked research reversing scanf scripting segmentationfault sequential socket spoonfeeding standard string student systemcall testing threads turboc unix user variable wab whythiscodecausesegmentationfault windowsapi





