I have my code doing some math and i have done it by hand, with wolfram, and excel excel didn't match any of the calcs therefore i gave up with that but my hand calcs were close to wolfram therefore im assuming discrepancies were due to rounding
all the numbers going in are the same as the numbers i use by hand and i have checked to make sure!!
here is the subroutine that does the calc
where for the first loop that im checking against
17.5 data[0][0]
-0.27266 f2
-0.05599 f4
-0.2613 f22
-0.0484 f44
the answer for the first loop is = 0.970543 = submod
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
void wmodel ( double model[], double f2, double f4, double f22 ,
double f42, double (*data)[3], int l){
//this function does the w(theta) calculation for the model
int x;
for (x=0 ; x < l ; ++x){
model[x] = 1 + (f2*f22*1/2*(3* pow(cos(data[x][0]),2) -1 ) )
+ (f4*f42* 1/8*(35*pow(cos(data[x][0]),4)
- 30 *pow(cos(data[x][0]),4) + 3));
cout << model [x] << " submod"<< endl;
}
The Wolfram page has the note: "Assuming trigonometric arguments in degrees".
Your code is doing the calculations using radians. All the trigonometric functions use radians for input or result values. If you want to treat the angles as degrees rather than radians, you need to convert them yourself.
Multiply the value in degrees by the conversion factor PI/180 to give the angle expressed in radians.