| Alternative 1 | |
|---|---|
| Error | 0.4 |
| Cost | 708 |
(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 5000000.0) (* i (/ i (+ -4.0 (* (* i i) 16.0)))) 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 <= 5000000.0) {
tmp = i * (i / (-4.0 + ((i * i) * 16.0)));
} 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 <= 5000000.0d0) then
tmp = i * (i / ((-4.0d0) + ((i * i) * 16.0d0)))
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 <= 5000000.0) {
tmp = i * (i / (-4.0 + ((i * i) * 16.0)));
} 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 <= 5000000.0: tmp = i * (i / (-4.0 + ((i * i) * 16.0))) 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 <= 5000000.0) tmp = Float64(i * Float64(i / Float64(-4.0 + Float64(Float64(i * i) * 16.0)))); 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 <= 5000000.0) tmp = i * (i / (-4.0 + ((i * i) * 16.0))); 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, 5000000.0], N[(i * N[(i / N[(-4.0 + N[(N[(i * i), $MachinePrecision] * 16.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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 5000000:\\
\;\;\;\;i \cdot \frac{i}{-4 + \left(i \cdot i\right) \cdot 16}\\
\mathbf{else}:\\
\;\;\;\;0.0625\\
\end{array}
Results
if i < 5e6Initial program 44.4
Simplified0.1
[Start]44.4 | \[ \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.json-simplify-16 [=>]44.4 | \[ \color{blue}{\frac{\left(i \cdot i\right) \cdot \left(i \cdot i\right)}{\left(\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)\right) \cdot \left(\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1\right)}}
\] |
rational.json-simplify-3 [=>]44.4 | \[ \frac{\color{blue}{i \cdot \left(\left(i \cdot i\right) \cdot i\right)}}{\left(\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)\right) \cdot \left(\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1\right)}
\] |
rational.json-simplify-39 [=>]44.4 | \[ \frac{\color{blue}{\left(\left(i \cdot i\right) \cdot i\right) \cdot i}}{\left(\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)\right) \cdot \left(\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1\right)}
\] |
rational.json-simplify-19 [=>]39.0 | \[ \color{blue}{i \cdot \frac{\left(i \cdot i\right) \cdot i}{\left(\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)\right) \cdot \left(\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1\right)}}
\] |
rational.json-simplify-15 [=>]39.0 | \[ i \cdot \color{blue}{\frac{\frac{\left(i \cdot i\right) \cdot i}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)}}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1}}
\] |
Taylor expanded in i around 0 0.0
Applied egg-rr0.1
Applied egg-rr0.0
Simplified0.0
[Start]0.0 | \[ 0.25 \cdot \frac{i \cdot i}{4 \cdot \left(i \cdot i\right) + -1} + 0
\] |
|---|---|
rational.json-simplify-65 [=>]0.0 | \[ \color{blue}{0.25 \cdot \frac{i \cdot i}{4 \cdot \left(i \cdot i\right) + -1}}
\] |
rational.json-simplify-18 [=>]0.6 | \[ \color{blue}{\frac{0.25}{\frac{4 \cdot \left(i \cdot i\right) + -1}{i \cdot i}}}
\] |
rational.json-simplify-1 [=>]0.0 | \[ \color{blue}{\frac{i \cdot i}{\frac{4 \cdot \left(i \cdot i\right) + -1}{0.25}}}
\] |
rational.json-simplify-20 [<=]0.0 | \[ \color{blue}{i \cdot \frac{i}{\frac{4 \cdot \left(i \cdot i\right) + -1}{0.25}}}
\] |
rational.json-simplify-41 [=>]0.0 | \[ i \cdot \frac{i}{\frac{\color{blue}{-1 + 4 \cdot \left(i \cdot i\right)}}{0.25}}
\] |
rational.json-simplify-37 [=>]0.0 | \[ i \cdot \frac{i}{\color{blue}{\frac{-1}{0.25} + \frac{4 \cdot \left(i \cdot i\right)}{0.25}}}
\] |
metadata-eval [=>]0.0 | \[ i \cdot \frac{i}{\color{blue}{-4} + \frac{4 \cdot \left(i \cdot i\right)}{0.25}}
\] |
rational.json-simplify-19 [=>]0.0 | \[ i \cdot \frac{i}{-4 + \color{blue}{\left(i \cdot i\right) \cdot \frac{4}{0.25}}}
\] |
metadata-eval [=>]0.0 | \[ i \cdot \frac{i}{-4 + \left(i \cdot i\right) \cdot \color{blue}{16}}
\] |
if 5e6 < i Initial program 48.7
Simplified31.4
[Start]48.7 | \[ \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.json-simplify-16 [=>]48.8 | \[ \color{blue}{\frac{\left(i \cdot i\right) \cdot \left(i \cdot i\right)}{\left(\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)\right) \cdot \left(\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1\right)}}
\] |
rational.json-simplify-3 [=>]48.9 | \[ \frac{\color{blue}{i \cdot \left(\left(i \cdot i\right) \cdot i\right)}}{\left(\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)\right) \cdot \left(\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1\right)}
\] |
rational.json-simplify-39 [=>]48.9 | \[ \frac{\color{blue}{\left(\left(i \cdot i\right) \cdot i\right) \cdot i}}{\left(\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)\right) \cdot \left(\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1\right)}
\] |
rational.json-simplify-19 [=>]48.7 | \[ \color{blue}{i \cdot \frac{\left(i \cdot i\right) \cdot i}{\left(\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)\right) \cdot \left(\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1\right)}}
\] |
rational.json-simplify-15 [=>]43.5 | \[ i \cdot \color{blue}{\frac{\frac{\left(i \cdot i\right) \cdot i}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)}}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1}}
\] |
Taylor expanded in i around inf 0.0
Final simplification0.0
| Alternative 1 | |
|---|---|
| Error | 0.4 |
| Cost | 708 |
| Alternative 2 | |
|---|---|
| Error | 0.1 |
| Cost | 704 |
| Alternative 3 | |
|---|---|
| Error | 0.6 |
| Cost | 452 |
| Alternative 4 | |
|---|---|
| Error | 31.3 |
| Cost | 64 |
herbie shell --seed 2023066
(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)))