An inverse Fibonacci algorithm?

Since OP has asked about matrix solution not involving any floating point computations, here it is. We can achieve O(logn) complexity this way, assuming numeric operations have O(1) complexity. Let’s take 2×2 matrix A having following structure 1 1 1 0 Now consider vector (8, 5), storing two consecutive fibonacci numbers. If you multiply it … Read more

What is the fastest way to compute sin and cos together?

Modern Intel/AMD processors have instruction FSINCOS for calculating sine and cosine functions simultaneously. If you need strong optimization, perhaps you should use it. Here is a small example: http://home.broadpark.no/~alein/fsincos.html Here is another example (for MSVC): http://www.codeguru.com/forum/showthread.php?t=328669 Here is yet another example (with gcc): http://www.allegro.cc/forums/thread/588470 Hope one of them helps. (I didn’t use this instruction myself, … Read more