
(FPCore (t) :precision binary32 (let* ((t_1 (- 2.0 (/ (/ 2.0 t) (+ 1.0 (/ 1.0 t)))))) (- 1.0 (/ 1.0 (+ 2.0 (* t_1 t_1))))))
float code(float t) {
float t_1 = 2.0f - ((2.0f / t) / (1.0f + (1.0f / t)));
return 1.0f - (1.0f / (2.0f + (t_1 * t_1)));
}
real(4) function code(t)
real(4), intent (in) :: t
real(4) :: t_1
t_1 = 2.0e0 - ((2.0e0 / t) / (1.0e0 + (1.0e0 / t)))
code = 1.0e0 - (1.0e0 / (2.0e0 + (t_1 * t_1)))
end function
function code(t) t_1 = Float32(Float32(2.0) - Float32(Float32(Float32(2.0) / t) / Float32(Float32(1.0) + Float32(Float32(1.0) / t)))) return Float32(Float32(1.0) - Float32(Float32(1.0) / Float32(Float32(2.0) + Float32(t_1 * t_1)))) end
function tmp = code(t) t_1 = single(2.0) - ((single(2.0) / t) / (single(1.0) + (single(1.0) / t))); tmp = single(1.0) - (single(1.0) / (single(2.0) + (t_1 * t_1))); end
\begin{array}{l}
\\
\begin{array}{l}
t_1 := 2 - \frac{\frac{2}{t}}{1 + \frac{1}{t}}\\
1 - \frac{1}{2 + t\_1 \cdot t\_1}
\end{array}
\end{array}
Sampling outcomes in binary32 precision:
Herbie found 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (t) :precision binary32 (let* ((t_1 (- 2.0 (/ (/ 2.0 t) (+ 1.0 (/ 1.0 t)))))) (- 1.0 (/ 1.0 (+ 2.0 (* t_1 t_1))))))
float code(float t) {
float t_1 = 2.0f - ((2.0f / t) / (1.0f + (1.0f / t)));
return 1.0f - (1.0f / (2.0f + (t_1 * t_1)));
}
real(4) function code(t)
real(4), intent (in) :: t
real(4) :: t_1
t_1 = 2.0e0 - ((2.0e0 / t) / (1.0e0 + (1.0e0 / t)))
code = 1.0e0 - (1.0e0 / (2.0e0 + (t_1 * t_1)))
end function
function code(t) t_1 = Float32(Float32(2.0) - Float32(Float32(Float32(2.0) / t) / Float32(Float32(1.0) + Float32(Float32(1.0) / t)))) return Float32(Float32(1.0) - Float32(Float32(1.0) / Float32(Float32(2.0) + Float32(t_1 * t_1)))) end
function tmp = code(t) t_1 = single(2.0) - ((single(2.0) / t) / (single(1.0) + (single(1.0) / t))); tmp = single(1.0) - (single(1.0) / (single(2.0) + (t_1 * t_1))); end
\begin{array}{l}
\\
\begin{array}{l}
t_1 := 2 - \frac{\frac{2}{t}}{1 + \frac{1}{t}}\\
1 - \frac{1}{2 + t\_1 \cdot t\_1}
\end{array}
\end{array}
(FPCore (t) :precision binary32 (let* ((t_1 (+ 2.0 (/ -2.0 (+ 1.0 t))))) (- 1.0 (/ 1.0 (+ (* t_1 t_1) 2.0)))))
float code(float t) {
float t_1 = 2.0f + (-2.0f / (1.0f + t));
return 1.0f - (1.0f / ((t_1 * t_1) + 2.0f));
}
real(4) function code(t)
real(4), intent (in) :: t
real(4) :: t_1
t_1 = 2.0e0 + ((-2.0e0) / (1.0e0 + t))
code = 1.0e0 - (1.0e0 / ((t_1 * t_1) + 2.0e0))
end function
function code(t) t_1 = Float32(Float32(2.0) + Float32(Float32(-2.0) / Float32(Float32(1.0) + t))) return Float32(Float32(1.0) - Float32(Float32(1.0) / Float32(Float32(t_1 * t_1) + Float32(2.0)))) end
function tmp = code(t) t_1 = single(2.0) + (single(-2.0) / (single(1.0) + t)); tmp = single(1.0) - (single(1.0) / ((t_1 * t_1) + single(2.0))); end
\begin{array}{l}
\\
\begin{array}{l}
t_1 := 2 + \frac{-2}{1 + t}\\
1 - \frac{1}{t\_1 \cdot t\_1 + 2}
\end{array}
\end{array}
Initial program 99.2%
lift-+.f32N/A
+-commutativeN/A
lower-+.f3299.2
Applied rewrites99.9%
(FPCore (t)
:precision binary32
(if (<= (/ (/ 2.0 t) (+ 1.0 (/ 1.0 t))) 0.5)
(-
1.0
(+
(/
(-
0.2222222222222222
(/ (+ (/ 0.04938271604938271 t) 0.037037037037037035) t))
t)
0.16666666666666666))
(-
1.0
(/
1.0
(+ 2.0 (* (* (+ (* (- (* (+ (* -16.0 t) 12.0) t) 8.0) t) 4.0) t) t))))))
float code(float t) {
float tmp;
if (((2.0f / t) / (1.0f + (1.0f / t))) <= 0.5f) {
tmp = 1.0f - (((0.2222222222222222f - (((0.04938271604938271f / t) + 0.037037037037037035f) / t)) / t) + 0.16666666666666666f);
} else {
tmp = 1.0f - (1.0f / (2.0f + ((((((((-16.0f * t) + 12.0f) * t) - 8.0f) * t) + 4.0f) * t) * t)));
}
return tmp;
}
real(4) function code(t)
real(4), intent (in) :: t
real(4) :: tmp
if (((2.0e0 / t) / (1.0e0 + (1.0e0 / t))) <= 0.5e0) then
tmp = 1.0e0 - (((0.2222222222222222e0 - (((0.04938271604938271e0 / t) + 0.037037037037037035e0) / t)) / t) + 0.16666666666666666e0)
else
tmp = 1.0e0 - (1.0e0 / (2.0e0 + (((((((((-16.0e0) * t) + 12.0e0) * t) - 8.0e0) * t) + 4.0e0) * t) * t)))
end if
code = tmp
end function
function code(t) tmp = Float32(0.0) if (Float32(Float32(Float32(2.0) / t) / Float32(Float32(1.0) + Float32(Float32(1.0) / t))) <= Float32(0.5)) tmp = Float32(Float32(1.0) - Float32(Float32(Float32(Float32(0.2222222222222222) - Float32(Float32(Float32(Float32(0.04938271604938271) / t) + Float32(0.037037037037037035)) / t)) / t) + Float32(0.16666666666666666))); else tmp = Float32(Float32(1.0) - Float32(Float32(1.0) / Float32(Float32(2.0) + Float32(Float32(Float32(Float32(Float32(Float32(Float32(Float32(Float32(-16.0) * t) + Float32(12.0)) * t) - Float32(8.0)) * t) + Float32(4.0)) * t) * t)))); end return tmp end
function tmp_2 = code(t) tmp = single(0.0); if (((single(2.0) / t) / (single(1.0) + (single(1.0) / t))) <= single(0.5)) tmp = single(1.0) - (((single(0.2222222222222222) - (((single(0.04938271604938271) / t) + single(0.037037037037037035)) / t)) / t) + single(0.16666666666666666)); else tmp = single(1.0) - (single(1.0) / (single(2.0) + ((((((((single(-16.0) * t) + single(12.0)) * t) - single(8.0)) * t) + single(4.0)) * t) * t))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\frac{2}{t}}{1 + \frac{1}{t}} \leq 0.5:\\
\;\;\;\;1 - \left(\frac{0.2222222222222222 - \frac{\frac{0.04938271604938271}{t} + 0.037037037037037035}{t}}{t} + 0.16666666666666666\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{1}{2 + \left(\left(\left(\left(-16 \cdot t + 12\right) \cdot t - 8\right) \cdot t + 4\right) \cdot t\right) \cdot t}\\
\end{array}
\end{array}
if (/.f32 (/.f32 #s(literal 2 binary32) t) (+.f32 #s(literal 1 binary32) (/.f32 #s(literal 1 binary32) t))) < 0.5Initial program 99.8%
Taylor expanded in t around inf
+-commutativeN/A
unpow2N/A
associate-/r*N/A
associate-/l*N/A
associate-*r/N/A
metadata-evalN/A
div-addN/A
*-rgt-identityN/A
metadata-evalN/A
associate-*l*N/A
*-commutativeN/A
mul-1-negN/A
Applied rewrites98.9%
if 0.5 < (/.f32 (/.f32 #s(literal 2 binary32) t) (+.f32 #s(literal 1 binary32) (/.f32 #s(literal 1 binary32) t))) Initial program 98.5%
Taylor expanded in t around 0
unpow2N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f32N/A
Applied rewrites97.6%
(FPCore (t)
:precision binary32
(if (<= (/ (/ 2.0 t) (+ 1.0 (/ 1.0 t))) 0.5)
(-
1.0
(+
(/
(-
0.2222222222222222
(/ (+ (/ 0.04938271604938271 t) 0.037037037037037035) t))
t)
0.16666666666666666))
(- 1.0 (/ 1.0 (+ 2.0 (* (* (+ (* (- (* 12.0 t) 8.0) t) 4.0) t) t))))))
float code(float t) {
float tmp;
if (((2.0f / t) / (1.0f + (1.0f / t))) <= 0.5f) {
tmp = 1.0f - (((0.2222222222222222f - (((0.04938271604938271f / t) + 0.037037037037037035f) / t)) / t) + 0.16666666666666666f);
} else {
tmp = 1.0f - (1.0f / (2.0f + ((((((12.0f * t) - 8.0f) * t) + 4.0f) * t) * t)));
}
return tmp;
}
real(4) function code(t)
real(4), intent (in) :: t
real(4) :: tmp
if (((2.0e0 / t) / (1.0e0 + (1.0e0 / t))) <= 0.5e0) then
tmp = 1.0e0 - (((0.2222222222222222e0 - (((0.04938271604938271e0 / t) + 0.037037037037037035e0) / t)) / t) + 0.16666666666666666e0)
else
tmp = 1.0e0 - (1.0e0 / (2.0e0 + ((((((12.0e0 * t) - 8.0e0) * t) + 4.0e0) * t) * t)))
end if
code = tmp
end function
function code(t) tmp = Float32(0.0) if (Float32(Float32(Float32(2.0) / t) / Float32(Float32(1.0) + Float32(Float32(1.0) / t))) <= Float32(0.5)) tmp = Float32(Float32(1.0) - Float32(Float32(Float32(Float32(0.2222222222222222) - Float32(Float32(Float32(Float32(0.04938271604938271) / t) + Float32(0.037037037037037035)) / t)) / t) + Float32(0.16666666666666666))); else tmp = Float32(Float32(1.0) - Float32(Float32(1.0) / Float32(Float32(2.0) + Float32(Float32(Float32(Float32(Float32(Float32(Float32(12.0) * t) - Float32(8.0)) * t) + Float32(4.0)) * t) * t)))); end return tmp end
function tmp_2 = code(t) tmp = single(0.0); if (((single(2.0) / t) / (single(1.0) + (single(1.0) / t))) <= single(0.5)) tmp = single(1.0) - (((single(0.2222222222222222) - (((single(0.04938271604938271) / t) + single(0.037037037037037035)) / t)) / t) + single(0.16666666666666666)); else tmp = single(1.0) - (single(1.0) / (single(2.0) + ((((((single(12.0) * t) - single(8.0)) * t) + single(4.0)) * t) * t))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\frac{2}{t}}{1 + \frac{1}{t}} \leq 0.5:\\
\;\;\;\;1 - \left(\frac{0.2222222222222222 - \frac{\frac{0.04938271604938271}{t} + 0.037037037037037035}{t}}{t} + 0.16666666666666666\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{1}{2 + \left(\left(\left(12 \cdot t - 8\right) \cdot t + 4\right) \cdot t\right) \cdot t}\\
\end{array}
\end{array}
if (/.f32 (/.f32 #s(literal 2 binary32) t) (+.f32 #s(literal 1 binary32) (/.f32 #s(literal 1 binary32) t))) < 0.5Initial program 99.8%
Taylor expanded in t around inf
+-commutativeN/A
unpow2N/A
associate-/r*N/A
associate-/l*N/A
associate-*r/N/A
metadata-evalN/A
div-addN/A
*-rgt-identityN/A
metadata-evalN/A
associate-*l*N/A
*-commutativeN/A
mul-1-negN/A
Applied rewrites98.9%
if 0.5 < (/.f32 (/.f32 #s(literal 2 binary32) t) (+.f32 #s(literal 1 binary32) (/.f32 #s(literal 1 binary32) t))) Initial program 98.5%
Taylor expanded in t around 0
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f32N/A
lower-*.f32N/A
+-commutativeN/A
lower-+.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
lower-*.f3297.2
Applied rewrites97.2%
(FPCore (t)
:precision binary32
(if (<= (/ (/ 2.0 t) (+ 1.0 (/ 1.0 t))) 0.5)
(-
0.8333333333333334
(/
(-
0.2222222222222222
(/ (+ (/ 0.04938271604938271 t) 0.037037037037037035) t))
t))
(- 1.0 (/ 1.0 (+ 2.0 (* (* (+ (* (- (* 12.0 t) 8.0) t) 4.0) t) t))))))
float code(float t) {
float tmp;
if (((2.0f / t) / (1.0f + (1.0f / t))) <= 0.5f) {
tmp = 0.8333333333333334f - ((0.2222222222222222f - (((0.04938271604938271f / t) + 0.037037037037037035f) / t)) / t);
} else {
tmp = 1.0f - (1.0f / (2.0f + ((((((12.0f * t) - 8.0f) * t) + 4.0f) * t) * t)));
}
return tmp;
}
real(4) function code(t)
real(4), intent (in) :: t
real(4) :: tmp
if (((2.0e0 / t) / (1.0e0 + (1.0e0 / t))) <= 0.5e0) then
tmp = 0.8333333333333334e0 - ((0.2222222222222222e0 - (((0.04938271604938271e0 / t) + 0.037037037037037035e0) / t)) / t)
else
tmp = 1.0e0 - (1.0e0 / (2.0e0 + ((((((12.0e0 * t) - 8.0e0) * t) + 4.0e0) * t) * t)))
end if
code = tmp
end function
function code(t) tmp = Float32(0.0) if (Float32(Float32(Float32(2.0) / t) / Float32(Float32(1.0) + Float32(Float32(1.0) / t))) <= Float32(0.5)) tmp = Float32(Float32(0.8333333333333334) - Float32(Float32(Float32(0.2222222222222222) - Float32(Float32(Float32(Float32(0.04938271604938271) / t) + Float32(0.037037037037037035)) / t)) / t)); else tmp = Float32(Float32(1.0) - Float32(Float32(1.0) / Float32(Float32(2.0) + Float32(Float32(Float32(Float32(Float32(Float32(Float32(12.0) * t) - Float32(8.0)) * t) + Float32(4.0)) * t) * t)))); end return tmp end
function tmp_2 = code(t) tmp = single(0.0); if (((single(2.0) / t) / (single(1.0) + (single(1.0) / t))) <= single(0.5)) tmp = single(0.8333333333333334) - ((single(0.2222222222222222) - (((single(0.04938271604938271) / t) + single(0.037037037037037035)) / t)) / t); else tmp = single(1.0) - (single(1.0) / (single(2.0) + ((((((single(12.0) * t) - single(8.0)) * t) + single(4.0)) * t) * t))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\frac{2}{t}}{1 + \frac{1}{t}} \leq 0.5:\\
\;\;\;\;0.8333333333333334 - \frac{0.2222222222222222 - \frac{\frac{0.04938271604938271}{t} + 0.037037037037037035}{t}}{t}\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{1}{2 + \left(\left(\left(12 \cdot t - 8\right) \cdot t + 4\right) \cdot t\right) \cdot t}\\
\end{array}
\end{array}
if (/.f32 (/.f32 #s(literal 2 binary32) t) (+.f32 #s(literal 1 binary32) (/.f32 #s(literal 1 binary32) t))) < 0.5Initial program 99.8%
Taylor expanded in t around inf
Applied rewrites98.9%
if 0.5 < (/.f32 (/.f32 #s(literal 2 binary32) t) (+.f32 #s(literal 1 binary32) (/.f32 #s(literal 1 binary32) t))) Initial program 98.5%
Taylor expanded in t around 0
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f32N/A
lower-*.f32N/A
+-commutativeN/A
lower-+.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
lower-*.f3297.2
Applied rewrites97.2%
(FPCore (t)
:precision binary32
(if (<= (/ (/ 2.0 t) (+ 1.0 (/ 1.0 t))) 0.5)
(-
0.8333333333333334
(/
(-
0.2222222222222222
(/ (+ (/ 0.04938271604938271 t) 0.037037037037037035) t))
t))
(- 0.5 (* (* (- -1.0 (* (- t 2.0) t)) t) t))))
float code(float t) {
float tmp;
if (((2.0f / t) / (1.0f + (1.0f / t))) <= 0.5f) {
tmp = 0.8333333333333334f - ((0.2222222222222222f - (((0.04938271604938271f / t) + 0.037037037037037035f) / t)) / t);
} else {
tmp = 0.5f - (((-1.0f - ((t - 2.0f) * t)) * t) * t);
}
return tmp;
}
real(4) function code(t)
real(4), intent (in) :: t
real(4) :: tmp
if (((2.0e0 / t) / (1.0e0 + (1.0e0 / t))) <= 0.5e0) then
tmp = 0.8333333333333334e0 - ((0.2222222222222222e0 - (((0.04938271604938271e0 / t) + 0.037037037037037035e0) / t)) / t)
else
tmp = 0.5e0 - ((((-1.0e0) - ((t - 2.0e0) * t)) * t) * t)
end if
code = tmp
end function
function code(t) tmp = Float32(0.0) if (Float32(Float32(Float32(2.0) / t) / Float32(Float32(1.0) + Float32(Float32(1.0) / t))) <= Float32(0.5)) tmp = Float32(Float32(0.8333333333333334) - Float32(Float32(Float32(0.2222222222222222) - Float32(Float32(Float32(Float32(0.04938271604938271) / t) + Float32(0.037037037037037035)) / t)) / t)); else tmp = Float32(Float32(0.5) - Float32(Float32(Float32(Float32(-1.0) - Float32(Float32(t - Float32(2.0)) * t)) * t) * t)); end return tmp end
function tmp_2 = code(t) tmp = single(0.0); if (((single(2.0) / t) / (single(1.0) + (single(1.0) / t))) <= single(0.5)) tmp = single(0.8333333333333334) - ((single(0.2222222222222222) - (((single(0.04938271604938271) / t) + single(0.037037037037037035)) / t)) / t); else tmp = single(0.5) - (((single(-1.0) - ((t - single(2.0)) * t)) * t) * t); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\frac{2}{t}}{1 + \frac{1}{t}} \leq 0.5:\\
\;\;\;\;0.8333333333333334 - \frac{0.2222222222222222 - \frac{\frac{0.04938271604938271}{t} + 0.037037037037037035}{t}}{t}\\
\mathbf{else}:\\
\;\;\;\;0.5 - \left(\left(-1 - \left(t - 2\right) \cdot t\right) \cdot t\right) \cdot t\\
\end{array}
\end{array}
if (/.f32 (/.f32 #s(literal 2 binary32) t) (+.f32 #s(literal 1 binary32) (/.f32 #s(literal 1 binary32) t))) < 0.5Initial program 99.8%
Taylor expanded in t around inf
Applied rewrites98.9%
if 0.5 < (/.f32 (/.f32 #s(literal 2 binary32) t) (+.f32 #s(literal 1 binary32) (/.f32 #s(literal 1 binary32) t))) Initial program 98.5%
Taylor expanded in t around 0
fp-cancel-sign-sub-invN/A
lower--.f32N/A
distribute-lft-neg-outN/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
distribute-lft-neg-inN/A
lower-*.f32N/A
Applied rewrites97.1%
(FPCore (t)
:precision binary32
(if (<= (/ (/ 2.0 t) (+ 1.0 (/ 1.0 t))) 0.5)
(-
1.0
(-
0.16666666666666666
(/ (- (/ 0.037037037037037035 t) 0.2222222222222222) t)))
(- 0.5 (* (* (- -1.0 (* (- t 2.0) t)) t) t))))
float code(float t) {
float tmp;
if (((2.0f / t) / (1.0f + (1.0f / t))) <= 0.5f) {
tmp = 1.0f - (0.16666666666666666f - (((0.037037037037037035f / t) - 0.2222222222222222f) / t));
} else {
tmp = 0.5f - (((-1.0f - ((t - 2.0f) * t)) * t) * t);
}
return tmp;
}
real(4) function code(t)
real(4), intent (in) :: t
real(4) :: tmp
if (((2.0e0 / t) / (1.0e0 + (1.0e0 / t))) <= 0.5e0) then
tmp = 1.0e0 - (0.16666666666666666e0 - (((0.037037037037037035e0 / t) - 0.2222222222222222e0) / t))
else
tmp = 0.5e0 - ((((-1.0e0) - ((t - 2.0e0) * t)) * t) * t)
end if
code = tmp
end function
function code(t) tmp = Float32(0.0) if (Float32(Float32(Float32(2.0) / t) / Float32(Float32(1.0) + Float32(Float32(1.0) / t))) <= Float32(0.5)) tmp = Float32(Float32(1.0) - Float32(Float32(0.16666666666666666) - Float32(Float32(Float32(Float32(0.037037037037037035) / t) - Float32(0.2222222222222222)) / t))); else tmp = Float32(Float32(0.5) - Float32(Float32(Float32(Float32(-1.0) - Float32(Float32(t - Float32(2.0)) * t)) * t) * t)); end return tmp end
function tmp_2 = code(t) tmp = single(0.0); if (((single(2.0) / t) / (single(1.0) + (single(1.0) / t))) <= single(0.5)) tmp = single(1.0) - (single(0.16666666666666666) - (((single(0.037037037037037035) / t) - single(0.2222222222222222)) / t)); else tmp = single(0.5) - (((single(-1.0) - ((t - single(2.0)) * t)) * t) * t); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\frac{2}{t}}{1 + \frac{1}{t}} \leq 0.5:\\
\;\;\;\;1 - \left(0.16666666666666666 - \frac{\frac{0.037037037037037035}{t} - 0.2222222222222222}{t}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 - \left(\left(-1 - \left(t - 2\right) \cdot t\right) \cdot t\right) \cdot t\\
\end{array}
\end{array}
if (/.f32 (/.f32 #s(literal 2 binary32) t) (+.f32 #s(literal 1 binary32) (/.f32 #s(literal 1 binary32) t))) < 0.5Initial program 99.8%
Taylor expanded in t around inf
fp-cancel-sign-sub-invN/A
associate--l-N/A
+-commutativeN/A
unpow2N/A
associate-/r*N/A
metadata-evalN/A
associate-*r/N/A
fp-cancel-sub-sign-invN/A
associate-*r/N/A
metadata-evalN/A
div-subN/A
lower--.f32N/A
lower-/.f32N/A
lower--.f32N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f3298.3
Applied rewrites98.3%
if 0.5 < (/.f32 (/.f32 #s(literal 2 binary32) t) (+.f32 #s(literal 1 binary32) (/.f32 #s(literal 1 binary32) t))) Initial program 98.5%
Taylor expanded in t around 0
fp-cancel-sign-sub-invN/A
lower--.f32N/A
distribute-lft-neg-outN/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
distribute-lft-neg-inN/A
lower-*.f32N/A
Applied rewrites97.1%
(FPCore (t)
:precision binary32
(if (<= (/ (/ 2.0 t) (+ 1.0 (/ 1.0 t))) 0.5)
(-
0.8333333333333334
(/ (- 0.2222222222222222 (/ 0.037037037037037035 t)) t))
(- 0.5 (* (* (- -1.0 (* (- t 2.0) t)) t) t))))
float code(float t) {
float tmp;
if (((2.0f / t) / (1.0f + (1.0f / t))) <= 0.5f) {
tmp = 0.8333333333333334f - ((0.2222222222222222f - (0.037037037037037035f / t)) / t);
} else {
tmp = 0.5f - (((-1.0f - ((t - 2.0f) * t)) * t) * t);
}
return tmp;
}
real(4) function code(t)
real(4), intent (in) :: t
real(4) :: tmp
if (((2.0e0 / t) / (1.0e0 + (1.0e0 / t))) <= 0.5e0) then
tmp = 0.8333333333333334e0 - ((0.2222222222222222e0 - (0.037037037037037035e0 / t)) / t)
else
tmp = 0.5e0 - ((((-1.0e0) - ((t - 2.0e0) * t)) * t) * t)
end if
code = tmp
end function
function code(t) tmp = Float32(0.0) if (Float32(Float32(Float32(2.0) / t) / Float32(Float32(1.0) + Float32(Float32(1.0) / t))) <= Float32(0.5)) tmp = Float32(Float32(0.8333333333333334) - Float32(Float32(Float32(0.2222222222222222) - Float32(Float32(0.037037037037037035) / t)) / t)); else tmp = Float32(Float32(0.5) - Float32(Float32(Float32(Float32(-1.0) - Float32(Float32(t - Float32(2.0)) * t)) * t) * t)); end return tmp end
function tmp_2 = code(t) tmp = single(0.0); if (((single(2.0) / t) / (single(1.0) + (single(1.0) / t))) <= single(0.5)) tmp = single(0.8333333333333334) - ((single(0.2222222222222222) - (single(0.037037037037037035) / t)) / t); else tmp = single(0.5) - (((single(-1.0) - ((t - single(2.0)) * t)) * t) * t); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\frac{2}{t}}{1 + \frac{1}{t}} \leq 0.5:\\
\;\;\;\;0.8333333333333334 - \frac{0.2222222222222222 - \frac{0.037037037037037035}{t}}{t}\\
\mathbf{else}:\\
\;\;\;\;0.5 - \left(\left(-1 - \left(t - 2\right) \cdot t\right) \cdot t\right) \cdot t\\
\end{array}
\end{array}
if (/.f32 (/.f32 #s(literal 2 binary32) t) (+.f32 #s(literal 1 binary32) (/.f32 #s(literal 1 binary32) t))) < 0.5Initial program 99.8%
Taylor expanded in t around inf
Applied rewrites98.3%
if 0.5 < (/.f32 (/.f32 #s(literal 2 binary32) t) (+.f32 #s(literal 1 binary32) (/.f32 #s(literal 1 binary32) t))) Initial program 98.5%
Taylor expanded in t around 0
fp-cancel-sign-sub-invN/A
lower--.f32N/A
distribute-lft-neg-outN/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
distribute-lft-neg-inN/A
lower-*.f32N/A
Applied rewrites97.1%
(FPCore (t) :precision binary32 (if (<= (/ (/ 2.0 t) (+ 1.0 (/ 1.0 t))) 0.5) (- 1.0 (+ 0.16666666666666666 (/ 0.2222222222222222 t))) (- 0.5 (* (* (- -1.0 (* (- t 2.0) t)) t) t))))
float code(float t) {
float tmp;
if (((2.0f / t) / (1.0f + (1.0f / t))) <= 0.5f) {
tmp = 1.0f - (0.16666666666666666f + (0.2222222222222222f / t));
} else {
tmp = 0.5f - (((-1.0f - ((t - 2.0f) * t)) * t) * t);
}
return tmp;
}
real(4) function code(t)
real(4), intent (in) :: t
real(4) :: tmp
if (((2.0e0 / t) / (1.0e0 + (1.0e0 / t))) <= 0.5e0) then
tmp = 1.0e0 - (0.16666666666666666e0 + (0.2222222222222222e0 / t))
else
tmp = 0.5e0 - ((((-1.0e0) - ((t - 2.0e0) * t)) * t) * t)
end if
code = tmp
end function
function code(t) tmp = Float32(0.0) if (Float32(Float32(Float32(2.0) / t) / Float32(Float32(1.0) + Float32(Float32(1.0) / t))) <= Float32(0.5)) tmp = Float32(Float32(1.0) - Float32(Float32(0.16666666666666666) + Float32(Float32(0.2222222222222222) / t))); else tmp = Float32(Float32(0.5) - Float32(Float32(Float32(Float32(-1.0) - Float32(Float32(t - Float32(2.0)) * t)) * t) * t)); end return tmp end
function tmp_2 = code(t) tmp = single(0.0); if (((single(2.0) / t) / (single(1.0) + (single(1.0) / t))) <= single(0.5)) tmp = single(1.0) - (single(0.16666666666666666) + (single(0.2222222222222222) / t)); else tmp = single(0.5) - (((single(-1.0) - ((t - single(2.0)) * t)) * t) * t); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\frac{2}{t}}{1 + \frac{1}{t}} \leq 0.5:\\
\;\;\;\;1 - \left(0.16666666666666666 + \frac{0.2222222222222222}{t}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 - \left(\left(-1 - \left(t - 2\right) \cdot t\right) \cdot t\right) \cdot t\\
\end{array}
\end{array}
if (/.f32 (/.f32 #s(literal 2 binary32) t) (+.f32 #s(literal 1 binary32) (/.f32 #s(literal 1 binary32) t))) < 0.5Initial program 99.8%
Taylor expanded in t around inf
lower-+.f32N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f3297.5
Applied rewrites97.5%
if 0.5 < (/.f32 (/.f32 #s(literal 2 binary32) t) (+.f32 #s(literal 1 binary32) (/.f32 #s(literal 1 binary32) t))) Initial program 98.5%
Taylor expanded in t around 0
fp-cancel-sign-sub-invN/A
lower--.f32N/A
distribute-lft-neg-outN/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
distribute-lft-neg-inN/A
lower-*.f32N/A
Applied rewrites97.1%
(FPCore (t) :precision binary32 (if (<= (/ (/ 2.0 t) (+ 1.0 (/ 1.0 t))) 0.5) (- 1.0 (+ 0.16666666666666666 (/ 0.2222222222222222 t))) (- 0.5 (* (+ (+ t t) -1.0) (* t t)))))
float code(float t) {
float tmp;
if (((2.0f / t) / (1.0f + (1.0f / t))) <= 0.5f) {
tmp = 1.0f - (0.16666666666666666f + (0.2222222222222222f / t));
} else {
tmp = 0.5f - (((t + t) + -1.0f) * (t * t));
}
return tmp;
}
real(4) function code(t)
real(4), intent (in) :: t
real(4) :: tmp
if (((2.0e0 / t) / (1.0e0 + (1.0e0 / t))) <= 0.5e0) then
tmp = 1.0e0 - (0.16666666666666666e0 + (0.2222222222222222e0 / t))
else
tmp = 0.5e0 - (((t + t) + (-1.0e0)) * (t * t))
end if
code = tmp
end function
function code(t) tmp = Float32(0.0) if (Float32(Float32(Float32(2.0) / t) / Float32(Float32(1.0) + Float32(Float32(1.0) / t))) <= Float32(0.5)) tmp = Float32(Float32(1.0) - Float32(Float32(0.16666666666666666) + Float32(Float32(0.2222222222222222) / t))); else tmp = Float32(Float32(0.5) - Float32(Float32(Float32(t + t) + Float32(-1.0)) * Float32(t * t))); end return tmp end
function tmp_2 = code(t) tmp = single(0.0); if (((single(2.0) / t) / (single(1.0) + (single(1.0) / t))) <= single(0.5)) tmp = single(1.0) - (single(0.16666666666666666) + (single(0.2222222222222222) / t)); else tmp = single(0.5) - (((t + t) + single(-1.0)) * (t * t)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\frac{2}{t}}{1 + \frac{1}{t}} \leq 0.5:\\
\;\;\;\;1 - \left(0.16666666666666666 + \frac{0.2222222222222222}{t}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 - \left(\left(t + t\right) + -1\right) \cdot \left(t \cdot t\right)\\
\end{array}
\end{array}
if (/.f32 (/.f32 #s(literal 2 binary32) t) (+.f32 #s(literal 1 binary32) (/.f32 #s(literal 1 binary32) t))) < 0.5Initial program 99.8%
Taylor expanded in t around inf
lower-+.f32N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f3297.5
Applied rewrites97.5%
if 0.5 < (/.f32 (/.f32 #s(literal 2 binary32) t) (+.f32 #s(literal 1 binary32) (/.f32 #s(literal 1 binary32) t))) Initial program 98.5%
lift-+.f32N/A
+-commutativeN/A
lower-+.f3298.5
Applied rewrites99.9%
Taylor expanded in t around inf
Applied rewrites30.0%
Taylor expanded in t around 0
fp-cancel-sign-sub-invN/A
lower--.f32N/A
distribute-lft-neg-outN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f32N/A
+-commutativeN/A
distribute-neg-inN/A
distribute-lft-neg-inN/A
metadata-evalN/A
metadata-evalN/A
lower-+.f32N/A
lower-*.f32N/A
unpow2N/A
lower-*.f3297.1
Applied rewrites97.1%
Applied rewrites97.1%
(FPCore (t) :precision binary32 (if (<= (/ (/ 2.0 t) (+ 1.0 (/ 1.0 t))) 0.5) (- 1.0 (+ 0.16666666666666666 (/ 0.2222222222222222 t))) (+ (* t t) 0.5)))
float code(float t) {
float tmp;
if (((2.0f / t) / (1.0f + (1.0f / t))) <= 0.5f) {
tmp = 1.0f - (0.16666666666666666f + (0.2222222222222222f / t));
} else {
tmp = (t * t) + 0.5f;
}
return tmp;
}
real(4) function code(t)
real(4), intent (in) :: t
real(4) :: tmp
if (((2.0e0 / t) / (1.0e0 + (1.0e0 / t))) <= 0.5e0) then
tmp = 1.0e0 - (0.16666666666666666e0 + (0.2222222222222222e0 / t))
else
tmp = (t * t) + 0.5e0
end if
code = tmp
end function
function code(t) tmp = Float32(0.0) if (Float32(Float32(Float32(2.0) / t) / Float32(Float32(1.0) + Float32(Float32(1.0) / t))) <= Float32(0.5)) tmp = Float32(Float32(1.0) - Float32(Float32(0.16666666666666666) + Float32(Float32(0.2222222222222222) / t))); else tmp = Float32(Float32(t * t) + Float32(0.5)); end return tmp end
function tmp_2 = code(t) tmp = single(0.0); if (((single(2.0) / t) / (single(1.0) + (single(1.0) / t))) <= single(0.5)) tmp = single(1.0) - (single(0.16666666666666666) + (single(0.2222222222222222) / t)); else tmp = (t * t) + single(0.5); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\frac{2}{t}}{1 + \frac{1}{t}} \leq 0.5:\\
\;\;\;\;1 - \left(0.16666666666666666 + \frac{0.2222222222222222}{t}\right)\\
\mathbf{else}:\\
\;\;\;\;t \cdot t + 0.5\\
\end{array}
\end{array}
if (/.f32 (/.f32 #s(literal 2 binary32) t) (+.f32 #s(literal 1 binary32) (/.f32 #s(literal 1 binary32) t))) < 0.5Initial program 99.8%
Taylor expanded in t around inf
lower-+.f32N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f3297.5
Applied rewrites97.5%
if 0.5 < (/.f32 (/.f32 #s(literal 2 binary32) t) (+.f32 #s(literal 1 binary32) (/.f32 #s(literal 1 binary32) t))) Initial program 98.5%
Taylor expanded in t around 0
+-commutativeN/A
lower-+.f32N/A
unpow2N/A
lower-*.f3295.7
Applied rewrites95.7%
(FPCore (t) :precision binary32 (if (<= (/ (/ 2.0 t) (+ 1.0 (/ 1.0 t))) 0.5) (- 0.8333333333333334 (/ 0.2222222222222222 t)) (+ (* t t) 0.5)))
float code(float t) {
float tmp;
if (((2.0f / t) / (1.0f + (1.0f / t))) <= 0.5f) {
tmp = 0.8333333333333334f - (0.2222222222222222f / t);
} else {
tmp = (t * t) + 0.5f;
}
return tmp;
}
real(4) function code(t)
real(4), intent (in) :: t
real(4) :: tmp
if (((2.0e0 / t) / (1.0e0 + (1.0e0 / t))) <= 0.5e0) then
tmp = 0.8333333333333334e0 - (0.2222222222222222e0 / t)
else
tmp = (t * t) + 0.5e0
end if
code = tmp
end function
function code(t) tmp = Float32(0.0) if (Float32(Float32(Float32(2.0) / t) / Float32(Float32(1.0) + Float32(Float32(1.0) / t))) <= Float32(0.5)) tmp = Float32(Float32(0.8333333333333334) - Float32(Float32(0.2222222222222222) / t)); else tmp = Float32(Float32(t * t) + Float32(0.5)); end return tmp end
function tmp_2 = code(t) tmp = single(0.0); if (((single(2.0) / t) / (single(1.0) + (single(1.0) / t))) <= single(0.5)) tmp = single(0.8333333333333334) - (single(0.2222222222222222) / t); else tmp = (t * t) + single(0.5); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\frac{2}{t}}{1 + \frac{1}{t}} \leq 0.5:\\
\;\;\;\;0.8333333333333334 - \frac{0.2222222222222222}{t}\\
\mathbf{else}:\\
\;\;\;\;t \cdot t + 0.5\\
\end{array}
\end{array}
if (/.f32 (/.f32 #s(literal 2 binary32) t) (+.f32 #s(literal 1 binary32) (/.f32 #s(literal 1 binary32) t))) < 0.5Initial program 99.8%
Taylor expanded in t around inf
lower--.f32N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f3297.4
Applied rewrites97.4%
if 0.5 < (/.f32 (/.f32 #s(literal 2 binary32) t) (+.f32 #s(literal 1 binary32) (/.f32 #s(literal 1 binary32) t))) Initial program 98.5%
Taylor expanded in t around 0
+-commutativeN/A
lower-+.f32N/A
unpow2N/A
lower-*.f3295.7
Applied rewrites95.7%
(FPCore (t) :precision binary32 (if (<= (/ (/ 2.0 t) (+ 1.0 (/ 1.0 t))) 0.5) 0.8333333333333334 (+ (* t t) 0.5)))
float code(float t) {
float tmp;
if (((2.0f / t) / (1.0f + (1.0f / t))) <= 0.5f) {
tmp = 0.8333333333333334f;
} else {
tmp = (t * t) + 0.5f;
}
return tmp;
}
real(4) function code(t)
real(4), intent (in) :: t
real(4) :: tmp
if (((2.0e0 / t) / (1.0e0 + (1.0e0 / t))) <= 0.5e0) then
tmp = 0.8333333333333334e0
else
tmp = (t * t) + 0.5e0
end if
code = tmp
end function
function code(t) tmp = Float32(0.0) if (Float32(Float32(Float32(2.0) / t) / Float32(Float32(1.0) + Float32(Float32(1.0) / t))) <= Float32(0.5)) tmp = Float32(0.8333333333333334); else tmp = Float32(Float32(t * t) + Float32(0.5)); end return tmp end
function tmp_2 = code(t) tmp = single(0.0); if (((single(2.0) / t) / (single(1.0) + (single(1.0) / t))) <= single(0.5)) tmp = single(0.8333333333333334); else tmp = (t * t) + single(0.5); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\frac{2}{t}}{1 + \frac{1}{t}} \leq 0.5:\\
\;\;\;\;0.8333333333333334\\
\mathbf{else}:\\
\;\;\;\;t \cdot t + 0.5\\
\end{array}
\end{array}
if (/.f32 (/.f32 #s(literal 2 binary32) t) (+.f32 #s(literal 1 binary32) (/.f32 #s(literal 1 binary32) t))) < 0.5Initial program 99.8%
Taylor expanded in t around inf
Applied rewrites94.1%
if 0.5 < (/.f32 (/.f32 #s(literal 2 binary32) t) (+.f32 #s(literal 1 binary32) (/.f32 #s(literal 1 binary32) t))) Initial program 98.5%
Taylor expanded in t around 0
+-commutativeN/A
lower-+.f32N/A
unpow2N/A
lower-*.f3295.7
Applied rewrites95.7%
(FPCore (t) :precision binary32 (if (<= (/ (/ 2.0 t) (+ 1.0 (/ 1.0 t))) 0.5) 0.8333333333333334 0.5))
float code(float t) {
float tmp;
if (((2.0f / t) / (1.0f + (1.0f / t))) <= 0.5f) {
tmp = 0.8333333333333334f;
} else {
tmp = 0.5f;
}
return tmp;
}
real(4) function code(t)
real(4), intent (in) :: t
real(4) :: tmp
if (((2.0e0 / t) / (1.0e0 + (1.0e0 / t))) <= 0.5e0) then
tmp = 0.8333333333333334e0
else
tmp = 0.5e0
end if
code = tmp
end function
function code(t) tmp = Float32(0.0) if (Float32(Float32(Float32(2.0) / t) / Float32(Float32(1.0) + Float32(Float32(1.0) / t))) <= Float32(0.5)) tmp = Float32(0.8333333333333334); else tmp = Float32(0.5); end return tmp end
function tmp_2 = code(t) tmp = single(0.0); if (((single(2.0) / t) / (single(1.0) + (single(1.0) / t))) <= single(0.5)) tmp = single(0.8333333333333334); else tmp = single(0.5); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\frac{2}{t}}{1 + \frac{1}{t}} \leq 0.5:\\
\;\;\;\;0.8333333333333334\\
\mathbf{else}:\\
\;\;\;\;0.5\\
\end{array}
\end{array}
if (/.f32 (/.f32 #s(literal 2 binary32) t) (+.f32 #s(literal 1 binary32) (/.f32 #s(literal 1 binary32) t))) < 0.5Initial program 99.8%
Taylor expanded in t around inf
Applied rewrites94.1%
if 0.5 < (/.f32 (/.f32 #s(literal 2 binary32) t) (+.f32 #s(literal 1 binary32) (/.f32 #s(literal 1 binary32) t))) Initial program 98.5%
Taylor expanded in t around 0
Applied rewrites94.3%
(FPCore (t) :precision binary32 0.5)
float code(float t) {
return 0.5f;
}
real(4) function code(t)
real(4), intent (in) :: t
code = 0.5e0
end function
function code(t) return Float32(0.5) end
function tmp = code(t) tmp = single(0.5); end
\begin{array}{l}
\\
0.5
\end{array}
Initial program 99.2%
Taylor expanded in t around 0
Applied rewrites59.4%
herbie shell --seed 2024341
(FPCore (t)
:name "Kahan p13 Example 3"
:precision binary32
(- 1.0 (/ 1.0 (+ 2.0 (* (- 2.0 (/ (/ 2.0 t) (+ 1.0 (/ 1.0 t)))) (- 2.0 (/ (/ 2.0 t) (+ 1.0 (/ 1.0 t)))))))))