1 Attachment(s)

Simplify expression for faster calculation

Is there any way to simplify the expression below? I want to calculate it many times in real time so speedier is better. What I really want is m, but it cannot be solved for, so I use a numerical method.

The simplification I can think of is to calculate recurring parts of the expression only once, like R-Sqrt[-1+R^2] and Tan[(-m+pi)/2]. But is there any trick to do with the five trigonometric functions in it? Four of them have the same parameter (-m+pi)/2, must I independantly calculate Tan, Csc and Sec for it, or are they connected in a simpler way?

http://i41.tinypic.com/54xiy1.jpg

Sec[x] is secant=1/Cos[x] and Csc[x] is cosecant=1/Sin[x].

The same expression in different formats if you want to copy it to Mathematica:

Re: Simplify expression for faster calculation

Hey Encircled.

One way that 3d video games used to do was use look-up tables where values would be stored in memory and the computation just looks them up when they need it. You might want to consider using this especially if you have limited values that can be put in memory (or a file that can be loaded into memory).

Apart from this, I'd suggest you look at things like a Taylor series expansion and other representations where you can evaluate a function with some known error that executes the code in a guaranteed number of clock cycles.

Hopefully you can build on these hints if need be.

Re: Simplify expression for faster calculation

Yes, a table could have sufficient precision and still be small enough, most of the time I can constrain the range of that m variable. If you have any kind of reference to that kind of method, I'd be grateful. Though it seems to be a simple enough concept to just improvise.

And thinking about it, calculating Sin[x] really takes no time nowadays, does it? Haven't ordinary CPU:s got hardware which does that in one or two clock cycles? I'm starting to realize that my expression is very trivial for computing power. It's benign to numerical methods, even the simple secant method narrows it down after just a handful of steps.

Re: Simplify expression for faster calculation

It's not just for the sine terms, but for all terms so that you get a table for arc-sine with varying values of m and R with whatever precision you need.