
(FPCore (i) :precision binary32 (let* ((t_0 (* (* 2.0 i) (* 2.0 i)))) (/ (/ (* (* i i) (* i i)) t_0) (- t_0 1.0))))
float code(float i) {
float t_0 = (2.0f * i) * (2.0f * i);
return (((i * i) * (i * i)) / t_0) / (t_0 - 1.0f);
}
real(4) function code(i)
real(4), intent (in) :: i
real(4) :: t_0
t_0 = (2.0e0 * i) * (2.0e0 * i)
code = (((i * i) * (i * i)) / t_0) / (t_0 - 1.0e0)
end function
function code(i) t_0 = Float32(Float32(Float32(2.0) * i) * Float32(Float32(2.0) * i)) return Float32(Float32(Float32(Float32(i * i) * Float32(i * i)) / t_0) / Float32(t_0 - Float32(1.0))) end
function tmp = code(i) t_0 = (single(2.0) * i) * (single(2.0) * i); tmp = (((i * i) * (i * i)) / t_0) / (t_0 - single(1.0)); end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(2 \cdot i\right) \cdot \left(2 \cdot i\right)\\
\frac{\frac{\left(i \cdot i\right) \cdot \left(i \cdot i\right)}{t\_0}}{t\_0 - 1}
\end{array}
\end{array}
Sampling outcomes in binary32 precision:
Herbie found 6 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (i) :precision binary32 (let* ((t_0 (* (* 2.0 i) (* 2.0 i)))) (/ (/ (* (* i i) (* i i)) t_0) (- t_0 1.0))))
float code(float i) {
float t_0 = (2.0f * i) * (2.0f * i);
return (((i * i) * (i * i)) / t_0) / (t_0 - 1.0f);
}
real(4) function code(i)
real(4), intent (in) :: i
real(4) :: t_0
t_0 = (2.0e0 * i) * (2.0e0 * i)
code = (((i * i) * (i * i)) / t_0) / (t_0 - 1.0e0)
end function
function code(i) t_0 = Float32(Float32(Float32(2.0) * i) * Float32(Float32(2.0) * i)) return Float32(Float32(Float32(Float32(i * i) * Float32(i * i)) / t_0) / Float32(t_0 - Float32(1.0))) end
function tmp = code(i) t_0 = (single(2.0) * i) * (single(2.0) * i); tmp = (((i * i) * (i * i)) / t_0) / (t_0 - single(1.0)); end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(2 \cdot i\right) \cdot \left(2 \cdot i\right)\\
\frac{\frac{\left(i \cdot i\right) \cdot \left(i \cdot i\right)}{t\_0}}{t\_0 - 1}
\end{array}
\end{array}
(FPCore (i) :precision binary32 (if (<= i 2000.0) (* (* i i) (/ 0.25 (- (* 4.0 (* i i)) 1.0))) 0.0625))
float code(float i) {
float tmp;
if (i <= 2000.0f) {
tmp = (i * i) * (0.25f / ((4.0f * (i * i)) - 1.0f));
} else {
tmp = 0.0625f;
}
return tmp;
}
real(4) function code(i)
real(4), intent (in) :: i
real(4) :: tmp
if (i <= 2000.0e0) then
tmp = (i * i) * (0.25e0 / ((4.0e0 * (i * i)) - 1.0e0))
else
tmp = 0.0625e0
end if
code = tmp
end function
function code(i) tmp = Float32(0.0) if (i <= Float32(2000.0)) tmp = Float32(Float32(i * i) * Float32(Float32(0.25) / Float32(Float32(Float32(4.0) * Float32(i * i)) - Float32(1.0)))); else tmp = Float32(0.0625); end return tmp end
function tmp_2 = code(i) tmp = single(0.0); if (i <= single(2000.0)) tmp = (i * i) * (single(0.25) / ((single(4.0) * (i * i)) - single(1.0))); else tmp = single(0.0625); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq 2000:\\
\;\;\;\;\left(i \cdot i\right) \cdot \frac{0.25}{4 \cdot \left(i \cdot i\right) - 1}\\
\mathbf{else}:\\
\;\;\;\;0.0625\\
\end{array}
\end{array}
if i < 2e3Initial program 46.2%
lift-/.f32N/A
lift-/.f32N/A
associate-/l/N/A
lift-*.f32N/A
associate-/l*N/A
lower-*.f32N/A
lower-/.f32N/A
lift-*.f32N/A
lift-*.f32N/A
associate-*r*N/A
associate-*l*N/A
lower-*.f32N/A
Applied rewrites60.9%
Applied rewrites99.4%
lift-*.f32N/A
lift-/.f32N/A
lift-/.f32N/A
frac-timesN/A
associate-/l*N/A
lift--.f32N/A
flip3--N/A
associate-*r/N/A
lift--.f32N/A
lift-*.f32N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
Applied rewrites99.8%
if 2e3 < i Initial program 15.2%
Taylor expanded in i around inf
Applied rewrites100.0%
(FPCore (i) :precision binary32 (if (<= i 0.5) (* (- (* i -0.25) (* i (* i i))) i) (+ (/ 0.015625 (* i i)) 0.0625)))
float code(float i) {
float tmp;
if (i <= 0.5f) {
tmp = ((i * -0.25f) - (i * (i * i))) * i;
} else {
tmp = (0.015625f / (i * i)) + 0.0625f;
}
return tmp;
}
real(4) function code(i)
real(4), intent (in) :: i
real(4) :: tmp
if (i <= 0.5e0) then
tmp = ((i * (-0.25e0)) - (i * (i * i))) * i
else
tmp = (0.015625e0 / (i * i)) + 0.0625e0
end if
code = tmp
end function
function code(i) tmp = Float32(0.0) if (i <= Float32(0.5)) tmp = Float32(Float32(Float32(i * Float32(-0.25)) - Float32(i * Float32(i * i))) * i); else tmp = Float32(Float32(Float32(0.015625) / Float32(i * i)) + Float32(0.0625)); end return tmp end
function tmp_2 = code(i) tmp = single(0.0); if (i <= single(0.5)) tmp = ((i * single(-0.25)) - (i * (i * i))) * i; else tmp = (single(0.015625) / (i * i)) + single(0.0625); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq 0.5:\\
\;\;\;\;\left(i \cdot -0.25 - i \cdot \left(i \cdot i\right)\right) \cdot i\\
\mathbf{else}:\\
\;\;\;\;\frac{0.015625}{i \cdot i} + 0.0625\\
\end{array}
\end{array}
if i < 0.5Initial program 38.7%
Taylor expanded in i around 0
*-commutativeN/A
lower-*.f32N/A
Applied rewrites98.1%
Applied rewrites98.1%
Taylor expanded in i around 0
Applied rewrites97.6%
Applied rewrites97.6%
if 0.5 < i Initial program 24.6%
Taylor expanded in i around inf
+-commutativeN/A
lower-+.f32N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f32N/A
unpow2N/A
lower-*.f3297.3
Applied rewrites97.3%
Final simplification97.4%
(FPCore (i) :precision binary32 (if (<= i 0.5) (* (* (- -0.25 (* i i)) i) i) (+ (/ 0.015625 (* i i)) 0.0625)))
float code(float i) {
float tmp;
if (i <= 0.5f) {
tmp = ((-0.25f - (i * i)) * i) * i;
} else {
tmp = (0.015625f / (i * i)) + 0.0625f;
}
return tmp;
}
real(4) function code(i)
real(4), intent (in) :: i
real(4) :: tmp
if (i <= 0.5e0) then
tmp = (((-0.25e0) - (i * i)) * i) * i
else
tmp = (0.015625e0 / (i * i)) + 0.0625e0
end if
code = tmp
end function
function code(i) tmp = Float32(0.0) if (i <= Float32(0.5)) tmp = Float32(Float32(Float32(Float32(-0.25) - Float32(i * i)) * i) * i); else tmp = Float32(Float32(Float32(0.015625) / Float32(i * i)) + Float32(0.0625)); end return tmp end
function tmp_2 = code(i) tmp = single(0.0); if (i <= single(0.5)) tmp = ((single(-0.25) - (i * i)) * i) * i; else tmp = (single(0.015625) / (i * i)) + single(0.0625); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq 0.5:\\
\;\;\;\;\left(\left(-0.25 - i \cdot i\right) \cdot i\right) \cdot i\\
\mathbf{else}:\\
\;\;\;\;\frac{0.015625}{i \cdot i} + 0.0625\\
\end{array}
\end{array}
if i < 0.5Initial program 38.7%
Taylor expanded in i around 0
*-commutativeN/A
lower-*.f32N/A
Applied rewrites98.1%
Applied rewrites98.1%
Taylor expanded in i around 0
Applied rewrites97.6%
if 0.5 < i Initial program 24.6%
Taylor expanded in i around inf
+-commutativeN/A
lower-+.f32N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f32N/A
unpow2N/A
lower-*.f3297.3
Applied rewrites97.3%
(FPCore (i) :precision binary32 (if (<= i 0.5) (* (* (- -0.25 (* i i)) i) i) 0.0625))
float code(float i) {
float tmp;
if (i <= 0.5f) {
tmp = ((-0.25f - (i * i)) * i) * i;
} else {
tmp = 0.0625f;
}
return tmp;
}
real(4) function code(i)
real(4), intent (in) :: i
real(4) :: tmp
if (i <= 0.5e0) then
tmp = (((-0.25e0) - (i * i)) * i) * i
else
tmp = 0.0625e0
end if
code = tmp
end function
function code(i) tmp = Float32(0.0) if (i <= Float32(0.5)) tmp = Float32(Float32(Float32(Float32(-0.25) - Float32(i * i)) * i) * i); else tmp = Float32(0.0625); end return tmp end
function tmp_2 = code(i) tmp = single(0.0); if (i <= single(0.5)) tmp = ((single(-0.25) - (i * i)) * i) * i; else tmp = single(0.0625); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq 0.5:\\
\;\;\;\;\left(\left(-0.25 - i \cdot i\right) \cdot i\right) \cdot i\\
\mathbf{else}:\\
\;\;\;\;0.0625\\
\end{array}
\end{array}
if i < 0.5Initial program 38.7%
Taylor expanded in i around 0
*-commutativeN/A
lower-*.f32N/A
Applied rewrites98.1%
Applied rewrites98.1%
Taylor expanded in i around 0
Applied rewrites97.6%
if 0.5 < i Initial program 24.6%
Taylor expanded in i around inf
Applied rewrites95.1%
(FPCore (i) :precision binary32 (if (<= i 0.5) (* (* -0.25 i) i) 0.0625))
float code(float i) {
float tmp;
if (i <= 0.5f) {
tmp = (-0.25f * i) * i;
} else {
tmp = 0.0625f;
}
return tmp;
}
real(4) function code(i)
real(4), intent (in) :: i
real(4) :: tmp
if (i <= 0.5e0) then
tmp = ((-0.25e0) * i) * i
else
tmp = 0.0625e0
end if
code = tmp
end function
function code(i) tmp = Float32(0.0) if (i <= Float32(0.5)) tmp = Float32(Float32(Float32(-0.25) * i) * i); else tmp = Float32(0.0625); end return tmp end
function tmp_2 = code(i) tmp = single(0.0); if (i <= single(0.5)) tmp = (single(-0.25) * i) * i; else tmp = single(0.0625); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq 0.5:\\
\;\;\;\;\left(-0.25 \cdot i\right) \cdot i\\
\mathbf{else}:\\
\;\;\;\;0.0625\\
\end{array}
\end{array}
if i < 0.5Initial program 38.7%
Taylor expanded in i around 0
metadata-evalN/A
associate-*r*N/A
mul-1-negN/A
unpow2N/A
distribute-lft-neg-inN/A
associate-*r*N/A
lower-*.f32N/A
mul-1-negN/A
associate-*r*N/A
metadata-evalN/A
lower-*.f3296.2
Applied rewrites96.2%
if 0.5 < i Initial program 24.6%
Taylor expanded in i around inf
Applied rewrites95.1%
(FPCore (i) :precision binary32 0.0625)
float code(float i) {
return 0.0625f;
}
real(4) function code(i)
real(4), intent (in) :: i
code = 0.0625e0
end function
function code(i) return Float32(0.0625) end
function tmp = code(i) tmp = single(0.0625); end
\begin{array}{l}
\\
0.0625
\end{array}
Initial program 30.8%
Taylor expanded in i around inf
Applied rewrites55.5%
herbie shell --seed 2024341
(FPCore (i)
:name "Octave 3.8, jcobi/4, as called"
:precision binary32
:pre (> i 0.0)
(/ (/ (* (* i i) (* i i)) (* (* 2.0 i) (* 2.0 i))) (- (* (* 2.0 i) (* 2.0 i)) 1.0)))