### Math not working properly compared to wolfram

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 calc done by wolfram :
http://www.wolframalpha.com/input/?i=%3D1%2B%28-0.27266+*-0.2613%2F2*%283*COS%2817.5%29%5E2-1%29%29+%2B+%28-0.05599*-0.0484%2F8*%2835*COS%2817.5%29%5E4-30*COS%2817.5%29%5E4%2B3%29%29

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

 ``12345678910111213141516`` `````` 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; } ``````
Last edited on
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.
THANK YOU SOOOOOOOOOO MUUCCCHHHH !!!!!
I will try this after my lunch break !
Last edited on
Topic archived. No new replies allowed.