Numeric.SpecFunctions:invIncompleteGamma from math-functions-0.1.5.2, A

Percentage Accurate: 99.9% → 99.8%
Time: 4.3s
Alternatives: 6
Speedup: 9.0×

Specification

?
\[1 - x \cdot \left(0.253 + x \cdot 0.12\right) \]

Your Program's Arguments

Results

Enter valid numbers for all inputs

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 6 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Alternative 1: 99.8% accurate, 0.5× speedup?

\[1 + x \cdot \frac{x \cdot \left(x \cdot 0.0144\right) - 0.064009}{0.253 + x \cdot -0.12} \]
Derivation
  1. Initial program 99.9%

    \[1 - x \cdot \left(0.253 + x \cdot 0.12\right) \]
  2. Step-by-step derivation
    1. flip-+99.8%

      \[\leadsto 1 - x \cdot \color{blue}{\frac{0.253 \cdot 0.253 - \left(x \cdot 0.12\right) \cdot \left(x \cdot 0.12\right)}{0.253 - x \cdot 0.12}} \]
    2. div-sub99.8%

      \[\leadsto 1 - x \cdot \color{blue}{\left(\frac{0.253 \cdot 0.253}{0.253 - x \cdot 0.12} - \frac{\left(x \cdot 0.12\right) \cdot \left(x \cdot 0.12\right)}{0.253 - x \cdot 0.12}\right)} \]
    3. metadata-eval99.8%

      \[\leadsto 1 - x \cdot \left(\frac{\color{blue}{0.064009}}{0.253 - x \cdot 0.12} - \frac{\left(x \cdot 0.12\right) \cdot \left(x \cdot 0.12\right)}{0.253 - x \cdot 0.12}\right) \]
    4. *-commutative99.8%

      \[\leadsto 1 - x \cdot \left(\frac{0.064009}{0.253 - \color{blue}{0.12 \cdot x}} - \frac{\left(x \cdot 0.12\right) \cdot \left(x \cdot 0.12\right)}{0.253 - x \cdot 0.12}\right) \]
    5. cancel-sign-sub-inv99.8%

      \[\leadsto 1 - x \cdot \left(\frac{0.064009}{\color{blue}{0.253 + \left(-0.12\right) \cdot x}} - \frac{\left(x \cdot 0.12\right) \cdot \left(x \cdot 0.12\right)}{0.253 - x \cdot 0.12}\right) \]
    6. metadata-eval99.8%

      \[\leadsto 1 - x \cdot \left(\frac{0.064009}{0.253 + \color{blue}{-0.12} \cdot x} - \frac{\left(x \cdot 0.12\right) \cdot \left(x \cdot 0.12\right)}{0.253 - x \cdot 0.12}\right) \]
    7. swap-sqr99.8%

      \[\leadsto 1 - x \cdot \left(\frac{0.064009}{0.253 + -0.12 \cdot x} - \frac{\color{blue}{\left(x \cdot x\right) \cdot \left(0.12 \cdot 0.12\right)}}{0.253 - x \cdot 0.12}\right) \]
    8. metadata-eval99.8%

      \[\leadsto 1 - x \cdot \left(\frac{0.064009}{0.253 + -0.12 \cdot x} - \frac{\left(x \cdot x\right) \cdot \color{blue}{0.0144}}{0.253 - x \cdot 0.12}\right) \]
    9. *-commutative99.8%

      \[\leadsto 1 - x \cdot \left(\frac{0.064009}{0.253 + -0.12 \cdot x} - \frac{\left(x \cdot x\right) \cdot 0.0144}{0.253 - \color{blue}{0.12 \cdot x}}\right) \]
    10. cancel-sign-sub-inv99.8%

      \[\leadsto 1 - x \cdot \left(\frac{0.064009}{0.253 + -0.12 \cdot x} - \frac{\left(x \cdot x\right) \cdot 0.0144}{\color{blue}{0.253 + \left(-0.12\right) \cdot x}}\right) \]
    11. metadata-eval99.8%

      \[\leadsto 1 - x \cdot \left(\frac{0.064009}{0.253 + -0.12 \cdot x} - \frac{\left(x \cdot x\right) \cdot 0.0144}{0.253 + \color{blue}{-0.12} \cdot x}\right) \]
  3. Applied egg-rr99.8%

    \[\leadsto 1 - x \cdot \color{blue}{\left(\frac{0.064009}{0.253 + -0.12 \cdot x} - \frac{\left(x \cdot x\right) \cdot 0.0144}{0.253 + -0.12 \cdot x}\right)} \]
  4. Step-by-step derivation
    1. div-sub99.8%

      \[\leadsto 1 - x \cdot \color{blue}{\frac{0.064009 - \left(x \cdot x\right) \cdot 0.0144}{0.253 + -0.12 \cdot x}} \]
    2. associate-*l*99.9%

      \[\leadsto 1 - x \cdot \frac{0.064009 - \color{blue}{x \cdot \left(x \cdot 0.0144\right)}}{0.253 + -0.12 \cdot x} \]
    3. *-commutative99.9%

      \[\leadsto 1 - x \cdot \frac{0.064009 - x \cdot \left(x \cdot 0.0144\right)}{0.253 + \color{blue}{x \cdot -0.12}} \]
  5. Simplified99.9%

    \[\leadsto 1 - x \cdot \color{blue}{\frac{0.064009 - x \cdot \left(x \cdot 0.0144\right)}{0.253 + x \cdot -0.12}} \]
  6. Final simplification99.9%

    \[\leadsto 1 + x \cdot \frac{x \cdot \left(x \cdot 0.0144\right) - 0.064009}{0.253 + x \cdot -0.12} \]

Alternative 2: 98.1% accurate, 1.0× speedup?

\[\begin{array}{l} \mathbf{if}\;x \leq -4 \lor \neg \left(x \leq 2.05\right):\\ \;\;\;\;x \cdot \left(x \cdot -0.12\right)\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Derivation
  1. Split input into 2 regimes
  2. if x < -4 or 2.0499999999999998 < x

    1. Initial program 99.7%

      \[1 - x \cdot \left(0.253 + x \cdot 0.12\right) \]
    2. Taylor expanded in x around inf 98.2%

      \[\leadsto 1 - \color{blue}{0.12 \cdot {x}^{2}} \]
    3. Step-by-step derivation
      1. unpow298.2%

        \[\leadsto 1 - 0.12 \cdot \color{blue}{\left(x \cdot x\right)} \]
    4. Simplified98.2%

      \[\leadsto 1 - \color{blue}{0.12 \cdot \left(x \cdot x\right)} \]
    5. Taylor expanded in x around inf 98.2%

      \[\leadsto \color{blue}{-0.12 \cdot {x}^{2}} \]
    6. Step-by-step derivation
      1. unpow298.2%

        \[\leadsto -0.12 \cdot \color{blue}{\left(x \cdot x\right)} \]
      2. *-commutative98.2%

        \[\leadsto \color{blue}{\left(x \cdot x\right) \cdot -0.12} \]
      3. associate-*r*98.2%

        \[\leadsto \color{blue}{x \cdot \left(x \cdot -0.12\right)} \]
    7. Simplified98.2%

      \[\leadsto \color{blue}{x \cdot \left(x \cdot -0.12\right)} \]

    if -4 < x < 2.0499999999999998

    1. Initial program 100.0%

      \[1 - x \cdot \left(0.253 + x \cdot 0.12\right) \]
    2. Taylor expanded in x around inf 97.2%

      \[\leadsto 1 - \color{blue}{0.12 \cdot {x}^{2}} \]
    3. Step-by-step derivation
      1. unpow297.2%

        \[\leadsto 1 - 0.12 \cdot \color{blue}{\left(x \cdot x\right)} \]
    4. Simplified97.2%

      \[\leadsto 1 - \color{blue}{0.12 \cdot \left(x \cdot x\right)} \]
    5. Taylor expanded in x around 0 97.2%

      \[\leadsto \color{blue}{1} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification97.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4 \lor \neg \left(x \leq 2.05\right):\\ \;\;\;\;x \cdot \left(x \cdot -0.12\right)\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]

Alternative 3: 98.6% accurate, 1.0× speedup?

\[\begin{array}{l} \mathbf{if}\;x \leq -4 \lor \neg \left(x \leq 2.05\right):\\ \;\;\;\;x \cdot \left(x \cdot -0.12\right)\\ \mathbf{else}:\\ \;\;\;\;1 - x \cdot 0.253\\ \end{array} \]
Derivation
  1. Split input into 2 regimes
  2. if x < -4 or 2.0499999999999998 < x

    1. Initial program 99.7%

      \[1 - x \cdot \left(0.253 + x \cdot 0.12\right) \]
    2. Taylor expanded in x around inf 98.2%

      \[\leadsto 1 - \color{blue}{0.12 \cdot {x}^{2}} \]
    3. Step-by-step derivation
      1. unpow298.2%

        \[\leadsto 1 - 0.12 \cdot \color{blue}{\left(x \cdot x\right)} \]
    4. Simplified98.2%

      \[\leadsto 1 - \color{blue}{0.12 \cdot \left(x \cdot x\right)} \]
    5. Taylor expanded in x around inf 98.2%

      \[\leadsto \color{blue}{-0.12 \cdot {x}^{2}} \]
    6. Step-by-step derivation
      1. unpow298.2%

        \[\leadsto -0.12 \cdot \color{blue}{\left(x \cdot x\right)} \]
      2. *-commutative98.2%

        \[\leadsto \color{blue}{\left(x \cdot x\right) \cdot -0.12} \]
      3. associate-*r*98.2%

        \[\leadsto \color{blue}{x \cdot \left(x \cdot -0.12\right)} \]
    7. Simplified98.2%

      \[\leadsto \color{blue}{x \cdot \left(x \cdot -0.12\right)} \]

    if -4 < x < 2.0499999999999998

    1. Initial program 100.0%

      \[1 - x \cdot \left(0.253 + x \cdot 0.12\right) \]
    2. Taylor expanded in x around 0 98.5%

      \[\leadsto 1 - \color{blue}{0.253 \cdot x} \]
    3. Step-by-step derivation
      1. *-commutative98.5%

        \[\leadsto 1 - \color{blue}{x \cdot 0.253} \]
    4. Simplified98.5%

      \[\leadsto 1 - \color{blue}{x \cdot 0.253} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification98.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4 \lor \neg \left(x \leq 2.05\right):\\ \;\;\;\;x \cdot \left(x \cdot -0.12\right)\\ \mathbf{else}:\\ \;\;\;\;1 - x \cdot 0.253\\ \end{array} \]

Alternative 4: 99.9% accurate, 1.0× speedup?

\[1 - x \cdot \left(0.253 + x \cdot 0.12\right) \]
Derivation
  1. Initial program 99.9%

    \[1 - x \cdot \left(0.253 + x \cdot 0.12\right) \]
  2. Final simplification99.9%

    \[\leadsto 1 - x \cdot \left(0.253 + x \cdot 0.12\right) \]

Alternative 5: 98.1% accurate, 1.3× speedup?

\[1 - 0.12 \cdot \left(x \cdot x\right) \]
Derivation
  1. Initial program 99.9%

    \[1 - x \cdot \left(0.253 + x \cdot 0.12\right) \]
  2. Taylor expanded in x around inf 97.7%

    \[\leadsto 1 - \color{blue}{0.12 \cdot {x}^{2}} \]
  3. Step-by-step derivation
    1. unpow297.7%

      \[\leadsto 1 - 0.12 \cdot \color{blue}{\left(x \cdot x\right)} \]
  4. Simplified97.7%

    \[\leadsto 1 - \color{blue}{0.12 \cdot \left(x \cdot x\right)} \]
  5. Final simplification97.7%

    \[\leadsto 1 - 0.12 \cdot \left(x \cdot x\right) \]

Alternative 6: 49.0% accurate, 9.0× speedup?

\[1 \]
Derivation
  1. Initial program 99.9%

    \[1 - x \cdot \left(0.253 + x \cdot 0.12\right) \]
  2. Taylor expanded in x around inf 97.7%

    \[\leadsto 1 - \color{blue}{0.12 \cdot {x}^{2}} \]
  3. Step-by-step derivation
    1. unpow297.7%

      \[\leadsto 1 - 0.12 \cdot \color{blue}{\left(x \cdot x\right)} \]
  4. Simplified97.7%

    \[\leadsto 1 - \color{blue}{0.12 \cdot \left(x \cdot x\right)} \]
  5. Taylor expanded in x around 0 50.9%

    \[\leadsto \color{blue}{1} \]
  6. Final simplification50.9%

    \[\leadsto 1 \]

Reproduce

?
herbie shell --seed 2023167 
(FPCore (x)
  :name "Numeric.SpecFunctions:invIncompleteGamma from math-functions-0.1.5.2, A"
  :precision binary64
  (- 1.0 (* x (+ 0.253 (* x 0.12)))))