Falkner and Boettcher, Equation (22+)

Percentage Accurate: 98.5% → 100.0%
Time: 2.4s
Alternatives: 4
Speedup: 3.2×

Specification

?
\[\begin{array}{l} \\ \frac{4}{\left(\left(3 \cdot \pi\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}} \end{array} \]
(FPCore (v)
 :precision binary64
 (/ 4.0 (* (* (* 3.0 PI) (- 1.0 (* v v))) (sqrt (- 2.0 (* 6.0 (* v v)))))))
double code(double v) {
	return 4.0 / (((3.0 * ((double) M_PI)) * (1.0 - (v * v))) * sqrt((2.0 - (6.0 * (v * v)))));
}
public static double code(double v) {
	return 4.0 / (((3.0 * Math.PI) * (1.0 - (v * v))) * Math.sqrt((2.0 - (6.0 * (v * v)))));
}
def code(v):
	return 4.0 / (((3.0 * math.pi) * (1.0 - (v * v))) * math.sqrt((2.0 - (6.0 * (v * v)))))
function code(v)
	return Float64(4.0 / Float64(Float64(Float64(3.0 * pi) * Float64(1.0 - Float64(v * v))) * sqrt(Float64(2.0 - Float64(6.0 * Float64(v * v))))))
end
function tmp = code(v)
	tmp = 4.0 / (((3.0 * pi) * (1.0 - (v * v))) * sqrt((2.0 - (6.0 * (v * v)))));
end
code[v_] := N[(4.0 / N[(N[(N[(3.0 * Pi), $MachinePrecision] * N[(1.0 - N[(v * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(2.0 - N[(6.0 * N[(v * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{4}{\left(\left(3 \cdot \pi\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}}
\end{array}

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: 98.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{4}{\left(\left(3 \cdot \pi\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}} \end{array} \]
(FPCore (v)
 :precision binary64
 (/ 4.0 (* (* (* 3.0 PI) (- 1.0 (* v v))) (sqrt (- 2.0 (* 6.0 (* v v)))))))
double code(double v) {
	return 4.0 / (((3.0 * ((double) M_PI)) * (1.0 - (v * v))) * sqrt((2.0 - (6.0 * (v * v)))));
}
public static double code(double v) {
	return 4.0 / (((3.0 * Math.PI) * (1.0 - (v * v))) * Math.sqrt((2.0 - (6.0 * (v * v)))));
}
def code(v):
	return 4.0 / (((3.0 * math.pi) * (1.0 - (v * v))) * math.sqrt((2.0 - (6.0 * (v * v)))))
function code(v)
	return Float64(4.0 / Float64(Float64(Float64(3.0 * pi) * Float64(1.0 - Float64(v * v))) * sqrt(Float64(2.0 - Float64(6.0 * Float64(v * v))))))
end
function tmp = code(v)
	tmp = 4.0 / (((3.0 * pi) * (1.0 - (v * v))) * sqrt((2.0 - (6.0 * (v * v)))));
end
code[v_] := N[(4.0 / N[(N[(N[(3.0 * Pi), $MachinePrecision] * N[(1.0 - N[(v * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(2.0 - N[(6.0 * N[(v * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{4}{\left(\left(3 \cdot \pi\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}}
\end{array}

Alternative 1: 100.0% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \frac{-1.3333333333333333}{\mathsf{fma}\left(v, v, -1\right) \cdot \left(\pi \cdot \sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)}\right)} \end{array} \]
(FPCore (v)
 :precision binary64
 (/
  -1.3333333333333333
  (* (fma v v -1.0) (* PI (sqrt (fma -6.0 (* v v) 2.0))))))
double code(double v) {
	return -1.3333333333333333 / (fma(v, v, -1.0) * (((double) M_PI) * sqrt(fma(-6.0, (v * v), 2.0))));
}
function code(v)
	return Float64(-1.3333333333333333 / Float64(fma(v, v, -1.0) * Float64(pi * sqrt(fma(-6.0, Float64(v * v), 2.0)))))
end
code[v_] := N[(-1.3333333333333333 / N[(N[(v * v + -1.0), $MachinePrecision] * N[(Pi * N[Sqrt[N[(-6.0 * N[(v * v), $MachinePrecision] + 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{-1.3333333333333333}{\mathsf{fma}\left(v, v, -1\right) \cdot \left(\pi \cdot \sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)}\right)}
\end{array}
Derivation
  1. Initial program 98.5%

    \[\frac{4}{\left(\left(3 \cdot \pi\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}} \]
  2. Step-by-step derivation
    1. lift-/.f64N/A

      \[\leadsto \color{blue}{\frac{4}{\left(\left(3 \cdot \pi\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}}} \]
    2. lift-*.f64N/A

      \[\leadsto \frac{4}{\color{blue}{\left(\left(3 \cdot \pi\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}}} \]
    3. lift-*.f64N/A

      \[\leadsto \frac{4}{\color{blue}{\left(\left(3 \cdot \pi\right) \cdot \left(1 - v \cdot v\right)\right)} \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}} \]
    4. lift-*.f64N/A

      \[\leadsto \frac{4}{\left(\color{blue}{\left(3 \cdot \pi\right)} \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}} \]
    5. associate-*l*N/A

      \[\leadsto \frac{4}{\color{blue}{\left(3 \cdot \left(\pi \cdot \left(1 - v \cdot v\right)\right)\right)} \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}} \]
    6. associate-*l*N/A

      \[\leadsto \frac{4}{\color{blue}{3 \cdot \left(\left(\pi \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}\right)}} \]
    7. associate-/r*N/A

      \[\leadsto \color{blue}{\frac{\frac{4}{3}}{\left(\pi \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}}} \]
    8. lower-/.f64N/A

      \[\leadsto \color{blue}{\frac{\frac{4}{3}}{\left(\pi \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}}} \]
    9. metadata-evalN/A

      \[\leadsto \frac{\color{blue}{\frac{4}{3}}}{\left(\pi \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}} \]
    10. associate-*l*N/A

      \[\leadsto \frac{\frac{4}{3}}{\color{blue}{\pi \cdot \left(\left(1 - v \cdot v\right) \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}\right)}} \]
    11. *-commutativeN/A

      \[\leadsto \frac{\frac{4}{3}}{\color{blue}{\left(\left(1 - v \cdot v\right) \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}\right) \cdot \pi}} \]
    12. lower-*.f64N/A

      \[\leadsto \frac{\frac{4}{3}}{\color{blue}{\left(\left(1 - v \cdot v\right) \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}\right) \cdot \pi}} \]
  3. Applied rewrites100.0%

    \[\leadsto \color{blue}{\frac{1.3333333333333333}{\left(\sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)} \cdot \left(1 - v \cdot v\right)\right) \cdot \pi}} \]
  4. Step-by-step derivation
    1. lift-/.f64N/A

      \[\leadsto \color{blue}{\frac{\frac{4}{3}}{\left(\sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)} \cdot \left(1 - v \cdot v\right)\right) \cdot \pi}} \]
    2. frac-2negN/A

      \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(\frac{4}{3}\right)}{\mathsf{neg}\left(\left(\sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)} \cdot \left(1 - v \cdot v\right)\right) \cdot \pi\right)}} \]
    3. metadata-evalN/A

      \[\leadsto \frac{\color{blue}{\frac{-4}{3}}}{\mathsf{neg}\left(\left(\sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)} \cdot \left(1 - v \cdot v\right)\right) \cdot \pi\right)} \]
    4. lower-/.f64N/A

      \[\leadsto \color{blue}{\frac{\frac{-4}{3}}{\mathsf{neg}\left(\left(\sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)} \cdot \left(1 - v \cdot v\right)\right) \cdot \pi\right)}} \]
    5. lift-*.f64N/A

      \[\leadsto \frac{\frac{-4}{3}}{\mathsf{neg}\left(\color{blue}{\left(\sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)} \cdot \left(1 - v \cdot v\right)\right) \cdot \pi}\right)} \]
    6. *-commutativeN/A

      \[\leadsto \frac{\frac{-4}{3}}{\mathsf{neg}\left(\color{blue}{\pi \cdot \left(\sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)} \cdot \left(1 - v \cdot v\right)\right)}\right)} \]
    7. distribute-rgt-neg-inN/A

      \[\leadsto \frac{\frac{-4}{3}}{\color{blue}{\pi \cdot \left(\mathsf{neg}\left(\sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)} \cdot \left(1 - v \cdot v\right)\right)\right)}} \]
    8. lift-*.f64N/A

      \[\leadsto \frac{\frac{-4}{3}}{\pi \cdot \left(\mathsf{neg}\left(\color{blue}{\sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)} \cdot \left(1 - v \cdot v\right)}\right)\right)} \]
    9. *-commutativeN/A

      \[\leadsto \frac{\frac{-4}{3}}{\pi \cdot \left(\mathsf{neg}\left(\color{blue}{\left(1 - v \cdot v\right) \cdot \sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)}}\right)\right)} \]
    10. distribute-lft-neg-outN/A

      \[\leadsto \frac{\frac{-4}{3}}{\pi \cdot \color{blue}{\left(\left(\mathsf{neg}\left(\left(1 - v \cdot v\right)\right)\right) \cdot \sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)}\right)}} \]
    11. lift--.f64N/A

      \[\leadsto \frac{\frac{-4}{3}}{\pi \cdot \left(\left(\mathsf{neg}\left(\color{blue}{\left(1 - v \cdot v\right)}\right)\right) \cdot \sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)}\right)} \]
    12. sub-negate-revN/A

      \[\leadsto \frac{\frac{-4}{3}}{\pi \cdot \left(\color{blue}{\left(v \cdot v - 1\right)} \cdot \sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)}\right)} \]
    13. metadata-evalN/A

      \[\leadsto \frac{\frac{-4}{3}}{\pi \cdot \left(\left(v \cdot v - \color{blue}{\left(\mathsf{neg}\left(-1\right)\right)}\right) \cdot \sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)}\right)} \]
    14. add-flipN/A

      \[\leadsto \frac{\frac{-4}{3}}{\pi \cdot \left(\color{blue}{\left(v \cdot v + -1\right)} \cdot \sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)}\right)} \]
    15. lift-*.f64N/A

      \[\leadsto \frac{\frac{-4}{3}}{\pi \cdot \left(\left(\color{blue}{v \cdot v} + -1\right) \cdot \sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)}\right)} \]
    16. lift-fma.f64N/A

      \[\leadsto \frac{\frac{-4}{3}}{\pi \cdot \left(\color{blue}{\mathsf{fma}\left(v, v, -1\right)} \cdot \sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)}\right)} \]
  5. Applied rewrites100.0%

    \[\leadsto \color{blue}{\frac{-1.3333333333333333}{\left(\mathsf{fma}\left(v, v, -1\right) \cdot \pi\right) \cdot \sqrt{\mathsf{fma}\left(v \cdot v, -6, 2\right)}}} \]
  6. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto \frac{\frac{-4}{3}}{\color{blue}{\left(\mathsf{fma}\left(v, v, -1\right) \cdot \pi\right) \cdot \sqrt{\mathsf{fma}\left(v \cdot v, -6, 2\right)}}} \]
    2. lift-*.f64N/A

      \[\leadsto \frac{\frac{-4}{3}}{\color{blue}{\left(\mathsf{fma}\left(v, v, -1\right) \cdot \pi\right)} \cdot \sqrt{\mathsf{fma}\left(v \cdot v, -6, 2\right)}} \]
    3. associate-*l*N/A

      \[\leadsto \frac{\frac{-4}{3}}{\color{blue}{\mathsf{fma}\left(v, v, -1\right) \cdot \left(\pi \cdot \sqrt{\mathsf{fma}\left(v \cdot v, -6, 2\right)}\right)}} \]
    4. lift-*.f64N/A

      \[\leadsto \frac{\frac{-4}{3}}{\mathsf{fma}\left(v, v, -1\right) \cdot \color{blue}{\left(\pi \cdot \sqrt{\mathsf{fma}\left(v \cdot v, -6, 2\right)}\right)}} \]
    5. lower-*.f64100.0

      \[\leadsto \frac{-1.3333333333333333}{\color{blue}{\mathsf{fma}\left(v, v, -1\right) \cdot \left(\pi \cdot \sqrt{\mathsf{fma}\left(v \cdot v, -6, 2\right)}\right)}} \]
    6. lift-fma.f64N/A

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

      \[\leadsto \frac{\frac{-4}{3}}{\mathsf{fma}\left(v, v, -1\right) \cdot \left(\pi \cdot \sqrt{\color{blue}{-6 \cdot \left(v \cdot v\right)} + 2}\right)} \]
    8. lift-fma.f64100.0

      \[\leadsto \frac{-1.3333333333333333}{\mathsf{fma}\left(v, v, -1\right) \cdot \left(\pi \cdot \sqrt{\color{blue}{\mathsf{fma}\left(-6, v \cdot v, 2\right)}}\right)} \]
  7. Applied rewrites100.0%

    \[\leadsto \frac{-1.3333333333333333}{\color{blue}{\mathsf{fma}\left(v, v, -1\right) \cdot \left(\pi \cdot \sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)}\right)}} \]
  8. Add Preprocessing

Alternative 2: 100.0% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \frac{-1.3333333333333333}{\left(\mathsf{fma}\left(v, v, -1\right) \cdot \pi\right) \cdot \sqrt{\mathsf{fma}\left(v \cdot v, -6, 2\right)}} \end{array} \]
(FPCore (v)
 :precision binary64
 (/
  -1.3333333333333333
  (* (* (fma v v -1.0) PI) (sqrt (fma (* v v) -6.0 2.0)))))
double code(double v) {
	return -1.3333333333333333 / ((fma(v, v, -1.0) * ((double) M_PI)) * sqrt(fma((v * v), -6.0, 2.0)));
}
function code(v)
	return Float64(-1.3333333333333333 / Float64(Float64(fma(v, v, -1.0) * pi) * sqrt(fma(Float64(v * v), -6.0, 2.0))))
end
code[v_] := N[(-1.3333333333333333 / N[(N[(N[(v * v + -1.0), $MachinePrecision] * Pi), $MachinePrecision] * N[Sqrt[N[(N[(v * v), $MachinePrecision] * -6.0 + 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{-1.3333333333333333}{\left(\mathsf{fma}\left(v, v, -1\right) \cdot \pi\right) \cdot \sqrt{\mathsf{fma}\left(v \cdot v, -6, 2\right)}}
\end{array}
Derivation
  1. Initial program 98.5%

    \[\frac{4}{\left(\left(3 \cdot \pi\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}} \]
  2. Step-by-step derivation
    1. lift-/.f64N/A

      \[\leadsto \color{blue}{\frac{4}{\left(\left(3 \cdot \pi\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}}} \]
    2. lift-*.f64N/A

      \[\leadsto \frac{4}{\color{blue}{\left(\left(3 \cdot \pi\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}}} \]
    3. lift-*.f64N/A

      \[\leadsto \frac{4}{\color{blue}{\left(\left(3 \cdot \pi\right) \cdot \left(1 - v \cdot v\right)\right)} \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}} \]
    4. lift-*.f64N/A

      \[\leadsto \frac{4}{\left(\color{blue}{\left(3 \cdot \pi\right)} \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}} \]
    5. associate-*l*N/A

      \[\leadsto \frac{4}{\color{blue}{\left(3 \cdot \left(\pi \cdot \left(1 - v \cdot v\right)\right)\right)} \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}} \]
    6. associate-*l*N/A

      \[\leadsto \frac{4}{\color{blue}{3 \cdot \left(\left(\pi \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}\right)}} \]
    7. associate-/r*N/A

      \[\leadsto \color{blue}{\frac{\frac{4}{3}}{\left(\pi \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}}} \]
    8. lower-/.f64N/A

      \[\leadsto \color{blue}{\frac{\frac{4}{3}}{\left(\pi \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}}} \]
    9. metadata-evalN/A

      \[\leadsto \frac{\color{blue}{\frac{4}{3}}}{\left(\pi \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}} \]
    10. associate-*l*N/A

      \[\leadsto \frac{\frac{4}{3}}{\color{blue}{\pi \cdot \left(\left(1 - v \cdot v\right) \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}\right)}} \]
    11. *-commutativeN/A

      \[\leadsto \frac{\frac{4}{3}}{\color{blue}{\left(\left(1 - v \cdot v\right) \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}\right) \cdot \pi}} \]
    12. lower-*.f64N/A

      \[\leadsto \frac{\frac{4}{3}}{\color{blue}{\left(\left(1 - v \cdot v\right) \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}\right) \cdot \pi}} \]
  3. Applied rewrites100.0%

    \[\leadsto \color{blue}{\frac{1.3333333333333333}{\left(\sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)} \cdot \left(1 - v \cdot v\right)\right) \cdot \pi}} \]
  4. Step-by-step derivation
    1. lift-/.f64N/A

      \[\leadsto \color{blue}{\frac{\frac{4}{3}}{\left(\sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)} \cdot \left(1 - v \cdot v\right)\right) \cdot \pi}} \]
    2. frac-2negN/A

      \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(\frac{4}{3}\right)}{\mathsf{neg}\left(\left(\sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)} \cdot \left(1 - v \cdot v\right)\right) \cdot \pi\right)}} \]
    3. metadata-evalN/A

      \[\leadsto \frac{\color{blue}{\frac{-4}{3}}}{\mathsf{neg}\left(\left(\sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)} \cdot \left(1 - v \cdot v\right)\right) \cdot \pi\right)} \]
    4. lower-/.f64N/A

      \[\leadsto \color{blue}{\frac{\frac{-4}{3}}{\mathsf{neg}\left(\left(\sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)} \cdot \left(1 - v \cdot v\right)\right) \cdot \pi\right)}} \]
    5. lift-*.f64N/A

      \[\leadsto \frac{\frac{-4}{3}}{\mathsf{neg}\left(\color{blue}{\left(\sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)} \cdot \left(1 - v \cdot v\right)\right) \cdot \pi}\right)} \]
    6. *-commutativeN/A

      \[\leadsto \frac{\frac{-4}{3}}{\mathsf{neg}\left(\color{blue}{\pi \cdot \left(\sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)} \cdot \left(1 - v \cdot v\right)\right)}\right)} \]
    7. distribute-rgt-neg-inN/A

      \[\leadsto \frac{\frac{-4}{3}}{\color{blue}{\pi \cdot \left(\mathsf{neg}\left(\sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)} \cdot \left(1 - v \cdot v\right)\right)\right)}} \]
    8. lift-*.f64N/A

      \[\leadsto \frac{\frac{-4}{3}}{\pi \cdot \left(\mathsf{neg}\left(\color{blue}{\sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)} \cdot \left(1 - v \cdot v\right)}\right)\right)} \]
    9. *-commutativeN/A

      \[\leadsto \frac{\frac{-4}{3}}{\pi \cdot \left(\mathsf{neg}\left(\color{blue}{\left(1 - v \cdot v\right) \cdot \sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)}}\right)\right)} \]
    10. distribute-lft-neg-outN/A

      \[\leadsto \frac{\frac{-4}{3}}{\pi \cdot \color{blue}{\left(\left(\mathsf{neg}\left(\left(1 - v \cdot v\right)\right)\right) \cdot \sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)}\right)}} \]
    11. lift--.f64N/A

      \[\leadsto \frac{\frac{-4}{3}}{\pi \cdot \left(\left(\mathsf{neg}\left(\color{blue}{\left(1 - v \cdot v\right)}\right)\right) \cdot \sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)}\right)} \]
    12. sub-negate-revN/A

      \[\leadsto \frac{\frac{-4}{3}}{\pi \cdot \left(\color{blue}{\left(v \cdot v - 1\right)} \cdot \sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)}\right)} \]
    13. metadata-evalN/A

      \[\leadsto \frac{\frac{-4}{3}}{\pi \cdot \left(\left(v \cdot v - \color{blue}{\left(\mathsf{neg}\left(-1\right)\right)}\right) \cdot \sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)}\right)} \]
    14. add-flipN/A

      \[\leadsto \frac{\frac{-4}{3}}{\pi \cdot \left(\color{blue}{\left(v \cdot v + -1\right)} \cdot \sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)}\right)} \]
    15. lift-*.f64N/A

      \[\leadsto \frac{\frac{-4}{3}}{\pi \cdot \left(\left(\color{blue}{v \cdot v} + -1\right) \cdot \sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)}\right)} \]
    16. lift-fma.f64N/A

      \[\leadsto \frac{\frac{-4}{3}}{\pi \cdot \left(\color{blue}{\mathsf{fma}\left(v, v, -1\right)} \cdot \sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)}\right)} \]
  5. Applied rewrites100.0%

    \[\leadsto \color{blue}{\frac{-1.3333333333333333}{\left(\mathsf{fma}\left(v, v, -1\right) \cdot \pi\right) \cdot \sqrt{\mathsf{fma}\left(v \cdot v, -6, 2\right)}}} \]
  6. Add Preprocessing

Alternative 3: 98.9% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \frac{1.3333333333333333}{\pi \cdot \sqrt{\mathsf{fma}\left(v \cdot v, -6, 2\right)}} \end{array} \]
(FPCore (v)
 :precision binary64
 (/ 1.3333333333333333 (* PI (sqrt (fma (* v v) -6.0 2.0)))))
double code(double v) {
	return 1.3333333333333333 / (((double) M_PI) * sqrt(fma((v * v), -6.0, 2.0)));
}
function code(v)
	return Float64(1.3333333333333333 / Float64(pi * sqrt(fma(Float64(v * v), -6.0, 2.0))))
end
code[v_] := N[(1.3333333333333333 / N[(Pi * N[Sqrt[N[(N[(v * v), $MachinePrecision] * -6.0 + 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{1.3333333333333333}{\pi \cdot \sqrt{\mathsf{fma}\left(v \cdot v, -6, 2\right)}}
\end{array}
Derivation
  1. Initial program 98.5%

    \[\frac{4}{\left(\left(3 \cdot \pi\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}} \]
  2. Step-by-step derivation
    1. lift-/.f64N/A

      \[\leadsto \color{blue}{\frac{4}{\left(\left(3 \cdot \pi\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}}} \]
    2. lift-*.f64N/A

      \[\leadsto \frac{4}{\color{blue}{\left(\left(3 \cdot \pi\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}}} \]
    3. lift-*.f64N/A

      \[\leadsto \frac{4}{\color{blue}{\left(\left(3 \cdot \pi\right) \cdot \left(1 - v \cdot v\right)\right)} \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}} \]
    4. lift-*.f64N/A

      \[\leadsto \frac{4}{\left(\color{blue}{\left(3 \cdot \pi\right)} \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}} \]
    5. associate-*l*N/A

      \[\leadsto \frac{4}{\color{blue}{\left(3 \cdot \left(\pi \cdot \left(1 - v \cdot v\right)\right)\right)} \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}} \]
    6. associate-*l*N/A

      \[\leadsto \frac{4}{\color{blue}{3 \cdot \left(\left(\pi \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}\right)}} \]
    7. associate-/r*N/A

      \[\leadsto \color{blue}{\frac{\frac{4}{3}}{\left(\pi \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}}} \]
    8. lower-/.f64N/A

      \[\leadsto \color{blue}{\frac{\frac{4}{3}}{\left(\pi \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}}} \]
    9. metadata-evalN/A

      \[\leadsto \frac{\color{blue}{\frac{4}{3}}}{\left(\pi \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}} \]
    10. associate-*l*N/A

      \[\leadsto \frac{\frac{4}{3}}{\color{blue}{\pi \cdot \left(\left(1 - v \cdot v\right) \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}\right)}} \]
    11. *-commutativeN/A

      \[\leadsto \frac{\frac{4}{3}}{\color{blue}{\left(\left(1 - v \cdot v\right) \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}\right) \cdot \pi}} \]
    12. lower-*.f64N/A

      \[\leadsto \frac{\frac{4}{3}}{\color{blue}{\left(\left(1 - v \cdot v\right) \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}\right) \cdot \pi}} \]
  3. Applied rewrites100.0%

    \[\leadsto \color{blue}{\frac{1.3333333333333333}{\left(\sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)} \cdot \left(1 - v \cdot v\right)\right) \cdot \pi}} \]
  4. Step-by-step derivation
    1. lift-/.f64N/A

      \[\leadsto \color{blue}{\frac{\frac{4}{3}}{\left(\sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)} \cdot \left(1 - v \cdot v\right)\right) \cdot \pi}} \]
    2. lift-*.f64N/A

      \[\leadsto \frac{\frac{4}{3}}{\color{blue}{\left(\sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)} \cdot \left(1 - v \cdot v\right)\right) \cdot \pi}} \]
    3. *-commutativeN/A

      \[\leadsto \frac{\frac{4}{3}}{\color{blue}{\pi \cdot \left(\sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)} \cdot \left(1 - v \cdot v\right)\right)}} \]
    4. lift-*.f64N/A

      \[\leadsto \frac{\frac{4}{3}}{\pi \cdot \color{blue}{\left(\sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)} \cdot \left(1 - v \cdot v\right)\right)}} \]
    5. *-commutativeN/A

      \[\leadsto \frac{\frac{4}{3}}{\pi \cdot \color{blue}{\left(\left(1 - v \cdot v\right) \cdot \sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)}\right)}} \]
    6. associate-*r*N/A

      \[\leadsto \frac{\frac{4}{3}}{\color{blue}{\left(\pi \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)}}} \]
    7. lift--.f64N/A

      \[\leadsto \frac{\frac{4}{3}}{\left(\pi \cdot \color{blue}{\left(1 - v \cdot v\right)}\right) \cdot \sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)}} \]
    8. sub-negate-revN/A

      \[\leadsto \frac{\frac{4}{3}}{\left(\pi \cdot \color{blue}{\left(\mathsf{neg}\left(\left(v \cdot v - 1\right)\right)\right)}\right) \cdot \sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)}} \]
    9. metadata-evalN/A

      \[\leadsto \frac{\frac{4}{3}}{\left(\pi \cdot \left(\mathsf{neg}\left(\left(v \cdot v - \color{blue}{\left(\mathsf{neg}\left(-1\right)\right)}\right)\right)\right)\right) \cdot \sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)}} \]
    10. add-flipN/A

      \[\leadsto \frac{\frac{4}{3}}{\left(\pi \cdot \left(\mathsf{neg}\left(\color{blue}{\left(v \cdot v + -1\right)}\right)\right)\right) \cdot \sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)}} \]
    11. lift-*.f64N/A

      \[\leadsto \frac{\frac{4}{3}}{\left(\pi \cdot \left(\mathsf{neg}\left(\left(\color{blue}{v \cdot v} + -1\right)\right)\right)\right) \cdot \sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)}} \]
    12. lift-fma.f64N/A

      \[\leadsto \frac{\frac{4}{3}}{\left(\pi \cdot \left(\mathsf{neg}\left(\color{blue}{\mathsf{fma}\left(v, v, -1\right)}\right)\right)\right) \cdot \sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)}} \]
    13. distribute-rgt-neg-outN/A

      \[\leadsto \frac{\frac{4}{3}}{\color{blue}{\left(\mathsf{neg}\left(\pi \cdot \mathsf{fma}\left(v, v, -1\right)\right)\right)} \cdot \sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)}} \]
    14. *-commutativeN/A

      \[\leadsto \frac{\frac{4}{3}}{\left(\mathsf{neg}\left(\color{blue}{\mathsf{fma}\left(v, v, -1\right) \cdot \pi}\right)\right) \cdot \sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)}} \]
    15. lift-*.f64N/A

      \[\leadsto \frac{\frac{4}{3}}{\left(\mathsf{neg}\left(\color{blue}{\mathsf{fma}\left(v, v, -1\right) \cdot \pi}\right)\right) \cdot \sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)}} \]
  5. Applied rewrites100.0%

    \[\leadsto \color{blue}{\frac{\frac{-1.3333333333333333}{\mathsf{fma}\left(v, v, -1\right)}}{\pi \cdot \sqrt{\mathsf{fma}\left(v \cdot v, -6, 2\right)}}} \]
  6. Taylor expanded in v around 0

    \[\leadsto \frac{\color{blue}{\frac{4}{3}}}{\pi \cdot \sqrt{\mathsf{fma}\left(v \cdot v, -6, 2\right)}} \]
  7. Step-by-step derivation
    1. Applied rewrites98.9%

      \[\leadsto \frac{\color{blue}{1.3333333333333333}}{\pi \cdot \sqrt{\mathsf{fma}\left(v \cdot v, -6, 2\right)}} \]
    2. Add Preprocessing

    Alternative 4: 98.8% accurate, 3.2× speedup?

    \[\begin{array}{l} \\ \frac{1.3333333333333333}{\pi \cdot \sqrt{2}} \end{array} \]
    (FPCore (v) :precision binary64 (/ 1.3333333333333333 (* PI (sqrt 2.0))))
    double code(double v) {
    	return 1.3333333333333333 / (((double) M_PI) * sqrt(2.0));
    }
    
    public static double code(double v) {
    	return 1.3333333333333333 / (Math.PI * Math.sqrt(2.0));
    }
    
    def code(v):
    	return 1.3333333333333333 / (math.pi * math.sqrt(2.0))
    
    function code(v)
    	return Float64(1.3333333333333333 / Float64(pi * sqrt(2.0)))
    end
    
    function tmp = code(v)
    	tmp = 1.3333333333333333 / (pi * sqrt(2.0));
    end
    
    code[v_] := N[(1.3333333333333333 / N[(Pi * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    \frac{1.3333333333333333}{\pi \cdot \sqrt{2}}
    \end{array}
    
    Derivation
    1. Initial program 98.5%

      \[\frac{4}{\left(\left(3 \cdot \pi\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}} \]
    2. Taylor expanded in v around 0

      \[\leadsto \color{blue}{\frac{\frac{4}{3}}{\mathsf{PI}\left(\right) \cdot \sqrt{2}}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{\frac{4}{3}}{\color{blue}{\mathsf{PI}\left(\right) \cdot \sqrt{2}}} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{\frac{4}{3}}{\mathsf{PI}\left(\right) \cdot \color{blue}{\sqrt{2}}} \]
      3. lower-PI.f64N/A

        \[\leadsto \frac{\frac{4}{3}}{\pi \cdot \sqrt{\color{blue}{2}}} \]
      4. lower-sqrt.f6498.8

        \[\leadsto \frac{1.3333333333333333}{\pi \cdot \sqrt{2}} \]
    4. Applied rewrites98.8%

      \[\leadsto \color{blue}{\frac{1.3333333333333333}{\pi \cdot \sqrt{2}}} \]
    5. Add Preprocessing

    Reproduce

    ?
    herbie shell --seed 2025155 
    (FPCore (v)
      :name "Falkner and Boettcher, Equation (22+)"
      :precision binary64
      (/ 4.0 (* (* (* 3.0 PI) (- 1.0 (* v v))) (sqrt (- 2.0 (* 6.0 (* v v)))))))