Results 1 to 4 of 4

Math Help - Simplify expression for faster calculation

  1. #1
    Newbie
    Joined
    Jan 2013
    From
    Sweden
    Posts
    23

    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?


    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:
    Spoiler:
    2 ArcSin[Sqrt[
    1 - (R - Sqrt[-1 + R^2])^2 Tan[
    1/2 (-m + \[Pi])]^2]/(\[Sqrt](1 + (-(R - Sqrt[-1 + R^2]) Sec[
    1/2 (-m + \[Pi])] +
    R Csc[1/2 (-m + \[Pi])] Sin[m])^2 - (R -
    Sqrt[-1 + R^2])^2 Tan[1/2 (-m + \[Pi])]^2))]


    2 \sin ^{-1}\left(\frac{\sqrt{1-\left(R-\sqrt{R^2-1}\right)^2 \tan ^2\left(\frac{\pi -m}{2}\right)}}{\sqrt{-\left(R-\sqrt{R^2-1}\right)^2 \tan ^2\left(\frac{\pi -m}{2}\right)+\left(R \sin (m) \csc \left(\frac{\pi -m}{2}\right)-\left(R-\sqrt{R^2-1}\right) \sec \left(\frac{\pi -m}{2}\right)\right)^2+1}}\right)


    2ArcSin[Sqrt[1-(R-Sqrt[-1+R^2])^2 Tan[1/2 (-m+\[Pi])]^2]/(\[Sqrt](1+(-(R-Sqrt[-1+R^2]) Sec[1/2 (-m+\[Pi])]+R Csc[1/2 (-m+\[Pi])] Sin[m])^2-(R-Sqrt[-1+R^2])^2 Tan[1/2 (-m+\[Pi])]^2))]
    Attached Thumbnails Attached Thumbnails Simplify expression for faster calculation-formula.jpg  
    Last edited by Encircled; November 15th 2013 at 11:52 PM.
    Follow Math Help Forum on Facebook and Google+

  2. #2
    MHF Contributor
    Joined
    Sep 2012
    From
    Australia
    Posts
    3,607
    Thanks
    591

    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.
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Jan 2013
    From
    Sweden
    Posts
    23

    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.
    Last edited by Encircled; November 16th 2013 at 01:59 AM.
    Follow Math Help Forum on Facebook and Google+

  4. #4
    MHF Contributor
    Joined
    Sep 2012
    From
    Australia
    Posts
    3,607
    Thanks
    591

    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.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. help simplify the expression
    Posted in the Calculus Forum
    Replies: 4
    Last Post: October 1st 2012, 05:44 PM
  2. simplify a qud expression
    Posted in the Algebra Forum
    Replies: 6
    Last Post: March 31st 2012, 02:09 PM
  3. simplify each expression
    Posted in the Algebra Forum
    Replies: 3
    Last Post: September 16th 2008, 09:01 PM
  4. Simplify...another expression
    Posted in the Algebra Forum
    Replies: 1
    Last Post: February 24th 2008, 08:46 PM

Search Tags


/mathhelpforum @mathhelpforum