| Alternative 1 | |
|---|---|
| Accuracy | 99.1% |
| Cost | 6976 |
\[\left(1 - v \cdot v\right) \cdot \left(0.25 \cdot \sqrt{2}\right)
\]
(FPCore (v) :precision binary64 (* (* (/ (sqrt 2.0) 4.0) (sqrt (- 1.0 (* 3.0 (* v v))))) (- 1.0 (* v v))))
(FPCore (v) :precision binary64 (* (sqrt (+ 0.125 (* v (* v -0.375)))) (- 1.0 (* v v))))
double code(double v) {
return ((sqrt(2.0) / 4.0) * sqrt((1.0 - (3.0 * (v * v))))) * (1.0 - (v * v));
}
double code(double v) {
return sqrt((0.125 + (v * (v * -0.375)))) * (1.0 - (v * v));
}
real(8) function code(v)
real(8), intent (in) :: v
code = ((sqrt(2.0d0) / 4.0d0) * sqrt((1.0d0 - (3.0d0 * (v * v))))) * (1.0d0 - (v * v))
end function
real(8) function code(v)
real(8), intent (in) :: v
code = sqrt((0.125d0 + (v * (v * (-0.375d0))))) * (1.0d0 - (v * v))
end function
public static double code(double v) {
return ((Math.sqrt(2.0) / 4.0) * Math.sqrt((1.0 - (3.0 * (v * v))))) * (1.0 - (v * v));
}
public static double code(double v) {
return Math.sqrt((0.125 + (v * (v * -0.375)))) * (1.0 - (v * v));
}
def code(v): return ((math.sqrt(2.0) / 4.0) * math.sqrt((1.0 - (3.0 * (v * v))))) * (1.0 - (v * v))
def code(v): return math.sqrt((0.125 + (v * (v * -0.375)))) * (1.0 - (v * v))
function code(v) return Float64(Float64(Float64(sqrt(2.0) / 4.0) * sqrt(Float64(1.0 - Float64(3.0 * Float64(v * v))))) * Float64(1.0 - Float64(v * v))) end
function code(v) return Float64(sqrt(Float64(0.125 + Float64(v * Float64(v * -0.375)))) * Float64(1.0 - Float64(v * v))) end
function tmp = code(v) tmp = ((sqrt(2.0) / 4.0) * sqrt((1.0 - (3.0 * (v * v))))) * (1.0 - (v * v)); end
function tmp = code(v) tmp = sqrt((0.125 + (v * (v * -0.375)))) * (1.0 - (v * v)); end
code[v_] := N[(N[(N[(N[Sqrt[2.0], $MachinePrecision] / 4.0), $MachinePrecision] * N[Sqrt[N[(1.0 - N[(3.0 * N[(v * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(v * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[v_] := N[(N[Sqrt[N[(0.125 + N[(v * N[(v * -0.375), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 - N[(v * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(\frac{\sqrt{2}}{4} \cdot \sqrt{1 - 3 \cdot \left(v \cdot v\right)}\right) \cdot \left(1 - v \cdot v\right)
\sqrt{0.125 + v \cdot \left(v \cdot -0.375\right)} \cdot \left(1 - v \cdot v\right)
Results
Initial program 100.0%
Applied egg-rr100.0%
[Start]100.0 | \[ \left(\frac{\sqrt{2}}{4} \cdot \sqrt{1 - 3 \cdot \left(v \cdot v\right)}\right) \cdot \left(1 - v \cdot v\right)
\] |
|---|---|
add-log-exp [=>]100.0 | \[ \color{blue}{\log \left(e^{\frac{\sqrt{2}}{4} \cdot \sqrt{1 - 3 \cdot \left(v \cdot v\right)}}\right)} \cdot \left(1 - v \cdot v\right)
\] |
*-un-lft-identity [=>]100.0 | \[ \log \color{blue}{\left(1 \cdot e^{\frac{\sqrt{2}}{4} \cdot \sqrt{1 - 3 \cdot \left(v \cdot v\right)}}\right)} \cdot \left(1 - v \cdot v\right)
\] |
log-prod [=>]100.0 | \[ \color{blue}{\left(\log 1 + \log \left(e^{\frac{\sqrt{2}}{4} \cdot \sqrt{1 - 3 \cdot \left(v \cdot v\right)}}\right)\right)} \cdot \left(1 - v \cdot v\right)
\] |
metadata-eval [=>]100.0 | \[ \left(\color{blue}{0} + \log \left(e^{\frac{\sqrt{2}}{4} \cdot \sqrt{1 - 3 \cdot \left(v \cdot v\right)}}\right)\right) \cdot \left(1 - v \cdot v\right)
\] |
add-log-exp [<=]100.0 | \[ \left(0 + \color{blue}{\frac{\sqrt{2}}{4} \cdot \sqrt{1 - 3 \cdot \left(v \cdot v\right)}}\right) \cdot \left(1 - v \cdot v\right)
\] |
add-sqr-sqrt [=>]98.4 | \[ \left(0 + \color{blue}{\sqrt{\frac{\sqrt{2}}{4} \cdot \sqrt{1 - 3 \cdot \left(v \cdot v\right)}} \cdot \sqrt{\frac{\sqrt{2}}{4} \cdot \sqrt{1 - 3 \cdot \left(v \cdot v\right)}}}\right) \cdot \left(1 - v \cdot v\right)
\] |
sqrt-unprod [=>]100.0 | \[ \left(0 + \color{blue}{\sqrt{\left(\frac{\sqrt{2}}{4} \cdot \sqrt{1 - 3 \cdot \left(v \cdot v\right)}\right) \cdot \left(\frac{\sqrt{2}}{4} \cdot \sqrt{1 - 3 \cdot \left(v \cdot v\right)}\right)}}\right) \cdot \left(1 - v \cdot v\right)
\] |
*-commutative [=>]100.0 | \[ \left(0 + \sqrt{\color{blue}{\left(\sqrt{1 - 3 \cdot \left(v \cdot v\right)} \cdot \frac{\sqrt{2}}{4}\right)} \cdot \left(\frac{\sqrt{2}}{4} \cdot \sqrt{1 - 3 \cdot \left(v \cdot v\right)}\right)}\right) \cdot \left(1 - v \cdot v\right)
\] |
*-commutative [=>]100.0 | \[ \left(0 + \sqrt{\left(\sqrt{1 - 3 \cdot \left(v \cdot v\right)} \cdot \frac{\sqrt{2}}{4}\right) \cdot \color{blue}{\left(\sqrt{1 - 3 \cdot \left(v \cdot v\right)} \cdot \frac{\sqrt{2}}{4}\right)}}\right) \cdot \left(1 - v \cdot v\right)
\] |
swap-sqr [=>]100.0 | \[ \left(0 + \sqrt{\color{blue}{\left(\sqrt{1 - 3 \cdot \left(v \cdot v\right)} \cdot \sqrt{1 - 3 \cdot \left(v \cdot v\right)}\right) \cdot \left(\frac{\sqrt{2}}{4} \cdot \frac{\sqrt{2}}{4}\right)}}\right) \cdot \left(1 - v \cdot v\right)
\] |
Simplified100.0%
[Start]100.0 | \[ \left(0 + \sqrt{\mathsf{fma}\left(v \cdot v, -3, 1\right) \cdot 0.125}\right) \cdot \left(1 - v \cdot v\right)
\] |
|---|---|
+-lft-identity [=>]100.0 | \[ \color{blue}{\sqrt{\mathsf{fma}\left(v \cdot v, -3, 1\right) \cdot 0.125}} \cdot \left(1 - v \cdot v\right)
\] |
fma-udef [=>]100.0 | \[ \sqrt{\color{blue}{\left(\left(v \cdot v\right) \cdot -3 + 1\right)} \cdot 0.125} \cdot \left(1 - v \cdot v\right)
\] |
distribute-lft1-in [<=]100.0 | \[ \sqrt{\color{blue}{\left(\left(v \cdot v\right) \cdot -3\right) \cdot 0.125 + 0.125}} \cdot \left(1 - v \cdot v\right)
\] |
+-commutative [=>]100.0 | \[ \sqrt{\color{blue}{0.125 + \left(\left(v \cdot v\right) \cdot -3\right) \cdot 0.125}} \cdot \left(1 - v \cdot v\right)
\] |
associate-*l* [=>]100.0 | \[ \sqrt{0.125 + \color{blue}{\left(v \cdot v\right) \cdot \left(-3 \cdot 0.125\right)}} \cdot \left(1 - v \cdot v\right)
\] |
metadata-eval [=>]100.0 | \[ \sqrt{0.125 + \left(v \cdot v\right) \cdot \color{blue}{-0.375}} \cdot \left(1 - v \cdot v\right)
\] |
associate-*l* [=>]100.0 | \[ \sqrt{0.125 + \color{blue}{v \cdot \left(v \cdot -0.375\right)}} \cdot \left(1 - v \cdot v\right)
\] |
Final simplification100.0%
| Alternative 1 | |
|---|---|
| Accuracy | 99.1% |
| Cost | 6976 |
| Alternative 2 | |
|---|---|
| Accuracy | 99.1% |
| Cost | 6592 |
herbie shell --seed 2023157
(FPCore (v)
:name "Falkner and Boettcher, Appendix B, 2"
:precision binary64
(* (* (/ (sqrt 2.0) 4.0) (sqrt (- 1.0 (* 3.0 (* v v))))) (- 1.0 (* v v))))