I have a finite series that looks like this:

$f(t) = \sum^n_{i=0} A_i cos(\Theta_i + \omega_i t) + B_i sin(\Theta_i + \omega_i t)$

That is, a finite series of pairs of phasors.

What's the state of the art for numerically calculating the value of the series at a given $t$? I'm interested in numerically finding the root of this series, so it's important to minimize numerical inaccuracies, particularly around the zeroes.

Just naively performing the cosine and sine calls produces a lot of numerical noise, which causes my root finding to fail. I've built up a solution that works using Kahan summation and various trig identities (see this), but it's really, really slow.

The N I have is not very large, so an answer doesn't have to necessarily scale well to more terms.

If anyone knows any links or papers that are relevant I'd appreciate it.

  • 1
    $\begingroup$ You could simplify the same frequency terms using $R_i=\sqrt{A_i^2+B_i^2}$, $A_i=\cos(\Phi_i)$, $B_i=\sin(\Phi_i)$, to obtain summands (addens) $R_i\,\cos(\Theta_i-\Phi_i+\omega_i t)$. $\endgroup$ Dec 29 '13 at 17:53
  • $\begingroup$ @LutzL That's my current line of thinking, but you still have to be careful trying to evaluate $R_i cos(\pm \epsilon)$ for $\epsilon$ close to 0, since you'll lose precision. I'm hoping there's a nice article somewhere that will confirm what I already know and explore what I don't :) $\endgroup$
    – Jay Lemmon
    Dec 29 '13 at 21:58
  • $\begingroup$ Yes, that cannot be avoided, it only reduces the effort by 1/2. The underlying problem in the other thread was that you were computing a root with multiplicity 2, i.e., a minimum on the t-axis. To reliably catch those roots you have to compute the roots of the derivatives and check their function values. And probably also the values of the second derivative to see if the parabolic approximation opens towards the t-axis or away from it. $\endgroup$ Dec 29 '13 at 22:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.