| Alternative 1 | |
|---|---|
| Accuracy | 99.4% |
| Cost | 576 |
\[\frac{0.25}{4 - \frac{1}{i \cdot i}}
\]

(FPCore (i) :precision binary64 (/ (/ (* (* i i) (* i i)) (* (* 2.0 i) (* 2.0 i))) (- (* (* 2.0 i) (* 2.0 i)) 1.0)))
(FPCore (i) :precision binary64 (/ 0.25 (- 4.0 (/ 1.0 (* i i)))))
double code(double i) {
return (((i * i) * (i * i)) / ((2.0 * i) * (2.0 * i))) / (((2.0 * i) * (2.0 * i)) - 1.0);
}
double code(double i) {
return 0.25 / (4.0 - (1.0 / (i * i)));
}
real(8) function code(i)
real(8), intent (in) :: i
code = (((i * i) * (i * i)) / ((2.0d0 * i) * (2.0d0 * i))) / (((2.0d0 * i) * (2.0d0 * i)) - 1.0d0)
end function
real(8) function code(i)
real(8), intent (in) :: i
code = 0.25d0 / (4.0d0 - (1.0d0 / (i * i)))
end function
public static double code(double i) {
return (((i * i) * (i * i)) / ((2.0 * i) * (2.0 * i))) / (((2.0 * i) * (2.0 * i)) - 1.0);
}
public static double code(double i) {
return 0.25 / (4.0 - (1.0 / (i * i)));
}
def code(i): return (((i * i) * (i * i)) / ((2.0 * i) * (2.0 * i))) / (((2.0 * i) * (2.0 * i)) - 1.0)
def code(i): return 0.25 / (4.0 - (1.0 / (i * i)))
function code(i) return Float64(Float64(Float64(Float64(i * i) * Float64(i * i)) / Float64(Float64(2.0 * i) * Float64(2.0 * i))) / Float64(Float64(Float64(2.0 * i) * Float64(2.0 * i)) - 1.0)) end
function code(i) return Float64(0.25 / Float64(4.0 - Float64(1.0 / Float64(i * i)))) end
function tmp = code(i) tmp = (((i * i) * (i * i)) / ((2.0 * i) * (2.0 * i))) / (((2.0 * i) * (2.0 * i)) - 1.0); end
function tmp = code(i) tmp = 0.25 / (4.0 - (1.0 / (i * i))); end
code[i_] := N[(N[(N[(N[(i * i), $MachinePrecision] * N[(i * i), $MachinePrecision]), $MachinePrecision] / N[(N[(2.0 * i), $MachinePrecision] * N[(2.0 * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(N[(2.0 * i), $MachinePrecision] * N[(2.0 * i), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]
code[i_] := N[(0.25 / N[(4.0 - N[(1.0 / N[(i * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{\frac{\left(i \cdot i\right) \cdot \left(i \cdot i\right)}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)}}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1}
\frac{0.25}{4 - \frac{1}{i \cdot i}}
Herbie found 4 alternatives:
| Alternative | Accuracy | Speedup |
|---|
Results
Initial program 27.6%
Simplified90.2%
[Start]27.6% | \[ \frac{\frac{\left(i \cdot i\right) \cdot \left(i \cdot i\right)}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)}}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1}
\] |
|---|---|
times-frac [=>]73.8% | \[ \frac{\color{blue}{\frac{i \cdot i}{2 \cdot i} \cdot \frac{i \cdot i}{2 \cdot i}}}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1}
\] |
associate-/l* [=>]73.7% | \[ \color{blue}{\frac{\frac{i \cdot i}{2 \cdot i}}{\frac{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1}{\frac{i \cdot i}{2 \cdot i}}}}
\] |
associate-/l* [=>]73.7% | \[ \frac{\color{blue}{\frac{i}{\frac{2 \cdot i}{i}}}}{\frac{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1}{\frac{i \cdot i}{2 \cdot i}}}
\] |
associate-/l/ [=>]73.7% | \[ \color{blue}{\frac{i}{\frac{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1}{\frac{i \cdot i}{2 \cdot i}} \cdot \frac{2 \cdot i}{i}}}
\] |
associate-/r/ [=>]73.0% | \[ \frac{i}{\color{blue}{\left(\frac{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1}{i \cdot i} \cdot \left(2 \cdot i\right)\right)} \cdot \frac{2 \cdot i}{i}}
\] |
associate-/l* [=>]73.0% | \[ \frac{i}{\left(\frac{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1}{i \cdot i} \cdot \left(2 \cdot i\right)\right) \cdot \color{blue}{\frac{2}{\frac{i}{i}}}}
\] |
*-inverses [=>]73.0% | \[ \frac{i}{\left(\frac{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1}{i \cdot i} \cdot \left(2 \cdot i\right)\right) \cdot \frac{2}{\color{blue}{1}}}
\] |
metadata-eval [=>]73.0% | \[ \frac{i}{\left(\frac{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1}{i \cdot i} \cdot \left(2 \cdot i\right)\right) \cdot \color{blue}{2}}
\] |
associate-*l* [=>]73.0% | \[ \frac{i}{\color{blue}{\frac{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1}{i \cdot i} \cdot \left(\left(2 \cdot i\right) \cdot 2\right)}}
\] |
*-commutative [<=]73.0% | \[ \frac{i}{\color{blue}{\left(\left(2 \cdot i\right) \cdot 2\right) \cdot \frac{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1}{i \cdot i}}}
\] |
associate-/r* [=>]73.1% | \[ \color{blue}{\frac{\frac{i}{\left(2 \cdot i\right) \cdot 2}}{\frac{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1}{i \cdot i}}}
\] |
Taylor expanded in i around 0 99.3%
Simplified99.3%
[Start]99.3% | \[ \frac{0.25}{4 - \frac{1}{{i}^{2}}}
\] |
|---|---|
unpow2 [=>]99.3% | \[ \frac{0.25}{4 - \frac{1}{\color{blue}{i \cdot i}}}
\] |
Final simplification99.3%
| Alternative 1 | |
|---|---|
| Accuracy | 99.4% |
| Cost | 576 |
| Alternative 2 | |
|---|---|
| Accuracy | 99.2% |
| Cost | 580 |
| Alternative 3 | |
|---|---|
| Accuracy | 98.9% |
| Cost | 452 |
| Alternative 4 | |
|---|---|
| Accuracy | 50.2% |
| Cost | 64 |
herbie shell --seed 2023178
(FPCore (i)
:name "Octave 3.8, jcobi/4, as called"
:precision binary64
:pre (> i 0.0)
(/ (/ (* (* i i) (* i i)) (* (* 2.0 i) (* 2.0 i))) (- (* (* 2.0 i) (* 2.0 i)) 1.0)))