Hello,
I'm using teensy 4.1 for a project. The numbers are not exactly the same as what I expected. The code is below:
void setup() {
Serial.begin(115200);
delay(3000);
// put your setup code here, to run once:
double W[3] = {0.0,0.0,0.0};
double WN[3] = {0.0,0.0,0.0};
double DW[8][3]= {{1.656,4.0,11.0}, {2.4,5.0,4.0}, {3.54,7.0,8}, {4.64,44.0,8.0}, {0.0, 0.0, 0.0}, {0.0, 0.0, 0.0}, {0.0, 0.0, 0.0}, {0.0, 0.0, 0.0}};
double DATAX[4]= {1.656, 2.4, 3.54, 4.64};
double DATAY[4]= {4.0, 5.0, 7.0, 44.0};
double DATAZ[4]= {11.0, 4.0, 8.0, 8.0};
for (int i = 0; i < 4 ; i++) {
WN[2] = W[2] + (WN[0] * DATAY[i]) - (WN[1] * DATAX[i]) + DW[i][2];
WN[1] = W[1] + (WN[2] * DATAX[i]) - (WN[0] * DATAZ[i]) + DW[i][1];
WN[0] = W[0] + (WN[1] * DATAZ[i]) - (WN[2] * DATAY[i]) + DW[i][0];
W[0] = WN[0]; W[1] = WN[1]; W[2] = WN[2];
}
Serial.println(W[0],12);
Serial.println(W[1],12);
Serial.println(W[2],12);
My output is :
-17882300.276224978268
9608005.109401557594
2154463.437236570287
Whereas the expected output is:
-17882300.276224955916
9608005.109401546419
2154463.437236567959
How can I resolve this issue ?