| Alternative 1 | |
|---|---|
| Error | 0.5 |
| Cost | 26304 |
\[e^{\log \cos^{-1} \left(\frac{1 - \left(v \cdot v\right) \cdot 5}{\mathsf{fma}\left(v, v, -1\right)}\right)}
\]
(FPCore (v) :precision binary64 (acos (/ (- 1.0 (* 5.0 (* v v))) (- (* v v) 1.0))))
(FPCore (v) :precision binary64 (exp (log (- (* PI 0.5) (asin (/ (+ -1.0 (* (* v v) 5.0)) (- 1.0 (* v v))))))))
double code(double v) {
return acos(((1.0 - (5.0 * (v * v))) / ((v * v) - 1.0)));
}
double code(double v) {
return exp(log(((((double) M_PI) * 0.5) - asin(((-1.0 + ((v * v) * 5.0)) / (1.0 - (v * v)))))));
}
public static double code(double v) {
return Math.acos(((1.0 - (5.0 * (v * v))) / ((v * v) - 1.0)));
}
public static double code(double v) {
return Math.exp(Math.log(((Math.PI * 0.5) - Math.asin(((-1.0 + ((v * v) * 5.0)) / (1.0 - (v * v)))))));
}
def code(v): return math.acos(((1.0 - (5.0 * (v * v))) / ((v * v) - 1.0)))
def code(v): return math.exp(math.log(((math.pi * 0.5) - math.asin(((-1.0 + ((v * v) * 5.0)) / (1.0 - (v * v)))))))
function code(v) return acos(Float64(Float64(1.0 - Float64(5.0 * Float64(v * v))) / Float64(Float64(v * v) - 1.0))) end
function code(v) return exp(log(Float64(Float64(pi * 0.5) - asin(Float64(Float64(-1.0 + Float64(Float64(v * v) * 5.0)) / Float64(1.0 - Float64(v * v))))))) end
function tmp = code(v) tmp = acos(((1.0 - (5.0 * (v * v))) / ((v * v) - 1.0))); end
function tmp = code(v) tmp = exp(log(((pi * 0.5) - asin(((-1.0 + ((v * v) * 5.0)) / (1.0 - (v * v))))))); end
code[v_] := N[ArcCos[N[(N[(1.0 - N[(5.0 * N[(v * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(v * v), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
code[v_] := N[Exp[N[Log[N[(N[(Pi * 0.5), $MachinePrecision] - N[ArcSin[N[(N[(-1.0 + N[(N[(v * v), $MachinePrecision] * 5.0), $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(v * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]
\cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right)
e^{\log \left(\pi \cdot 0.5 - \sin^{-1} \left(\frac{-1 + \left(v \cdot v\right) \cdot 5}{1 - v \cdot v}\right)\right)}
Results
Initial program 0.5
Applied egg-rr0.5
Applied egg-rr0.5
Applied egg-rr0.5
Simplified0.5
[Start]0.5 | \[ e^{\log \left(\pi \cdot 0.5 - \sin^{-1} \left(-\frac{\mathsf{fma}\left(v, v \cdot -5, 1\right)}{1 - v \cdot v}\right)\right)}
\] |
|---|---|
distribute-frac-neg [<=]0.5 | \[ e^{\log \left(\pi \cdot 0.5 - \sin^{-1} \color{blue}{\left(\frac{-\mathsf{fma}\left(v, v \cdot -5, 1\right)}{1 - v \cdot v}\right)}\right)}
\] |
fma-udef [=>]0.5 | \[ e^{\log \left(\pi \cdot 0.5 - \sin^{-1} \left(\frac{-\color{blue}{\left(v \cdot \left(v \cdot -5\right) + 1\right)}}{1 - v \cdot v}\right)\right)}
\] |
distribute-neg-in [=>]0.5 | \[ e^{\log \left(\pi \cdot 0.5 - \sin^{-1} \left(\frac{\color{blue}{\left(-v \cdot \left(v \cdot -5\right)\right) + \left(-1\right)}}{1 - v \cdot v}\right)\right)}
\] |
metadata-eval [=>]0.5 | \[ e^{\log \left(\pi \cdot 0.5 - \sin^{-1} \left(\frac{\left(-v \cdot \left(v \cdot -5\right)\right) + \color{blue}{-1}}{1 - v \cdot v}\right)\right)}
\] |
+-commutative [<=]0.5 | \[ e^{\log \left(\pi \cdot 0.5 - \sin^{-1} \left(\frac{\color{blue}{-1 + \left(-v \cdot \left(v \cdot -5\right)\right)}}{1 - v \cdot v}\right)\right)}
\] |
associate-*r* [=>]0.5 | \[ e^{\log \left(\pi \cdot 0.5 - \sin^{-1} \left(\frac{-1 + \left(-\color{blue}{\left(v \cdot v\right) \cdot -5}\right)}{1 - v \cdot v}\right)\right)}
\] |
unpow2 [<=]0.5 | \[ e^{\log \left(\pi \cdot 0.5 - \sin^{-1} \left(\frac{-1 + \left(-\color{blue}{{v}^{2}} \cdot -5\right)}{1 - v \cdot v}\right)\right)}
\] |
distribute-rgt-neg-in [=>]0.5 | \[ e^{\log \left(\pi \cdot 0.5 - \sin^{-1} \left(\frac{-1 + \color{blue}{{v}^{2} \cdot \left(--5\right)}}{1 - v \cdot v}\right)\right)}
\] |
unpow2 [=>]0.5 | \[ e^{\log \left(\pi \cdot 0.5 - \sin^{-1} \left(\frac{-1 + \color{blue}{\left(v \cdot v\right)} \cdot \left(--5\right)}{1 - v \cdot v}\right)\right)}
\] |
metadata-eval [=>]0.5 | \[ e^{\log \left(\pi \cdot 0.5 - \sin^{-1} \left(\frac{-1 + \left(v \cdot v\right) \cdot \color{blue}{5}}{1 - v \cdot v}\right)\right)}
\] |
Final simplification0.5
| Alternative 1 | |
|---|---|
| Error | 0.5 |
| Cost | 26304 |
| Alternative 2 | |
|---|---|
| Error | 0.5 |
| Cost | 20096 |
| Alternative 3 | |
|---|---|
| Error | 0.5 |
| Cost | 7232 |
| Alternative 4 | |
|---|---|
| Error | 1.2 |
| Cost | 6848 |
| Alternative 5 | |
|---|---|
| Error | 1.2 |
| Cost | 6464 |
herbie shell --seed 2023027
(FPCore (v)
:name "Falkner and Boettcher, Appendix B, 1"
:precision binary64
(acos (/ (- 1.0 (* 5.0 (* v v))) (- (* v v) 1.0))))