| Alternative 1 | |
|---|---|
| Error | 0.75% |
| Cost | 580 |
\[\begin{array}{l}
\mathbf{if}\;i \leq 0.5:\\
\;\;\;\;i \cdot \left(i \cdot -0.25\right)\\
\mathbf{else}:\\
\;\;\;\;0.0625 + \frac{\frac{0.015625}{i}}{i}\\
\end{array}
\]
(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 (/ (- i) (+ (/ 4.0 i) (* i -16.0))))
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 -i / ((4.0 / i) + (i * -16.0));
}
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 = -i / ((4.0d0 / i) + (i * (-16.0d0)))
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 -i / ((4.0 / i) + (i * -16.0));
}
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 -i / ((4.0 / i) + (i * -16.0))
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(Float64(-i) / Float64(Float64(4.0 / i) + Float64(i * -16.0))) 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 = -i / ((4.0 / i) + (i * -16.0)); 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[((-i) / N[(N[(4.0 / i), $MachinePrecision] + N[(i * -16.0), $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{-i}{\frac{4}{i} + i \cdot -16}
Results
Initial program 72.76
Simplified49.32
[Start]72.76 | \[ \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}
\] |
|---|---|
associate-/l* [=>]49.27 | \[ \frac{\color{blue}{\frac{i \cdot i}{\frac{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)}{i \cdot i}}}}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1}
\] |
swap-sqr [=>]49.32 | \[ \frac{\frac{i \cdot i}{\frac{\color{blue}{\left(2 \cdot 2\right) \cdot \left(i \cdot i\right)}}{i \cdot i}}}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1}
\] |
metadata-eval [=>]49.32 | \[ \frac{\frac{i \cdot i}{\frac{\color{blue}{4} \cdot \left(i \cdot i\right)}{i \cdot i}}}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1}
\] |
sub-neg [=>]49.32 | \[ \frac{\frac{i \cdot i}{\frac{4 \cdot \left(i \cdot i\right)}{i \cdot i}}}{\color{blue}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) + \left(-1\right)}}
\] |
swap-sqr [=>]49.32 | \[ \frac{\frac{i \cdot i}{\frac{4 \cdot \left(i \cdot i\right)}{i \cdot i}}}{\color{blue}{\left(2 \cdot 2\right) \cdot \left(i \cdot i\right)} + \left(-1\right)}
\] |
metadata-eval [=>]49.32 | \[ \frac{\frac{i \cdot i}{\frac{4 \cdot \left(i \cdot i\right)}{i \cdot i}}}{\color{blue}{4} \cdot \left(i \cdot i\right) + \left(-1\right)}
\] |
metadata-eval [=>]49.32 | \[ \frac{\frac{i \cdot i}{\frac{4 \cdot \left(i \cdot i\right)}{i \cdot i}}}{4 \cdot \left(i \cdot i\right) + \color{blue}{-1}}
\] |
Applied egg-rr24.66
Simplified24.66
[Start]24.66 | \[ -\frac{i}{\left(1 + \left(i \cdot i\right) \cdot -4\right) \cdot \frac{4}{i}}
\] |
|---|---|
distribute-neg-frac [=>]24.66 | \[ \color{blue}{\frac{-i}{\left(1 + \left(i \cdot i\right) \cdot -4\right) \cdot \frac{4}{i}}}
\] |
*-commutative [=>]24.66 | \[ \frac{-i}{\color{blue}{\frac{4}{i} \cdot \left(1 + \left(i \cdot i\right) \cdot -4\right)}}
\] |
associate-*l* [=>]24.66 | \[ \frac{-i}{\frac{4}{i} \cdot \left(1 + \color{blue}{i \cdot \left(i \cdot -4\right)}\right)}
\] |
Taylor expanded in i around 0 0.33
Simplified0.33
[Start]0.33 | \[ \frac{-i}{4 \cdot \frac{1}{i} + -16 \cdot i}
\] |
|---|---|
associate-*r/ [=>]0.33 | \[ \frac{-i}{\color{blue}{\frac{4 \cdot 1}{i}} + -16 \cdot i}
\] |
metadata-eval [=>]0.33 | \[ \frac{-i}{\frac{\color{blue}{4}}{i} + -16 \cdot i}
\] |
*-commutative [=>]0.33 | \[ \frac{-i}{\frac{4}{i} + \color{blue}{i \cdot -16}}
\] |
Final simplification0.33
| Alternative 1 | |
|---|---|
| Error | 0.75% |
| Cost | 580 |
| Alternative 2 | |
|---|---|
| Error | 0.5% |
| Cost | 576 |
| Alternative 3 | |
|---|---|
| Error | 0.97% |
| Cost | 452 |
| Alternative 4 | |
|---|---|
| Error | 48.61% |
| Cost | 64 |
herbie shell --seed 2023102
(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)))