fast approximate algorithm of phase for complex numberhttps://www.microchip.com/forums/(c) Microchip30Re: fast approximate algorithm of phase for complex number (Maple)Thx you guys!<br/>I found your suggestion is very useful, I will try both of your advice and see!<br/>https://www.microchip.com/forums/FindPost/1158887Thu, 26 Nov 2020 07:36:46 GMTRe: fast approximate algorithm of phase for complex number (1and0)For comparison, the first-order formula suggested by oliverb<br><br> z = y/x<br><br> arctan(z) = (pi/4) * z<br> <br>takes one division and one multiplication but with a worst case error of ~4°.<br><br>As always, higher order polynomials usually result in better approximation.<br/>https://www.microchip.com/forums/FindPost/1158432Fri, 20 Nov 2020 04:25:01 GMTRe: fast approximate algorithm of phase for complex number (1and0)<blockquote class="quote"><span class="original">grchy</span><br/>Does anyone can share some fast approximate algorithms of phase estimation? (Given the actual phase range is [-45°, 45°]<br></blockquote><br>For the range of [-45°, 45°] |y| <= x, so -1 <= y/x <= 1. One arctan approximation is<br><br> z = y/x<br><br> arctan(z) = z * [(pi/4 + 0.273) - 0.273 * abs(z)]<br><br>which takes one division, two multiplications, and one subtraction. A quick spreadsheet shows a worst case error of ~0.2° for that range.<br><br>Of course, this will have to be scaled for the Q15 format; i.e. 0x0000 is 0 radians, 0x8000 is pi radians, and 0xFFFF is almost 2*pi radians.<br/> <br/>https://www.microchip.com/forums/FindPost/1158417Thu, 19 Nov 2020 13:56:37 GMTRe: fast approximate algorithm of phase for complex number (oliverb)How much of an approximation can your application tolerate. Since you're working over a limited range you might start with Y/X, working in radians the error is 28% at the extremes. Then I suppose you could replace atan with some sort of look-up based approximation?<br/>https://www.microchip.com/forums/FindPost/1158371Thu, 19 Nov 2020 00:14:14 GMTfast approximate algorithm of phase for complex number (Maple)Hello everyone!<br/>I am using dsPIC33CK64MP506 MCU, XC16 compiler v1.41.<br/>I want to get feature data of a <b>fractcomplex</b>-type data, which are its magnitude and phase.<br/>I found build-in functions "_Q15sqrt"&"_Q15atanYByX" in <libq.h>, but it turns out <b>"_Q15atanYByX</b>" takes too much time to get the result for me(well <b>_Q15sqrt</b> is ok). Does anyone can share some fast approximate algorithms of phase estimation? (Given the actual phase range is [-45°, 45°])， THX in advance!<br/>https://www.microchip.com/forums/FindPost/1155941Thu, 22 Oct 2020 00:32:19 GMT