Cost function calculating best coefficient why differentiate then integrate to equal zero

12 Views Asked by At

My question when trying to find an optimum values of the coefficient to approximate a function.why do they take the derivative of the squared function before integrating it. whats the slope function and area have to do with best fit equals zero.

Example : x(t) a periodic pulse function. to be approximated by g(t)=A*cos(wt) and A is the coefficient we trying to find.

I understand the error should be close to zero so e(t) = x(t) - g(t) = 0 . then taking the average power with integration from 0-T with T being the fundamental period integral(|(x(t) - g(t))|^2) = 0. Why do that...the derivative gives the slope and integrating it gives the area over the period? and they square it be positive does that not change the function and the absolute value/magnitude is for complex numbers am guessing why. Thanks for the help