| Alternative 1 | |
|---|---|
| Error | 23.2 |
| Cost | 3012 |
(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 (if (<= i 0.5) (* (pow i 2.0) -0.25) 0.0625))
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) {
double tmp;
if (i <= 0.5) {
tmp = pow(i, 2.0) * -0.25;
} else {
tmp = 0.0625;
}
return tmp;
}
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
real(8) :: tmp
if (i <= 0.5d0) then
tmp = (i ** 2.0d0) * (-0.25d0)
else
tmp = 0.0625d0
end if
code = tmp
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) {
double tmp;
if (i <= 0.5) {
tmp = Math.pow(i, 2.0) * -0.25;
} else {
tmp = 0.0625;
}
return tmp;
}
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): tmp = 0 if i <= 0.5: tmp = math.pow(i, 2.0) * -0.25 else: tmp = 0.0625 return tmp
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) tmp = 0.0 if (i <= 0.5) tmp = Float64((i ^ 2.0) * -0.25); else tmp = 0.0625; end return tmp 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_2 = code(i) tmp = 0.0; if (i <= 0.5) tmp = (i ^ 2.0) * -0.25; else tmp = 0.0625; end tmp_2 = tmp; 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_] := If[LessEqual[i, 0.5], N[(N[Power[i, 2.0], $MachinePrecision] * -0.25), $MachinePrecision], 0.0625]
\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}
\begin{array}{l}
\mathbf{if}\;i \leq 0.5:\\
\;\;\;\;{i}^{2} \cdot -0.25\\
\mathbf{else}:\\
\;\;\;\;0.0625\\
\end{array}
Results
if i < 0.5Initial program 46.2
Simplified46.3
[Start]46.2 | \[ \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}
\] |
|---|---|
rational_best-simplify-44 [=>]46.3 | \[ \frac{\frac{\left(i \cdot i\right) \cdot \left(i \cdot i\right)}{\color{blue}{2 \cdot \left(\left(2 \cdot i\right) \cdot i\right)}}}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1}
\] |
rational_best-simplify-2 [=>]46.3 | \[ \frac{\frac{\left(i \cdot i\right) \cdot \left(i \cdot i\right)}{2 \cdot \color{blue}{\left(i \cdot \left(2 \cdot i\right)\right)}}}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1}
\] |
rational_best-simplify-44 [=>]46.3 | \[ \frac{\frac{\left(i \cdot i\right) \cdot \left(i \cdot i\right)}{2 \cdot \color{blue}{\left(2 \cdot \left(i \cdot i\right)\right)}}}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1}
\] |
rational_best-simplify-2 [=>]46.3 | \[ \frac{\frac{\left(i \cdot i\right) \cdot \left(i \cdot i\right)}{2 \cdot \color{blue}{\left(\left(i \cdot i\right) \cdot 2\right)}}}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1}
\] |
rational_best-simplify-44 [=>]46.3 | \[ \frac{\frac{\left(i \cdot i\right) \cdot \left(i \cdot i\right)}{\color{blue}{\left(i \cdot i\right) \cdot \left(2 \cdot 2\right)}}}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1}
\] |
metadata-eval [=>]46.3 | \[ \frac{\frac{\left(i \cdot i\right) \cdot \left(i \cdot i\right)}{\left(i \cdot i\right) \cdot \color{blue}{4}}}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1}
\] |
rational_best-simplify-19 [=>]46.3 | \[ \frac{\frac{\left(i \cdot i\right) \cdot \left(i \cdot i\right)}{\left(i \cdot i\right) \cdot 4}}{\color{blue}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) + -1}}
\] |
rational_best-simplify-44 [=>]46.3 | \[ \frac{\frac{\left(i \cdot i\right) \cdot \left(i \cdot i\right)}{\left(i \cdot i\right) \cdot 4}}{\color{blue}{2 \cdot \left(\left(2 \cdot i\right) \cdot i\right)} + -1}
\] |
rational_best-simplify-2 [=>]46.3 | \[ \frac{\frac{\left(i \cdot i\right) \cdot \left(i \cdot i\right)}{\left(i \cdot i\right) \cdot 4}}{2 \cdot \color{blue}{\left(i \cdot \left(2 \cdot i\right)\right)} + -1}
\] |
rational_best-simplify-44 [=>]46.3 | \[ \frac{\frac{\left(i \cdot i\right) \cdot \left(i \cdot i\right)}{\left(i \cdot i\right) \cdot 4}}{2 \cdot \color{blue}{\left(2 \cdot \left(i \cdot i\right)\right)} + -1}
\] |
rational_best-simplify-2 [=>]46.3 | \[ \frac{\frac{\left(i \cdot i\right) \cdot \left(i \cdot i\right)}{\left(i \cdot i\right) \cdot 4}}{2 \cdot \color{blue}{\left(\left(i \cdot i\right) \cdot 2\right)} + -1}
\] |
rational_best-simplify-44 [=>]46.3 | \[ \frac{\frac{\left(i \cdot i\right) \cdot \left(i \cdot i\right)}{\left(i \cdot i\right) \cdot 4}}{\color{blue}{\left(i \cdot i\right) \cdot \left(2 \cdot 2\right)} + -1}
\] |
metadata-eval [=>]46.3 | \[ \frac{\frac{\left(i \cdot i\right) \cdot \left(i \cdot i\right)}{\left(i \cdot i\right) \cdot 4}}{\left(i \cdot i\right) \cdot \color{blue}{4} + -1}
\] |
Taylor expanded in i around 0 0.7
Simplified0.7
[Start]0.7 | \[ -0.25 \cdot {i}^{2}
\] |
|---|---|
rational_best-simplify-2 [=>]0.7 | \[ \color{blue}{{i}^{2} \cdot -0.25}
\] |
if 0.5 < i Initial program 48.0
Simplified48.0
[Start]48.0 | \[ \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}
\] |
|---|---|
rational_best-simplify-44 [=>]48.0 | \[ \frac{\frac{\left(i \cdot i\right) \cdot \left(i \cdot i\right)}{\color{blue}{2 \cdot \left(\left(2 \cdot i\right) \cdot i\right)}}}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1}
\] |
rational_best-simplify-2 [=>]48.0 | \[ \frac{\frac{\left(i \cdot i\right) \cdot \left(i \cdot i\right)}{2 \cdot \color{blue}{\left(i \cdot \left(2 \cdot i\right)\right)}}}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1}
\] |
rational_best-simplify-44 [=>]48.0 | \[ \frac{\frac{\left(i \cdot i\right) \cdot \left(i \cdot i\right)}{2 \cdot \color{blue}{\left(2 \cdot \left(i \cdot i\right)\right)}}}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1}
\] |
rational_best-simplify-2 [=>]48.0 | \[ \frac{\frac{\left(i \cdot i\right) \cdot \left(i \cdot i\right)}{2 \cdot \color{blue}{\left(\left(i \cdot i\right) \cdot 2\right)}}}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1}
\] |
rational_best-simplify-44 [=>]48.0 | \[ \frac{\frac{\left(i \cdot i\right) \cdot \left(i \cdot i\right)}{\color{blue}{\left(i \cdot i\right) \cdot \left(2 \cdot 2\right)}}}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1}
\] |
metadata-eval [=>]48.0 | \[ \frac{\frac{\left(i \cdot i\right) \cdot \left(i \cdot i\right)}{\left(i \cdot i\right) \cdot \color{blue}{4}}}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1}
\] |
rational_best-simplify-19 [=>]48.0 | \[ \frac{\frac{\left(i \cdot i\right) \cdot \left(i \cdot i\right)}{\left(i \cdot i\right) \cdot 4}}{\color{blue}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) + -1}}
\] |
rational_best-simplify-44 [=>]48.0 | \[ \frac{\frac{\left(i \cdot i\right) \cdot \left(i \cdot i\right)}{\left(i \cdot i\right) \cdot 4}}{\color{blue}{2 \cdot \left(\left(2 \cdot i\right) \cdot i\right)} + -1}
\] |
rational_best-simplify-2 [=>]48.0 | \[ \frac{\frac{\left(i \cdot i\right) \cdot \left(i \cdot i\right)}{\left(i \cdot i\right) \cdot 4}}{2 \cdot \color{blue}{\left(i \cdot \left(2 \cdot i\right)\right)} + -1}
\] |
rational_best-simplify-44 [=>]48.0 | \[ \frac{\frac{\left(i \cdot i\right) \cdot \left(i \cdot i\right)}{\left(i \cdot i\right) \cdot 4}}{2 \cdot \color{blue}{\left(2 \cdot \left(i \cdot i\right)\right)} + -1}
\] |
rational_best-simplify-2 [=>]48.0 | \[ \frac{\frac{\left(i \cdot i\right) \cdot \left(i \cdot i\right)}{\left(i \cdot i\right) \cdot 4}}{2 \cdot \color{blue}{\left(\left(i \cdot i\right) \cdot 2\right)} + -1}
\] |
rational_best-simplify-44 [=>]48.0 | \[ \frac{\frac{\left(i \cdot i\right) \cdot \left(i \cdot i\right)}{\left(i \cdot i\right) \cdot 4}}{\color{blue}{\left(i \cdot i\right) \cdot \left(2 \cdot 2\right)} + -1}
\] |
metadata-eval [=>]48.0 | \[ \frac{\frac{\left(i \cdot i\right) \cdot \left(i \cdot i\right)}{\left(i \cdot i\right) \cdot 4}}{\left(i \cdot i\right) \cdot \color{blue}{4} + -1}
\] |
Taylor expanded in i around inf 0.6
Final simplification0.6
| Alternative 1 | |
|---|---|
| Error | 23.2 |
| Cost | 3012 |
| Alternative 2 | |
|---|---|
| Error | 31.8 |
| Cost | 64 |
herbie shell --seed 2023092
(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)))