Here is the problem
The Maclaurin series for arctan(x) is a formula which allows us to compute an approximation to arctan(x) as a polynomial in x. The formula is:
arctan(x) = x - x3/3 + x5/5 - x7/7 + x9/9 - x11/11 + . . .
Write a program which reads in a double x, and a positive integer k, and prints out the partial sum from the first k terms in this series.
Sample output
Enter x:
0.5
Enter integer k:
3
The partial sum from the first k terms: 0.4645833333333333
-------------------------------------------------------
Well, here are my codes
#include <iostream>
using namespace std;
int main()
{
double x, sum = 0.0;
int k;
//user input
cout << "Enter x: \n";
cin >> x;
cout << "Enter interger k: \n";
cin >> k;
sum = x - x3/3 + x5/5 - x7/7 + x9/9 - x11/11
cout << "The partial sum from the first k terms" << sum << endl;
return 0;
}
I got these errors when I tried to compile. Pls point out of what I did wrong, thank you!
Error E2451 lab42.cpp 19: Undefined symbol 'x3' in function main()
Error E2451 lab42.cpp 19: Undefined symbol 'x5' in function main()
Error E2451 lab42.cpp 19: Undefined symbol 'x7' in function main()
Error E2451 lab42.cpp 19: Undefined symbol 'x9' in function main()
Error E2451 lab42.cpp 19: Undefined symbol 'x11' in function main()
Error E2379 lab42.cpp 21: Statement missing ; in function main()
Warning W8004 lab42.cpp 24: 'sum' is assigned a value that is never used in function main()
*** 6 errors in Compile ***
**Mod Edit: added code tags:
This post has been edited by NickDMax: 24 September 2009 - 07:13 PM

New Topic/Question
Reply



MultiQuote







|