Success Probability

Percentage Accurate: 8.6% → 99.6%
Time: 12.8s
Alternatives: 4
Speedup: 5.8×

Specification

?
\[\left(0 \leq x \land x \leq 1\right) \land \left(0.3333333333333333 \leq a \land a \leq 3\right)\]
\[1 - {\left(1 - x\right)}^{a} \]
(FPCore (x a)
  :precision binary64
  (- 1.0 (pow (- 1.0 x) a)))
double code(double x, double a) {
	return 1.0 - pow((1.0 - x), a);
}
real(8) function code(x, a)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: a
    code = 1.0d0 - ((1.0d0 - x) ** a)
end function
public static double code(double x, double a) {
	return 1.0 - Math.pow((1.0 - x), a);
}
def code(x, a):
	return 1.0 - math.pow((1.0 - x), a)
function code(x, a)
	return Float64(1.0 - (Float64(1.0 - x) ^ a))
end
function tmp = code(x, a)
	tmp = 1.0 - ((1.0 - x) ^ a);
end
code[x_, a_] := N[(1.0 - N[Power[N[(1.0 - x), $MachinePrecision], a], $MachinePrecision]), $MachinePrecision]
1 - {\left(1 - x\right)}^{a}

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 4 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.

Initial Program: 8.6% accurate, 1.0× speedup?

\[1 - {\left(1 - x\right)}^{a} \]
(FPCore (x a)
  :precision binary64
  (- 1.0 (pow (- 1.0 x) a)))
double code(double x, double a) {
	return 1.0 - pow((1.0 - x), a);
}
real(8) function code(x, a)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: a
    code = 1.0d0 - ((1.0d0 - x) ** a)
end function
public static double code(double x, double a) {
	return 1.0 - Math.pow((1.0 - x), a);
}
def code(x, a):
	return 1.0 - math.pow((1.0 - x), a)
function code(x, a)
	return Float64(1.0 - (Float64(1.0 - x) ^ a))
end
function tmp = code(x, a)
	tmp = 1.0 - ((1.0 - x) ^ a);
end
code[x_, a_] := N[(1.0 - N[Power[N[(1.0 - x), $MachinePrecision], a], $MachinePrecision]), $MachinePrecision]
1 - {\left(1 - x\right)}^{a}

Alternative 1: 99.6% accurate, 0.4× speedup?

\[\mathsf{fma}\left(\left(\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.4583333333333333, x, \left(x \cdot \left(0.25 + -0.041666666666666664 \cdot a\right) - -0.16666666666666666\right) \cdot a\right) - 0.5, a, 0.25 \cdot x\right) - -0.3333333333333333\right) \cdot a\right) \cdot x - \mathsf{fma}\left(a \cdot a, 0.5, -0.5 \cdot a\right), x, a\right) \cdot x \]
(FPCore (x a)
  :precision binary64
  (*
 (fma
  (-
   (*
    (*
     (-
      (fma
       (-
        (fma
         -0.4583333333333333
         x
         (*
          (-
           (* x (+ 0.25 (* -0.041666666666666664 a)))
           -0.16666666666666666)
          a))
        0.5)
       a
       (* 0.25 x))
      -0.3333333333333333)
     a)
    x)
   (fma (* a a) 0.5 (* -0.5 a)))
  x
  a)
 x))
double code(double x, double a) {
	return fma(((((fma((fma(-0.4583333333333333, x, (((x * (0.25 + (-0.041666666666666664 * a))) - -0.16666666666666666) * a)) - 0.5), a, (0.25 * x)) - -0.3333333333333333) * a) * x) - fma((a * a), 0.5, (-0.5 * a))), x, a) * x;
}
function code(x, a)
	return Float64(fma(Float64(Float64(Float64(Float64(fma(Float64(fma(-0.4583333333333333, x, Float64(Float64(Float64(x * Float64(0.25 + Float64(-0.041666666666666664 * a))) - -0.16666666666666666) * a)) - 0.5), a, Float64(0.25 * x)) - -0.3333333333333333) * a) * x) - fma(Float64(a * a), 0.5, Float64(-0.5 * a))), x, a) * x)
end
code[x_, a_] := N[(N[(N[(N[(N[(N[(N[(N[(N[(-0.4583333333333333 * x + N[(N[(N[(x * N[(0.25 + N[(-0.041666666666666664 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - -0.16666666666666666), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision] * a + N[(0.25 * x), $MachinePrecision]), $MachinePrecision] - -0.3333333333333333), $MachinePrecision] * a), $MachinePrecision] * x), $MachinePrecision] - N[(N[(a * a), $MachinePrecision] * 0.5 + N[(-0.5 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * x + a), $MachinePrecision] * x), $MachinePrecision]
\mathsf{fma}\left(\left(\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.4583333333333333, x, \left(x \cdot \left(0.25 + -0.041666666666666664 \cdot a\right) - -0.16666666666666666\right) \cdot a\right) - 0.5, a, 0.25 \cdot x\right) - -0.3333333333333333\right) \cdot a\right) \cdot x - \mathsf{fma}\left(a \cdot a, 0.5, -0.5 \cdot a\right), x, a\right) \cdot x
Derivation
  1. Initial program 8.6%

    \[1 - {\left(1 - x\right)}^{a} \]
  2. Taylor expanded in x around 0

    \[\leadsto \color{blue}{x \cdot \left(x \cdot \left(x \cdot \left(-1 \cdot \left(x \cdot \left(\frac{-1}{4} \cdot a + \left(\frac{-1}{4} \cdot {a}^{3} + \left(\frac{1}{24} \cdot {a}^{4} + \left(\frac{1}{8} \cdot {a}^{2} + \frac{1}{3} \cdot {a}^{2}\right)\right)\right)\right)\right) - \left(\frac{-1}{3} \cdot a + \left(\frac{-1}{6} \cdot {a}^{3} + \frac{1}{2} \cdot {a}^{2}\right)\right)\right) - \left(\frac{-1}{2} \cdot a + \frac{1}{2} \cdot {a}^{2}\right)\right) - -1 \cdot a\right)} \]
  3. Applied rewrites99.6%

    \[\leadsto \color{blue}{x \cdot \left(x \cdot \left(x \cdot \left(-1 \cdot \left(x \cdot \mathsf{fma}\left(-0.25, a, \mathsf{fma}\left(-0.25, {a}^{3}, \mathsf{fma}\left(0.041666666666666664, {a}^{4}, \mathsf{fma}\left(0.125, {a}^{2}, 0.3333333333333333 \cdot {a}^{2}\right)\right)\right)\right)\right) - \mathsf{fma}\left(-0.3333333333333333, a, \mathsf{fma}\left(-0.16666666666666666, {a}^{3}, 0.5 \cdot {a}^{2}\right)\right)\right) - \mathsf{fma}\left(-0.5, a, 0.5 \cdot {a}^{2}\right)\right) - -1 \cdot a\right)} \]
  4. Taylor expanded in a around 0

    \[\leadsto x \cdot \left(x \cdot \left(x \cdot \left(a \cdot \left(\frac{1}{3} + \left(\frac{1}{4} \cdot x + a \cdot \left(\left(\frac{-11}{24} \cdot x + a \cdot \left(\frac{1}{6} + \left(\frac{-1}{24} \cdot \left(a \cdot x\right) + \frac{1}{4} \cdot x\right)\right)\right) - \frac{1}{2}\right)\right)\right)\right) - \mathsf{fma}\left(-0.5, a, 0.5 \cdot {a}^{2}\right)\right) - -1 \cdot a\right) \]
  5. Step-by-step derivation
    1. lower-*.f64N/A

      \[\leadsto x \cdot \left(x \cdot \left(x \cdot \left(a \cdot \left(\frac{1}{3} + \left(\frac{1}{4} \cdot x + a \cdot \left(\left(\frac{-11}{24} \cdot x + a \cdot \left(\frac{1}{6} + \left(\frac{-1}{24} \cdot \left(a \cdot x\right) + \frac{1}{4} \cdot x\right)\right)\right) - \frac{1}{2}\right)\right)\right)\right) - \mathsf{fma}\left(\frac{-1}{2}, a, \frac{1}{2} \cdot {a}^{2}\right)\right) - -1 \cdot a\right) \]
    2. lower-+.f64N/A

      \[\leadsto x \cdot \left(x \cdot \left(x \cdot \left(a \cdot \left(\frac{1}{3} + \left(\frac{1}{4} \cdot x + a \cdot \left(\left(\frac{-11}{24} \cdot x + a \cdot \left(\frac{1}{6} + \left(\frac{-1}{24} \cdot \left(a \cdot x\right) + \frac{1}{4} \cdot x\right)\right)\right) - \frac{1}{2}\right)\right)\right)\right) - \mathsf{fma}\left(\frac{-1}{2}, a, \frac{1}{2} \cdot {a}^{2}\right)\right) - -1 \cdot a\right) \]
    3. lower-fma.f64N/A

      \[\leadsto x \cdot \left(x \cdot \left(x \cdot \left(a \cdot \left(\frac{1}{3} + \mathsf{fma}\left(\frac{1}{4}, x, a \cdot \left(\left(\frac{-11}{24} \cdot x + a \cdot \left(\frac{1}{6} + \left(\frac{-1}{24} \cdot \left(a \cdot x\right) + \frac{1}{4} \cdot x\right)\right)\right) - \frac{1}{2}\right)\right)\right)\right) - \mathsf{fma}\left(\frac{-1}{2}, a, \frac{1}{2} \cdot {a}^{2}\right)\right) - -1 \cdot a\right) \]
    4. lower-*.f64N/A

      \[\leadsto x \cdot \left(x \cdot \left(x \cdot \left(a \cdot \left(\frac{1}{3} + \mathsf{fma}\left(\frac{1}{4}, x, a \cdot \left(\left(\frac{-11}{24} \cdot x + a \cdot \left(\frac{1}{6} + \left(\frac{-1}{24} \cdot \left(a \cdot x\right) + \frac{1}{4} \cdot x\right)\right)\right) - \frac{1}{2}\right)\right)\right)\right) - \mathsf{fma}\left(\frac{-1}{2}, a, \frac{1}{2} \cdot {a}^{2}\right)\right) - -1 \cdot a\right) \]
    5. lower--.f64N/A

      \[\leadsto x \cdot \left(x \cdot \left(x \cdot \left(a \cdot \left(\frac{1}{3} + \mathsf{fma}\left(\frac{1}{4}, x, a \cdot \left(\left(\frac{-11}{24} \cdot x + a \cdot \left(\frac{1}{6} + \left(\frac{-1}{24} \cdot \left(a \cdot x\right) + \frac{1}{4} \cdot x\right)\right)\right) - \frac{1}{2}\right)\right)\right)\right) - \mathsf{fma}\left(\frac{-1}{2}, a, \frac{1}{2} \cdot {a}^{2}\right)\right) - -1 \cdot a\right) \]
  6. Applied rewrites99.6%

    \[\leadsto x \cdot \left(x \cdot \left(x \cdot \left(a \cdot \left(0.3333333333333333 + \mathsf{fma}\left(0.25, x, a \cdot \left(\mathsf{fma}\left(-0.4583333333333333, x, a \cdot \left(0.16666666666666666 + \mathsf{fma}\left(-0.041666666666666664, a \cdot x, 0.25 \cdot x\right)\right)\right) - 0.5\right)\right)\right)\right) - \mathsf{fma}\left(-0.5, a, 0.5 \cdot {a}^{2}\right)\right) - -1 \cdot a\right) \]
  7. Applied rewrites99.6%

    \[\leadsto \mathsf{fma}\left(\left(\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.4583333333333333, x, \left(\mathsf{fma}\left(-0.041666666666666664, a \cdot x, 0.25 \cdot x\right) - -0.16666666666666666\right) \cdot a\right) - 0.5, a, 0.25 \cdot x\right) - -0.3333333333333333\right) \cdot a\right) \cdot x - \mathsf{fma}\left(a \cdot a, 0.5, -0.5 \cdot a\right), x, a\right) \cdot \color{blue}{x} \]
  8. Taylor expanded in x around 0

    \[\leadsto \mathsf{fma}\left(\left(\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.4583333333333333, x, \left(x \cdot \left(\frac{1}{4} + \frac{-1}{24} \cdot a\right) - -0.16666666666666666\right) \cdot a\right) - 0.5, a, 0.25 \cdot x\right) - -0.3333333333333333\right) \cdot a\right) \cdot x - \mathsf{fma}\left(a \cdot a, 0.5, -0.5 \cdot a\right), x, a\right) \cdot x \]
  9. Step-by-step derivation
    1. lower-*.f64N/A

      \[\leadsto \mathsf{fma}\left(\left(\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{-11}{24}, x, \left(x \cdot \left(\frac{1}{4} + \frac{-1}{24} \cdot a\right) - \frac{-1}{6}\right) \cdot a\right) - \frac{1}{2}, a, \frac{1}{4} \cdot x\right) - \frac{-1}{3}\right) \cdot a\right) \cdot x - \mathsf{fma}\left(a \cdot a, \frac{1}{2}, \frac{-1}{2} \cdot a\right), x, a\right) \cdot x \]
    2. lower-+.f64N/A

      \[\leadsto \mathsf{fma}\left(\left(\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{-11}{24}, x, \left(x \cdot \left(\frac{1}{4} + \frac{-1}{24} \cdot a\right) - \frac{-1}{6}\right) \cdot a\right) - \frac{1}{2}, a, \frac{1}{4} \cdot x\right) - \frac{-1}{3}\right) \cdot a\right) \cdot x - \mathsf{fma}\left(a \cdot a, \frac{1}{2}, \frac{-1}{2} \cdot a\right), x, a\right) \cdot x \]
    3. lower-*.f6499.6%

      \[\leadsto \mathsf{fma}\left(\left(\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.4583333333333333, x, \left(x \cdot \left(0.25 + -0.041666666666666664 \cdot a\right) - -0.16666666666666666\right) \cdot a\right) - 0.5, a, 0.25 \cdot x\right) - -0.3333333333333333\right) \cdot a\right) \cdot x - \mathsf{fma}\left(a \cdot a, 0.5, -0.5 \cdot a\right), x, a\right) \cdot x \]
  10. Applied rewrites99.6%

    \[\leadsto \mathsf{fma}\left(\left(\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.4583333333333333, x, \left(x \cdot \left(0.25 + -0.041666666666666664 \cdot a\right) - -0.16666666666666666\right) \cdot a\right) - 0.5, a, 0.25 \cdot x\right) - -0.3333333333333333\right) \cdot a\right) \cdot x - \mathsf{fma}\left(a \cdot a, 0.5, -0.5 \cdot a\right), x, a\right) \cdot x \]
  11. Add Preprocessing

Alternative 2: 99.4% accurate, 0.7× speedup?

\[\mathsf{fma}\left(\left(\mathsf{fma}\left(0.3333333333333333, x, \left(x \cdot \left(0.16666666666666666 \cdot a - 0.5\right) - 0.5\right) \cdot a\right) - -0.5\right) \cdot a, x, a\right) \cdot x \]
(FPCore (x a)
  :precision binary64
  (*
 (fma
  (*
   (-
    (fma
     0.3333333333333333
     x
     (* (- (* x (- (* 0.16666666666666666 a) 0.5)) 0.5) a))
    -0.5)
   a)
  x
  a)
 x))
double code(double x, double a) {
	return fma(((fma(0.3333333333333333, x, (((x * ((0.16666666666666666 * a) - 0.5)) - 0.5) * a)) - -0.5) * a), x, a) * x;
}
function code(x, a)
	return Float64(fma(Float64(Float64(fma(0.3333333333333333, x, Float64(Float64(Float64(x * Float64(Float64(0.16666666666666666 * a) - 0.5)) - 0.5) * a)) - -0.5) * a), x, a) * x)
end
code[x_, a_] := N[(N[(N[(N[(N[(0.3333333333333333 * x + N[(N[(N[(x * N[(N[(0.16666666666666666 * a), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] - -0.5), $MachinePrecision] * a), $MachinePrecision] * x + a), $MachinePrecision] * x), $MachinePrecision]
\mathsf{fma}\left(\left(\mathsf{fma}\left(0.3333333333333333, x, \left(x \cdot \left(0.16666666666666666 \cdot a - 0.5\right) - 0.5\right) \cdot a\right) - -0.5\right) \cdot a, x, a\right) \cdot x
Derivation
  1. Initial program 8.6%

    \[1 - {\left(1 - x\right)}^{a} \]
  2. Taylor expanded in x around 0

    \[\leadsto \color{blue}{x \cdot \left(x \cdot \left(-1 \cdot \left(x \cdot \left(\frac{-1}{3} \cdot a + \left(\frac{-1}{6} \cdot {a}^{3} + \frac{1}{2} \cdot {a}^{2}\right)\right)\right) - \left(\frac{-1}{2} \cdot a + \frac{1}{2} \cdot {a}^{2}\right)\right) - -1 \cdot a\right)} \]
  3. Step-by-step derivation
    1. lower-*.f64N/A

      \[\leadsto x \cdot \color{blue}{\left(x \cdot \left(-1 \cdot \left(x \cdot \left(\frac{-1}{3} \cdot a + \left(\frac{-1}{6} \cdot {a}^{3} + \frac{1}{2} \cdot {a}^{2}\right)\right)\right) - \left(\frac{-1}{2} \cdot a + \frac{1}{2} \cdot {a}^{2}\right)\right) - -1 \cdot a\right)} \]
    2. lower--.f64N/A

      \[\leadsto x \cdot \left(x \cdot \left(-1 \cdot \left(x \cdot \left(\frac{-1}{3} \cdot a + \left(\frac{-1}{6} \cdot {a}^{3} + \frac{1}{2} \cdot {a}^{2}\right)\right)\right) - \left(\frac{-1}{2} \cdot a + \frac{1}{2} \cdot {a}^{2}\right)\right) - \color{blue}{-1 \cdot a}\right) \]
  4. Applied rewrites99.4%

    \[\leadsto \color{blue}{x \cdot \left(x \cdot \left(-1 \cdot \left(x \cdot \mathsf{fma}\left(-0.3333333333333333, a, \mathsf{fma}\left(-0.16666666666666666, {a}^{3}, 0.5 \cdot {a}^{2}\right)\right)\right) - \mathsf{fma}\left(-0.5, a, 0.5 \cdot {a}^{2}\right)\right) - -1 \cdot a\right)} \]
  5. Taylor expanded in a around 0

    \[\leadsto x \cdot \left(x \cdot \left(a \cdot \left(\frac{1}{2} + \left(\frac{1}{3} \cdot x + a \cdot \left(\left(\frac{-1}{2} \cdot x + \frac{1}{6} \cdot \left(a \cdot x\right)\right) - \frac{1}{2}\right)\right)\right)\right) - -1 \cdot a\right) \]
  6. Step-by-step derivation
    1. lower-*.f64N/A

      \[\leadsto x \cdot \left(x \cdot \left(a \cdot \left(\frac{1}{2} + \left(\frac{1}{3} \cdot x + a \cdot \left(\left(\frac{-1}{2} \cdot x + \frac{1}{6} \cdot \left(a \cdot x\right)\right) - \frac{1}{2}\right)\right)\right)\right) - -1 \cdot a\right) \]
    2. lower-+.f64N/A

      \[\leadsto x \cdot \left(x \cdot \left(a \cdot \left(\frac{1}{2} + \left(\frac{1}{3} \cdot x + a \cdot \left(\left(\frac{-1}{2} \cdot x + \frac{1}{6} \cdot \left(a \cdot x\right)\right) - \frac{1}{2}\right)\right)\right)\right) - -1 \cdot a\right) \]
    3. lower-fma.f64N/A

      \[\leadsto x \cdot \left(x \cdot \left(a \cdot \left(\frac{1}{2} + \mathsf{fma}\left(\frac{1}{3}, x, a \cdot \left(\left(\frac{-1}{2} \cdot x + \frac{1}{6} \cdot \left(a \cdot x\right)\right) - \frac{1}{2}\right)\right)\right)\right) - -1 \cdot a\right) \]
    4. lower-*.f64N/A

      \[\leadsto x \cdot \left(x \cdot \left(a \cdot \left(\frac{1}{2} + \mathsf{fma}\left(\frac{1}{3}, x, a \cdot \left(\left(\frac{-1}{2} \cdot x + \frac{1}{6} \cdot \left(a \cdot x\right)\right) - \frac{1}{2}\right)\right)\right)\right) - -1 \cdot a\right) \]
    5. lower--.f64N/A

      \[\leadsto x \cdot \left(x \cdot \left(a \cdot \left(\frac{1}{2} + \mathsf{fma}\left(\frac{1}{3}, x, a \cdot \left(\left(\frac{-1}{2} \cdot x + \frac{1}{6} \cdot \left(a \cdot x\right)\right) - \frac{1}{2}\right)\right)\right)\right) - -1 \cdot a\right) \]
    6. lower-fma.f64N/A

      \[\leadsto x \cdot \left(x \cdot \left(a \cdot \left(\frac{1}{2} + \mathsf{fma}\left(\frac{1}{3}, x, a \cdot \left(\mathsf{fma}\left(\frac{-1}{2}, x, \frac{1}{6} \cdot \left(a \cdot x\right)\right) - \frac{1}{2}\right)\right)\right)\right) - -1 \cdot a\right) \]
    7. lower-*.f64N/A

      \[\leadsto x \cdot \left(x \cdot \left(a \cdot \left(\frac{1}{2} + \mathsf{fma}\left(\frac{1}{3}, x, a \cdot \left(\mathsf{fma}\left(\frac{-1}{2}, x, \frac{1}{6} \cdot \left(a \cdot x\right)\right) - \frac{1}{2}\right)\right)\right)\right) - -1 \cdot a\right) \]
    8. lower-*.f6499.4%

      \[\leadsto x \cdot \left(x \cdot \left(a \cdot \left(0.5 + \mathsf{fma}\left(0.3333333333333333, x, a \cdot \left(\mathsf{fma}\left(-0.5, x, 0.16666666666666666 \cdot \left(a \cdot x\right)\right) - 0.5\right)\right)\right)\right) - -1 \cdot a\right) \]
  7. Applied rewrites99.4%

    \[\leadsto x \cdot \left(x \cdot \left(a \cdot \left(0.5 + \mathsf{fma}\left(0.3333333333333333, x, a \cdot \left(\mathsf{fma}\left(-0.5, x, 0.16666666666666666 \cdot \left(a \cdot x\right)\right) - 0.5\right)\right)\right)\right) - -1 \cdot a\right) \]
  8. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto x \cdot \color{blue}{\left(x \cdot \left(a \cdot \left(\frac{1}{2} + \mathsf{fma}\left(\frac{1}{3}, x, a \cdot \left(\mathsf{fma}\left(\frac{-1}{2}, x, \frac{1}{6} \cdot \left(a \cdot x\right)\right) - \frac{1}{2}\right)\right)\right)\right) - -1 \cdot a\right)} \]
    2. *-commutativeN/A

      \[\leadsto \left(x \cdot \left(a \cdot \left(\frac{1}{2} + \mathsf{fma}\left(\frac{1}{3}, x, a \cdot \left(\mathsf{fma}\left(\frac{-1}{2}, x, \frac{1}{6} \cdot \left(a \cdot x\right)\right) - \frac{1}{2}\right)\right)\right)\right) - -1 \cdot a\right) \cdot \color{blue}{x} \]
    3. lower-*.f6499.4%

      \[\leadsto \left(x \cdot \left(a \cdot \left(0.5 + \mathsf{fma}\left(0.3333333333333333, x, a \cdot \left(\mathsf{fma}\left(-0.5, x, 0.16666666666666666 \cdot \left(a \cdot x\right)\right) - 0.5\right)\right)\right)\right) - -1 \cdot a\right) \cdot \color{blue}{x} \]
  9. Applied rewrites99.4%

    \[\leadsto \mathsf{fma}\left(\left(\mathsf{fma}\left(0.3333333333333333, x, \left(\mathsf{fma}\left(-0.5, x, 0.16666666666666666 \cdot \left(a \cdot x\right)\right) - 0.5\right) \cdot a\right) - -0.5\right) \cdot a, x, a\right) \cdot \color{blue}{x} \]
  10. Taylor expanded in x around 0

    \[\leadsto \mathsf{fma}\left(\left(\mathsf{fma}\left(0.3333333333333333, x, \left(x \cdot \left(\frac{1}{6} \cdot a - \frac{1}{2}\right) - 0.5\right) \cdot a\right) - -0.5\right) \cdot a, x, a\right) \cdot x \]
  11. Step-by-step derivation
    1. lower-*.f64N/A

      \[\leadsto \mathsf{fma}\left(\left(\mathsf{fma}\left(\frac{1}{3}, x, \left(x \cdot \left(\frac{1}{6} \cdot a - \frac{1}{2}\right) - \frac{1}{2}\right) \cdot a\right) - \frac{-1}{2}\right) \cdot a, x, a\right) \cdot x \]
    2. lower--.f64N/A

      \[\leadsto \mathsf{fma}\left(\left(\mathsf{fma}\left(\frac{1}{3}, x, \left(x \cdot \left(\frac{1}{6} \cdot a - \frac{1}{2}\right) - \frac{1}{2}\right) \cdot a\right) - \frac{-1}{2}\right) \cdot a, x, a\right) \cdot x \]
    3. lower-*.f6499.4%

      \[\leadsto \mathsf{fma}\left(\left(\mathsf{fma}\left(0.3333333333333333, x, \left(x \cdot \left(0.16666666666666666 \cdot a - 0.5\right) - 0.5\right) \cdot a\right) - -0.5\right) \cdot a, x, a\right) \cdot x \]
  12. Applied rewrites99.4%

    \[\leadsto \mathsf{fma}\left(\left(\mathsf{fma}\left(0.3333333333333333, x, \left(x \cdot \left(0.16666666666666666 \cdot a - 0.5\right) - 0.5\right) \cdot a\right) - -0.5\right) \cdot a, x, a\right) \cdot x \]
  13. Add Preprocessing

Alternative 3: 99.1% accurate, 1.3× speedup?

\[\mathsf{fma}\left(\left(0.5 + -0.5 \cdot a\right) \cdot a, x, a\right) \cdot x \]
(FPCore (x a)
  :precision binary64
  (* (fma (* (+ 0.5 (* -0.5 a)) a) x a) x))
double code(double x, double a) {
	return fma(((0.5 + (-0.5 * a)) * a), x, a) * x;
}
function code(x, a)
	return Float64(fma(Float64(Float64(0.5 + Float64(-0.5 * a)) * a), x, a) * x)
end
code[x_, a_] := N[(N[(N[(N[(0.5 + N[(-0.5 * a), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision] * x + a), $MachinePrecision] * x), $MachinePrecision]
\mathsf{fma}\left(\left(0.5 + -0.5 \cdot a\right) \cdot a, x, a\right) \cdot x
Derivation
  1. Initial program 8.6%

    \[1 - {\left(1 - x\right)}^{a} \]
  2. Taylor expanded in x around 0

    \[\leadsto \color{blue}{x \cdot \left(x \cdot \left(-1 \cdot \left(x \cdot \left(\frac{-1}{3} \cdot a + \left(\frac{-1}{6} \cdot {a}^{3} + \frac{1}{2} \cdot {a}^{2}\right)\right)\right) - \left(\frac{-1}{2} \cdot a + \frac{1}{2} \cdot {a}^{2}\right)\right) - -1 \cdot a\right)} \]
  3. Step-by-step derivation
    1. lower-*.f64N/A

      \[\leadsto x \cdot \color{blue}{\left(x \cdot \left(-1 \cdot \left(x \cdot \left(\frac{-1}{3} \cdot a + \left(\frac{-1}{6} \cdot {a}^{3} + \frac{1}{2} \cdot {a}^{2}\right)\right)\right) - \left(\frac{-1}{2} \cdot a + \frac{1}{2} \cdot {a}^{2}\right)\right) - -1 \cdot a\right)} \]
    2. lower--.f64N/A

      \[\leadsto x \cdot \left(x \cdot \left(-1 \cdot \left(x \cdot \left(\frac{-1}{3} \cdot a + \left(\frac{-1}{6} \cdot {a}^{3} + \frac{1}{2} \cdot {a}^{2}\right)\right)\right) - \left(\frac{-1}{2} \cdot a + \frac{1}{2} \cdot {a}^{2}\right)\right) - \color{blue}{-1 \cdot a}\right) \]
  4. Applied rewrites99.4%

    \[\leadsto \color{blue}{x \cdot \left(x \cdot \left(-1 \cdot \left(x \cdot \mathsf{fma}\left(-0.3333333333333333, a, \mathsf{fma}\left(-0.16666666666666666, {a}^{3}, 0.5 \cdot {a}^{2}\right)\right)\right) - \mathsf{fma}\left(-0.5, a, 0.5 \cdot {a}^{2}\right)\right) - -1 \cdot a\right)} \]
  5. Taylor expanded in a around 0

    \[\leadsto x \cdot \left(x \cdot \left(a \cdot \left(\frac{1}{2} + \left(\frac{1}{3} \cdot x + a \cdot \left(\left(\frac{-1}{2} \cdot x + \frac{1}{6} \cdot \left(a \cdot x\right)\right) - \frac{1}{2}\right)\right)\right)\right) - -1 \cdot a\right) \]
  6. Step-by-step derivation
    1. lower-*.f64N/A

      \[\leadsto x \cdot \left(x \cdot \left(a \cdot \left(\frac{1}{2} + \left(\frac{1}{3} \cdot x + a \cdot \left(\left(\frac{-1}{2} \cdot x + \frac{1}{6} \cdot \left(a \cdot x\right)\right) - \frac{1}{2}\right)\right)\right)\right) - -1 \cdot a\right) \]
    2. lower-+.f64N/A

      \[\leadsto x \cdot \left(x \cdot \left(a \cdot \left(\frac{1}{2} + \left(\frac{1}{3} \cdot x + a \cdot \left(\left(\frac{-1}{2} \cdot x + \frac{1}{6} \cdot \left(a \cdot x\right)\right) - \frac{1}{2}\right)\right)\right)\right) - -1 \cdot a\right) \]
    3. lower-fma.f64N/A

      \[\leadsto x \cdot \left(x \cdot \left(a \cdot \left(\frac{1}{2} + \mathsf{fma}\left(\frac{1}{3}, x, a \cdot \left(\left(\frac{-1}{2} \cdot x + \frac{1}{6} \cdot \left(a \cdot x\right)\right) - \frac{1}{2}\right)\right)\right)\right) - -1 \cdot a\right) \]
    4. lower-*.f64N/A

      \[\leadsto x \cdot \left(x \cdot \left(a \cdot \left(\frac{1}{2} + \mathsf{fma}\left(\frac{1}{3}, x, a \cdot \left(\left(\frac{-1}{2} \cdot x + \frac{1}{6} \cdot \left(a \cdot x\right)\right) - \frac{1}{2}\right)\right)\right)\right) - -1 \cdot a\right) \]
    5. lower--.f64N/A

      \[\leadsto x \cdot \left(x \cdot \left(a \cdot \left(\frac{1}{2} + \mathsf{fma}\left(\frac{1}{3}, x, a \cdot \left(\left(\frac{-1}{2} \cdot x + \frac{1}{6} \cdot \left(a \cdot x\right)\right) - \frac{1}{2}\right)\right)\right)\right) - -1 \cdot a\right) \]
    6. lower-fma.f64N/A

      \[\leadsto x \cdot \left(x \cdot \left(a \cdot \left(\frac{1}{2} + \mathsf{fma}\left(\frac{1}{3}, x, a \cdot \left(\mathsf{fma}\left(\frac{-1}{2}, x, \frac{1}{6} \cdot \left(a \cdot x\right)\right) - \frac{1}{2}\right)\right)\right)\right) - -1 \cdot a\right) \]
    7. lower-*.f64N/A

      \[\leadsto x \cdot \left(x \cdot \left(a \cdot \left(\frac{1}{2} + \mathsf{fma}\left(\frac{1}{3}, x, a \cdot \left(\mathsf{fma}\left(\frac{-1}{2}, x, \frac{1}{6} \cdot \left(a \cdot x\right)\right) - \frac{1}{2}\right)\right)\right)\right) - -1 \cdot a\right) \]
    8. lower-*.f6499.4%

      \[\leadsto x \cdot \left(x \cdot \left(a \cdot \left(0.5 + \mathsf{fma}\left(0.3333333333333333, x, a \cdot \left(\mathsf{fma}\left(-0.5, x, 0.16666666666666666 \cdot \left(a \cdot x\right)\right) - 0.5\right)\right)\right)\right) - -1 \cdot a\right) \]
  7. Applied rewrites99.4%

    \[\leadsto x \cdot \left(x \cdot \left(a \cdot \left(0.5 + \mathsf{fma}\left(0.3333333333333333, x, a \cdot \left(\mathsf{fma}\left(-0.5, x, 0.16666666666666666 \cdot \left(a \cdot x\right)\right) - 0.5\right)\right)\right)\right) - -1 \cdot a\right) \]
  8. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto x \cdot \color{blue}{\left(x \cdot \left(a \cdot \left(\frac{1}{2} + \mathsf{fma}\left(\frac{1}{3}, x, a \cdot \left(\mathsf{fma}\left(\frac{-1}{2}, x, \frac{1}{6} \cdot \left(a \cdot x\right)\right) - \frac{1}{2}\right)\right)\right)\right) - -1 \cdot a\right)} \]
    2. *-commutativeN/A

      \[\leadsto \left(x \cdot \left(a \cdot \left(\frac{1}{2} + \mathsf{fma}\left(\frac{1}{3}, x, a \cdot \left(\mathsf{fma}\left(\frac{-1}{2}, x, \frac{1}{6} \cdot \left(a \cdot x\right)\right) - \frac{1}{2}\right)\right)\right)\right) - -1 \cdot a\right) \cdot \color{blue}{x} \]
    3. lower-*.f6499.4%

      \[\leadsto \left(x \cdot \left(a \cdot \left(0.5 + \mathsf{fma}\left(0.3333333333333333, x, a \cdot \left(\mathsf{fma}\left(-0.5, x, 0.16666666666666666 \cdot \left(a \cdot x\right)\right) - 0.5\right)\right)\right)\right) - -1 \cdot a\right) \cdot \color{blue}{x} \]
  9. Applied rewrites99.4%

    \[\leadsto \mathsf{fma}\left(\left(\mathsf{fma}\left(0.3333333333333333, x, \left(\mathsf{fma}\left(-0.5, x, 0.16666666666666666 \cdot \left(a \cdot x\right)\right) - 0.5\right) \cdot a\right) - -0.5\right) \cdot a, x, a\right) \cdot \color{blue}{x} \]
  10. Taylor expanded in x around 0

    \[\leadsto \mathsf{fma}\left(\left(\frac{1}{2} + \frac{-1}{2} \cdot a\right) \cdot a, x, a\right) \cdot x \]
  11. Step-by-step derivation
    1. lower-+.f64N/A

      \[\leadsto \mathsf{fma}\left(\left(\frac{1}{2} + \frac{-1}{2} \cdot a\right) \cdot a, x, a\right) \cdot x \]
    2. lower-*.f6499.1%

      \[\leadsto \mathsf{fma}\left(\left(0.5 + -0.5 \cdot a\right) \cdot a, x, a\right) \cdot x \]
  12. Applied rewrites99.1%

    \[\leadsto \mathsf{fma}\left(\left(0.5 + -0.5 \cdot a\right) \cdot a, x, a\right) \cdot x \]
  13. Add Preprocessing

Alternative 4: 98.0% accurate, 5.8× speedup?

\[a \cdot x \]
(FPCore (x a)
  :precision binary64
  (* a x))
double code(double x, double a) {
	return a * x;
}
real(8) function code(x, a)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: a
    code = a * x
end function
public static double code(double x, double a) {
	return a * x;
}
def code(x, a):
	return a * x
function code(x, a)
	return Float64(a * x)
end
function tmp = code(x, a)
	tmp = a * x;
end
code[x_, a_] := N[(a * x), $MachinePrecision]
a \cdot x
Derivation
  1. Initial program 8.6%

    \[1 - {\left(1 - x\right)}^{a} \]
  2. Taylor expanded in x around 0

    \[\leadsto \color{blue}{a \cdot x} \]
  3. Step-by-step derivation
    1. lower-*.f6498.0%

      \[\leadsto a \cdot \color{blue}{x} \]
  4. Applied rewrites98.0%

    \[\leadsto \color{blue}{a \cdot x} \]
  5. Add Preprocessing

Reproduce

?
herbie shell --seed 2025326 
(FPCore (x a)
  :name "Success Probability"
  :precision binary64
  :pre (and (and (<= 0.0 x) (<= x 1.0)) (and (<= 0.3333333333333333 a) (<= a 3.0)))
  (- 1.0 (pow (- 1.0 x) a)))