I have to convert voltage measure (Volt) into power (Watt). As you know, the physics says I need to square the voltage measure.

I have to calibrate the mathematical law and I have two points:

0W -> 0V ->That could be enough, but we noticed a different relation between volt and watt at intermediate points. I, as the software engineer, have to try to compensate differences from the theory, without increasing complexity during calibration.

My idea is to calibrate the exponent: it is normally 2.00, but I can calibrate from 1.00 to 3.00. In this way, the two old calibration points are the same as before. So the exponent (the third calibration measure) can be changed at last.

The problem is pow() function with double arguments takes a lot of time to finish. Do you suggest a mathematical method to reduce its complexity?

uint16_t power_nominal = 1500; // In Watt uint16_t volt_nominal; // Volt measured at nominal power signed uint8_t exp_corr = -100 to +100; double exp = 2.00 + exp_corr;

uint16_t volt = adc_convert(...); // Actual volt measure double alpha = (double)power_nominal / pow((double)volt_nominal, exp); uint32_t watt = alpha * pow((double)volt, exp);

alpha can be pre-calculated, because power_nominal, volt_nominal and exp are constant (after calibration). The last instruction is the problem.