Falkner and Boettcher, Equation (22+)

Percentage Accurate: 98.5% → 100.0%
Time: 10.3s
Alternatives: 5
Speedup: 2.1×

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}

Sampling outcomes in binary64 precision:

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 5 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.1× speedup?

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

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

    \[\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. Add Preprocessing
  3. Step-by-step derivation
    1. sub-negN/A

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

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

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

      \[\leadsto \frac{4}{\left(\left(3 \cdot \mathsf{PI}\left(\right)\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{\color{blue}{\left(v \cdot v\right) \cdot \left(\mathsf{neg}\left(6\right)\right)} + 2}} \]
    5. accelerator-lowering-fma.f64N/A

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

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

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

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

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

      \[\leadsto \frac{\frac{4}{\left(3 \cdot \mathsf{PI}\left(\right)\right) \cdot \left(1 - v \cdot v\right)}}{\sqrt{\color{blue}{v \cdot \left(v \cdot -6\right)} + 2}} \]
    3. div-invN/A

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{4}{3}}}{\left(\mathsf{PI}\left(\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{v \cdot \left(v \cdot -6\right) + 2}} \]
    9. /-lowering-/.f64N/A

      \[\leadsto \color{blue}{\frac{\frac{4}{3}}{\left(\mathsf{PI}\left(\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{v \cdot \left(v \cdot -6\right) + 2}}} \]
    10. *-lowering-*.f64N/A

      \[\leadsto \frac{\frac{4}{3}}{\color{blue}{\left(\mathsf{PI}\left(\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{v \cdot \left(v \cdot -6\right) + 2}}} \]
  6. Applied egg-rr100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{1.3333333333333333}{\color{blue}{\left(\pi - \left(v \cdot v\right) \cdot \pi\right)} \cdot \sqrt{\mathsf{fma}\left(v, v \cdot -6, 2\right)}} \]
  11. Final simplification100.0%

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

Alternative 2: 100.0% accurate, 1.1× speedup?

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

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

    \[\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. Add Preprocessing
  3. Step-by-step derivation
    1. sub-negN/A

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

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

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

      \[\leadsto \frac{4}{\left(\left(3 \cdot \mathsf{PI}\left(\right)\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{\color{blue}{\left(v \cdot v\right) \cdot \left(\mathsf{neg}\left(6\right)\right)} + 2}} \]
    5. accelerator-lowering-fma.f64N/A

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

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

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

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

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

      \[\leadsto \frac{\frac{4}{\left(3 \cdot \mathsf{PI}\left(\right)\right) \cdot \left(1 - v \cdot v\right)}}{\sqrt{\color{blue}{v \cdot \left(v \cdot -6\right)} + 2}} \]
    3. div-invN/A

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{4}{3}}}{\left(\mathsf{PI}\left(\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{v \cdot \left(v \cdot -6\right) + 2}} \]
    9. /-lowering-/.f64N/A

      \[\leadsto \color{blue}{\frac{\frac{4}{3}}{\left(\mathsf{PI}\left(\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{v \cdot \left(v \cdot -6\right) + 2}}} \]
    10. *-lowering-*.f64N/A

      \[\leadsto \frac{\frac{4}{3}}{\color{blue}{\left(\mathsf{PI}\left(\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{v \cdot \left(v \cdot -6\right) + 2}}} \]
  6. Applied egg-rr100.0%

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

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

Alternative 3: 98.9% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \frac{1.3333333333333333}{\pi \cdot \sqrt{\mathsf{fma}\left(v, v \cdot -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(v, Float64(v * -6.0), 2.0))))
end
code[v_] := N[(1.3333333333333333 / N[(Pi * N[Sqrt[N[(v * N[(v * -6.0), $MachinePrecision] + 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

    \[\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. Add Preprocessing
  3. Applied egg-rr99.5%

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

    \[\leadsto \frac{\frac{4}{3}}{\sqrt{\mathsf{fma}\left(v, v \cdot -6, 2\right)} \cdot \color{blue}{\mathsf{PI}\left(\right)}} \]
  5. Step-by-step derivation
    1. PI-lowering-PI.f6499.5

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

    \[\leadsto \frac{1.3333333333333333}{\sqrt{\mathsf{fma}\left(v, v \cdot -6, 2\right)} \cdot \color{blue}{\pi}} \]
  7. Final simplification99.5%

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

Alternative 4: 98.8% accurate, 2.1× 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.4%

    \[\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. Add Preprocessing
  3. Applied egg-rr99.5%

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

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

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

      \[\leadsto \frac{\frac{4}{3}}{\color{blue}{\mathsf{PI}\left(\right)} \cdot \sqrt{2}} \]
    3. sqrt-lowering-sqrt.f6499.5

      \[\leadsto \frac{1.3333333333333333}{\pi \cdot \color{blue}{\sqrt{2}}} \]
  6. Simplified99.5%

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

Alternative 5: 97.3% accurate, 2.1× speedup?

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

\\
1.3333333333333333 \cdot \frac{\sqrt{0.5}}{\pi}
\end{array}
Derivation
  1. Initial program 98.4%

    \[\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. Add Preprocessing
  3. Taylor expanded in v around 0

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

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

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

      \[\leadsto \frac{4}{3} \cdot \frac{\color{blue}{\sqrt{\frac{1}{2}}}}{\mathsf{PI}\left(\right)} \]
    4. PI-lowering-PI.f6498.0

      \[\leadsto 1.3333333333333333 \cdot \frac{\sqrt{0.5}}{\color{blue}{\pi}} \]
  5. Simplified98.0%

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

Reproduce

?
herbie shell --seed 2024196 
(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)))))))