
(FPCore (x tau) :precision binary32 (let* ((t_1 (* (* x PI) tau))) (* (/ (sin t_1) t_1) (/ (sin (* x PI)) (* x PI)))))
float code(float x, float tau) {
float t_1 = (x * ((float) M_PI)) * tau;
return (sinf(t_1) / t_1) * (sinf((x * ((float) M_PI))) / (x * ((float) M_PI)));
}
function code(x, tau) t_1 = Float32(Float32(x * Float32(pi)) * tau) return Float32(Float32(sin(t_1) / t_1) * Float32(sin(Float32(x * Float32(pi))) / Float32(x * Float32(pi)))) end
function tmp = code(x, tau) t_1 = (x * single(pi)) * tau; tmp = (sin(t_1) / t_1) * (sin((x * single(pi))) / (x * single(pi))); end
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(x \cdot \pi\right) \cdot tau\\
\frac{\sin t\_1}{t\_1} \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi}
\end{array}
\end{array}
Sampling outcomes in binary32 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x tau) :precision binary32 (let* ((t_1 (* (* x PI) tau))) (* (/ (sin t_1) t_1) (/ (sin (* x PI)) (* x PI)))))
float code(float x, float tau) {
float t_1 = (x * ((float) M_PI)) * tau;
return (sinf(t_1) / t_1) * (sinf((x * ((float) M_PI))) / (x * ((float) M_PI)));
}
function code(x, tau) t_1 = Float32(Float32(x * Float32(pi)) * tau) return Float32(Float32(sin(t_1) / t_1) * Float32(sin(Float32(x * Float32(pi))) / Float32(x * Float32(pi)))) end
function tmp = code(x, tau) t_1 = (x * single(pi)) * tau; tmp = (sin(t_1) / t_1) * (sin((x * single(pi))) / (x * single(pi))); end
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(x \cdot \pi\right) \cdot tau\\
\frac{\sin t\_1}{t\_1} \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi}
\end{array}
\end{array}
(FPCore (x tau) :precision binary32 (let* ((t_1 (* (* x PI) tau))) (* (/ (sin t_1) t_1) (/ (sin (* x PI)) (* x PI)))))
float code(float x, float tau) {
float t_1 = (x * ((float) M_PI)) * tau;
return (sinf(t_1) / t_1) * (sinf((x * ((float) M_PI))) / (x * ((float) M_PI)));
}
function code(x, tau) t_1 = Float32(Float32(x * Float32(pi)) * tau) return Float32(Float32(sin(t_1) / t_1) * Float32(sin(Float32(x * Float32(pi))) / Float32(x * Float32(pi)))) end
function tmp = code(x, tau) t_1 = (x * single(pi)) * tau; tmp = (sin(t_1) / t_1) * (sin((x * single(pi))) / (x * single(pi))); end
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(x \cdot \pi\right) \cdot tau\\
\frac{\sin t\_1}{t\_1} \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi}
\end{array}
\end{array}
Initial program 97.9%
(FPCore (x tau) :precision binary32 (let* ((t_1 (* x (* PI tau)))) (* (sin t_1) (/ (sin (* x PI)) (* (* x PI) t_1)))))
float code(float x, float tau) {
float t_1 = x * (((float) M_PI) * tau);
return sinf(t_1) * (sinf((x * ((float) M_PI))) / ((x * ((float) M_PI)) * t_1));
}
function code(x, tau) t_1 = Float32(x * Float32(Float32(pi) * tau)) return Float32(sin(t_1) * Float32(sin(Float32(x * Float32(pi))) / Float32(Float32(x * Float32(pi)) * t_1))) end
function tmp = code(x, tau) t_1 = x * (single(pi) * tau); tmp = sin(t_1) * (sin((x * single(pi))) / ((x * single(pi)) * t_1)); end
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot \left(\pi \cdot tau\right)\\
\sin t\_1 \cdot \frac{\sin \left(x \cdot \pi\right)}{\left(x \cdot \pi\right) \cdot t\_1}
\end{array}
\end{array}
Initial program 97.9%
associate-*l/97.7%
associate-/l*97.8%
associate-*l*97.1%
associate-/l/97.0%
associate-*l*97.6%
Simplified97.6%
Final simplification97.6%
(FPCore (x tau) :precision binary32 (let* ((t_1 (* x (* PI tau)))) (* (sin t_1) (/ (sin (* x PI)) (* x (* PI t_1))))))
float code(float x, float tau) {
float t_1 = x * (((float) M_PI) * tau);
return sinf(t_1) * (sinf((x * ((float) M_PI))) / (x * (((float) M_PI) * t_1)));
}
function code(x, tau) t_1 = Float32(x * Float32(Float32(pi) * tau)) return Float32(sin(t_1) * Float32(sin(Float32(x * Float32(pi))) / Float32(x * Float32(Float32(pi) * t_1)))) end
function tmp = code(x, tau) t_1 = x * (single(pi) * tau); tmp = sin(t_1) * (sin((x * single(pi))) / (x * (single(pi) * t_1))); end
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot \left(\pi \cdot tau\right)\\
\sin t\_1 \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \left(\pi \cdot t\_1\right)}
\end{array}
\end{array}
Initial program 97.9%
associate-*l/97.7%
associate-/l*97.8%
associate-*l*97.1%
associate-/l/97.0%
*-commutative97.0%
*-commutative97.0%
associate-*l*96.9%
associate-*l*97.2%
Simplified97.2%
associate-*r*96.9%
associate-*r*97.0%
*-commutative97.0%
associate-/r*97.1%
*-commutative97.1%
associate-/r*97.1%
associate-/r*96.8%
*-un-lft-identity96.8%
times-frac96.8%
*-commutative96.8%
associate-*l*96.7%
Applied egg-rr96.7%
associate-/l/96.8%
frac-times96.9%
*-un-lft-identity96.9%
associate-*r*97.1%
*-commutative97.1%
associate-*r*97.4%
Applied egg-rr97.4%
Final simplification97.4%
(FPCore (x tau) :precision binary32 (* (/ (/ 1.0 tau) x) (/ (sin (* PI (* x tau))) PI)))
float code(float x, float tau) {
return ((1.0f / tau) / x) * (sinf((((float) M_PI) * (x * tau))) / ((float) M_PI));
}
function code(x, tau) return Float32(Float32(Float32(Float32(1.0) / tau) / x) * Float32(sin(Float32(Float32(pi) * Float32(x * tau))) / Float32(pi))) end
function tmp = code(x, tau) tmp = ((single(1.0) / tau) / x) * (sin((single(pi) * (x * tau))) / single(pi)); end
\begin{array}{l}
\\
\frac{\frac{1}{tau}}{x} \cdot \frac{\sin \left(\pi \cdot \left(x \cdot tau\right)\right)}{\pi}
\end{array}
Initial program 97.9%
associate-*l/97.7%
associate-/l*97.8%
associate-*l*97.1%
associate-/l/97.0%
*-commutative97.0%
*-commutative97.0%
associate-*l*96.9%
associate-*l*97.2%
Simplified97.2%
associate-*r*96.9%
associate-*r*97.0%
*-commutative97.0%
*-commutative97.0%
associate-*r*97.6%
*-commutative97.6%
associate-*r*97.0%
associate-/r*97.1%
Applied egg-rr97.8%
Taylor expanded in x around 0 71.9%
times-frac72.1%
Applied egg-rr72.1%
(FPCore (x tau) :precision binary32 (/ (/ (sin (* (* x PI) tau)) tau) (* x PI)))
float code(float x, float tau) {
return (sinf(((x * ((float) M_PI)) * tau)) / tau) / (x * ((float) M_PI));
}
function code(x, tau) return Float32(Float32(sin(Float32(Float32(x * Float32(pi)) * tau)) / tau) / Float32(x * Float32(pi))) end
function tmp = code(x, tau) tmp = (sin(((x * single(pi)) * tau)) / tau) / (x * single(pi)); end
\begin{array}{l}
\\
\frac{\frac{\sin \left(\left(x \cdot \pi\right) \cdot tau\right)}{tau}}{x \cdot \pi}
\end{array}
Initial program 97.9%
associate-*l/97.7%
associate-/l*97.8%
associate-*l*97.1%
associate-/l/97.0%
*-commutative97.0%
*-commutative97.0%
associate-*l*96.9%
associate-*l*97.2%
Simplified97.2%
associate-*r*96.9%
associate-*r*97.0%
*-commutative97.0%
*-commutative97.0%
associate-*r*97.6%
*-commutative97.6%
associate-*r*97.0%
associate-/r*97.1%
Applied egg-rr97.8%
Taylor expanded in x around 0 71.9%
Taylor expanded in tau around inf 72.1%
Final simplification72.1%
(FPCore (x tau) :precision binary32 (/ (sin (* x (* PI tau))) (* (* x PI) tau)))
float code(float x, float tau) {
return sinf((x * (((float) M_PI) * tau))) / ((x * ((float) M_PI)) * tau);
}
function code(x, tau) return Float32(sin(Float32(x * Float32(Float32(pi) * tau))) / Float32(Float32(x * Float32(pi)) * tau)) end
function tmp = code(x, tau) tmp = sin((x * (single(pi) * tau))) / ((x * single(pi)) * tau); end
\begin{array}{l}
\\
\frac{\sin \left(x \cdot \left(\pi \cdot tau\right)\right)}{\left(x \cdot \pi\right) \cdot tau}
\end{array}
Initial program 97.9%
add-log-exp97.1%
associate-*r*96.8%
associate-*r*97.1%
*-commutative97.1%
associate-*l*96.8%
*-commutative96.8%
associate-*l*97.2%
Applied egg-rr97.2%
*-commutative97.2%
clear-num97.1%
rem-log-exp97.8%
frac-times97.7%
*-un-lft-identity97.7%
associate-*r*97.0%
*-commutative97.0%
associate-*r*97.0%
associate-*r*97.1%
*-commutative97.1%
associate-*r*97.7%
Applied egg-rr97.7%
Taylor expanded in x around 0 71.9%
Final simplification71.9%
(FPCore (x tau) :precision binary32 (/ (sin (* x PI)) (* x PI)))
float code(float x, float tau) {
return sinf((x * ((float) M_PI))) / (x * ((float) M_PI));
}
function code(x, tau) return Float32(sin(Float32(x * Float32(pi))) / Float32(x * Float32(pi))) end
function tmp = code(x, tau) tmp = sin((x * single(pi))) / (x * single(pi)); end
\begin{array}{l}
\\
\frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi}
\end{array}
Initial program 97.9%
associate-*l/97.7%
associate-/l*97.8%
associate-*l*97.1%
associate-/l/97.0%
*-commutative97.0%
*-commutative97.0%
associate-*l*96.9%
associate-*l*97.2%
Simplified97.2%
Taylor expanded in tau around 0 65.6%
(FPCore (x tau) :precision binary32 1.0)
float code(float x, float tau) {
return 1.0f;
}
real(4) function code(x, tau)
real(4), intent (in) :: x
real(4), intent (in) :: tau
code = 1.0e0
end function
function code(x, tau) return Float32(1.0) end
function tmp = code(x, tau) tmp = single(1.0); end
\begin{array}{l}
\\
1
\end{array}
Initial program 97.9%
associate-*l/97.7%
associate-/l*97.8%
associate-*l*97.1%
associate-/l/97.0%
*-commutative97.0%
*-commutative97.0%
associate-*l*96.9%
associate-*l*97.2%
Simplified97.2%
Taylor expanded in x around 0 64.9%
herbie shell --seed 2024135
(FPCore (x tau)
:name "Lanczos kernel"
:precision binary32
:pre (and (and (<= 1e-5 x) (<= x 1.0)) (and (<= 1.0 tau) (<= tau 5.0)))
(* (/ (sin (* (* x PI) tau)) (* (* x PI) tau)) (/ (sin (* x PI)) (* x PI))))