| Alternative 1 | |
|---|---|
| Error | 0.01% |
| Cost | 7360 |
\[\left(1 - v \cdot v\right) \cdot \left(\sqrt{2 + \left(v \cdot v\right) \cdot -6} \cdot 0.25\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 (/ (- 1.0 (* v v)) (/ 4.0 (sqrt (+ 2.0 (* (* v v) -6.0))))))
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 (1.0 - (v * v)) / (4.0 / sqrt((2.0 + ((v * v) * -6.0))));
}
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 = (1.0d0 - (v * v)) / (4.0d0 / sqrt((2.0d0 + ((v * v) * (-6.0d0)))))
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 (1.0 - (v * v)) / (4.0 / Math.sqrt((2.0 + ((v * v) * -6.0))));
}
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 (1.0 - (v * v)) / (4.0 / math.sqrt((2.0 + ((v * v) * -6.0))))
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(Float64(1.0 - Float64(v * v)) / Float64(4.0 / sqrt(Float64(2.0 + Float64(Float64(v * v) * -6.0))))) 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 = (1.0 - (v * v)) / (4.0 / sqrt((2.0 + ((v * v) * -6.0)))); 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[(1.0 - N[(v * v), $MachinePrecision]), $MachinePrecision] / N[(4.0 / N[Sqrt[N[(2.0 + N[(N[(v * v), $MachinePrecision] * -6.0), $MachinePrecision]), $MachinePrecision]], $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)
\frac{1 - v \cdot v}{\frac{4}{\sqrt{2 + \left(v \cdot v\right) \cdot -6}}}
Results
Initial program 0.02
Applied egg-rr0.02
Applied egg-rr0.03
Simplified0.02
[Start]0.03 | \[ \frac{1 - v \cdot v}{e^{\mathsf{log1p}\left(\frac{4}{\sqrt{2 + -6 \cdot \left(v \cdot v\right)}}\right)} - 1}
\] |
|---|---|
expm1-def [=>]0.03 | \[ \frac{1 - v \cdot v}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{4}{\sqrt{2 + -6 \cdot \left(v \cdot v\right)}}\right)\right)}}
\] |
expm1-log1p [=>]0.02 | \[ \frac{1 - v \cdot v}{\color{blue}{\frac{4}{\sqrt{2 + -6 \cdot \left(v \cdot v\right)}}}}
\] |
Final simplification0.02
| Alternative 1 | |
|---|---|
| Error | 0.01% |
| Cost | 7360 |
| Alternative 2 | |
|---|---|
| Error | 0.43% |
| Cost | 7232 |
| Alternative 3 | |
|---|---|
| Error | 0.42% |
| Cost | 7104 |
| Alternative 4 | |
|---|---|
| Error | 0.42% |
| Cost | 6976 |
| Alternative 5 | |
|---|---|
| Error | 0.99% |
| Cost | 6848 |
| Alternative 6 | |
|---|---|
| Error | 1.02% |
| Cost | 6464 |
herbie shell --seed 2023090
(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))))