
(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 15 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 (* PI (* x tau)))) (* (/ (sin t_1) t_1) (/ (sin (* PI x)) (* PI x)))))
float code(float x, float tau) {
float t_1 = ((float) M_PI) * (x * tau);
return (sinf(t_1) / t_1) * (sinf((((float) M_PI) * x)) / (((float) M_PI) * x));
}
function code(x, tau) t_1 = Float32(Float32(pi) * Float32(x * tau)) return Float32(Float32(sin(t_1) / t_1) * Float32(sin(Float32(Float32(pi) * x)) / Float32(Float32(pi) * x))) end
function tmp = code(x, tau) t_1 = single(pi) * (x * tau); tmp = (sin(t_1) / t_1) * (sin((single(pi) * x)) / (single(pi) * x)); end
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \pi \cdot \left(x \cdot tau\right)\\
\frac{\sin t\_1}{t\_1} \cdot \frac{\sin \left(\pi \cdot x\right)}{\pi \cdot x}
\end{array}
\end{array}
Initial program 97.9%
*-commutative97.9%
associate-*l*97.2%
*-commutative97.2%
associate-*l*98.1%
Simplified98.1%
Final simplification98.1%
(FPCore (x tau) :precision binary32 (let* ((t_1 (* x (* PI tau)))) (* (sin t_1) (/ (sin (* PI x)) (* PI (* x t_1))))))
float code(float x, float tau) {
float t_1 = x * (((float) M_PI) * tau);
return sinf(t_1) * (sinf((((float) M_PI) * x)) / (((float) M_PI) * (x * t_1)));
}
function code(x, tau) t_1 = Float32(x * Float32(Float32(pi) * tau)) return Float32(sin(t_1) * Float32(sin(Float32(Float32(pi) * x)) / Float32(Float32(pi) * Float32(x * t_1)))) end
function tmp = code(x, tau) t_1 = x * (single(pi) * tau); tmp = sin(t_1) * (sin((single(pi) * x)) / (single(pi) * (x * 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(\pi \cdot x\right)}{\pi \cdot \left(x \cdot t\_1\right)}
\end{array}
\end{array}
Initial program 97.9%
associate-*l/97.8%
associate-/l*97.8%
associate-*l*97.3%
associate-/l/97.2%
*-commutative97.2%
*-commutative97.2%
associate-*l*97.2%
associate-*l*97.4%
Simplified97.4%
Final simplification97.4%
(FPCore (x tau) :precision binary32 (let* ((t_1 (* x (* PI tau)))) (* (sin t_1) (/ (sin (* PI x)) (* (* PI x) t_1)))))
float code(float x, float tau) {
float t_1 = x * (((float) M_PI) * tau);
return sinf(t_1) * (sinf((((float) M_PI) * x)) / ((((float) M_PI) * x) * t_1));
}
function code(x, tau) t_1 = Float32(x * Float32(Float32(pi) * tau)) return Float32(sin(t_1) * Float32(sin(Float32(Float32(pi) * x)) / Float32(Float32(Float32(pi) * x) * t_1))) end
function tmp = code(x, tau) t_1 = x * (single(pi) * tau); tmp = sin(t_1) * (sin((single(pi) * x)) / ((single(pi) * x) * 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(\pi \cdot x\right)}{\left(\pi \cdot x\right) \cdot t\_1}
\end{array}
\end{array}
Initial program 97.9%
associate-*l/97.8%
associate-/l*97.8%
associate-*l*97.3%
associate-/l/97.2%
associate-*l*97.8%
Simplified97.8%
Final simplification97.8%
(FPCore (x tau) :precision binary32 (let* ((t_1 (* tau (* PI x)))) (* (/ (sin (* PI x)) (* PI x)) (/ (sin t_1) t_1))))
float code(float x, float tau) {
float t_1 = tau * (((float) M_PI) * x);
return (sinf((((float) M_PI) * x)) / (((float) M_PI) * x)) * (sinf(t_1) / t_1);
}
function code(x, tau) t_1 = Float32(tau * Float32(Float32(pi) * x)) return Float32(Float32(sin(Float32(Float32(pi) * x)) / Float32(Float32(pi) * x)) * Float32(sin(t_1) / t_1)) end
function tmp = code(x, tau) t_1 = tau * (single(pi) * x); tmp = (sin((single(pi) * x)) / (single(pi) * x)) * (sin(t_1) / t_1); end
\begin{array}{l}
\\
\begin{array}{l}
t_1 := tau \cdot \left(\pi \cdot x\right)\\
\frac{\sin \left(\pi \cdot x\right)}{\pi \cdot x} \cdot \frac{\sin t\_1}{t\_1}
\end{array}
\end{array}
Initial program 97.9%
associate-*l/97.8%
associate-/l*97.8%
associate-*l*97.3%
associate-/l/97.2%
*-commutative97.2%
*-commutative97.2%
associate-*l*97.2%
associate-*l*97.4%
Simplified97.4%
associate-*r/97.3%
*-commutative97.3%
*-commutative97.3%
associate-*r*97.9%
associate-*r/97.8%
*-commutative97.8%
associate-/r*97.7%
associate-*l/97.7%
Applied egg-rr97.8%
associate-/l*97.9%
associate-/r*97.6%
rem-log-exp78.0%
frac-times78.0%
associate-*r*78.0%
*-commutative78.0%
*-commutative78.0%
associate-*r*77.9%
associate-*r/77.9%
Applied egg-rr97.7%
*-commutative97.7%
*-commutative97.7%
associate-*r*96.9%
*-commutative96.9%
*-commutative96.9%
associate-*r*97.6%
associate-/l/97.9%
*-commutative97.9%
Simplified97.9%
Final simplification97.9%
(FPCore (x tau) :precision binary32 (let* ((t_1 (* tau (* PI x)))) (* (/ (sin t_1) t_1) (/ (* PI x) (* PI x)))))
float code(float x, float tau) {
float t_1 = tau * (((float) M_PI) * x);
return (sinf(t_1) / t_1) * ((((float) M_PI) * x) / (((float) M_PI) * x));
}
function code(x, tau) t_1 = Float32(tau * Float32(Float32(pi) * x)) return Float32(Float32(sin(t_1) / t_1) * Float32(Float32(Float32(pi) * x) / Float32(Float32(pi) * x))) end
function tmp = code(x, tau) t_1 = tau * (single(pi) * x); tmp = (sin(t_1) / t_1) * ((single(pi) * x) / (single(pi) * x)); end
\begin{array}{l}
\\
\begin{array}{l}
t_1 := tau \cdot \left(\pi \cdot x\right)\\
\frac{\sin t\_1}{t\_1} \cdot \frac{\pi \cdot x}{\pi \cdot x}
\end{array}
\end{array}
Initial program 97.9%
*-commutative97.9%
associate-*l*97.2%
*-commutative97.2%
associate-*l*98.1%
Simplified98.1%
Taylor expanded in x around 0 97.3%
Taylor expanded in x around 0 70.9%
Taylor expanded in x around inf 71.1%
Final simplification71.1%
(FPCore (x tau) :precision binary32 (* (/ (/ (sin (* tau (* PI x))) (* PI x)) tau) (/ (* PI x) (* PI x))))
float code(float x, float tau) {
return ((sinf((tau * (((float) M_PI) * x))) / (((float) M_PI) * x)) / tau) * ((((float) M_PI) * x) / (((float) M_PI) * x));
}
function code(x, tau) return Float32(Float32(Float32(sin(Float32(tau * Float32(Float32(pi) * x))) / Float32(Float32(pi) * x)) / tau) * Float32(Float32(Float32(pi) * x) / Float32(Float32(pi) * x))) end
function tmp = code(x, tau) tmp = ((sin((tau * (single(pi) * x))) / (single(pi) * x)) / tau) * ((single(pi) * x) / (single(pi) * x)); end
\begin{array}{l}
\\
\frac{\frac{\sin \left(tau \cdot \left(\pi \cdot x\right)\right)}{\pi \cdot x}}{tau} \cdot \frac{\pi \cdot x}{\pi \cdot x}
\end{array}
Initial program 97.9%
*-commutative97.9%
associate-*l*97.2%
*-commutative97.2%
associate-*l*98.1%
Simplified98.1%
Taylor expanded in x around 0 97.3%
Taylor expanded in x around 0 70.9%
*-un-lft-identity70.9%
*-commutative70.9%
times-frac70.9%
Applied egg-rr70.9%
associate-*l/71.0%
*-lft-identity71.0%
*-commutative71.0%
*-commutative71.0%
associate-*r*71.2%
*-commutative71.2%
Simplified71.2%
Final simplification71.2%
(FPCore (x tau) :precision binary32 (let* ((t_1 (* x (* PI tau)))) (* x (/ (sin t_1) (* x t_1)))))
float code(float x, float tau) {
float t_1 = x * (((float) M_PI) * tau);
return x * (sinf(t_1) / (x * t_1));
}
function code(x, tau) t_1 = Float32(x * Float32(Float32(pi) * tau)) return Float32(x * Float32(sin(t_1) / Float32(x * t_1))) end
function tmp = code(x, tau) t_1 = x * (single(pi) * tau); tmp = x * (sin(t_1) / (x * t_1)); end
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot \left(\pi \cdot tau\right)\\
x \cdot \frac{\sin t\_1}{x \cdot t\_1}
\end{array}
\end{array}
Initial program 97.9%
associate-*r/97.7%
times-frac97.4%
associate-/l/97.3%
associate-*l*97.2%
associate-*l*97.4%
Simplified97.4%
Taylor expanded in x around 0 71.1%
Final simplification71.1%
(FPCore (x tau) :precision binary32 (* (sin (* x (* PI tau))) (/ 1.0 (* tau (* PI x)))))
float code(float x, float tau) {
return sinf((x * (((float) M_PI) * tau))) * (1.0f / (tau * (((float) M_PI) * x)));
}
function code(x, tau) return Float32(sin(Float32(x * Float32(Float32(pi) * tau))) * Float32(Float32(1.0) / Float32(tau * Float32(Float32(pi) * x)))) end
function tmp = code(x, tau) tmp = sin((x * (single(pi) * tau))) * (single(1.0) / (tau * (single(pi) * x))); end
\begin{array}{l}
\\
\sin \left(x \cdot \left(\pi \cdot tau\right)\right) \cdot \frac{1}{tau \cdot \left(\pi \cdot x\right)}
\end{array}
Initial program 97.9%
associate-*l/97.8%
associate-/l*97.8%
associate-*l*97.3%
associate-/l/97.2%
*-commutative97.2%
*-commutative97.2%
associate-*l*97.2%
associate-*l*97.4%
Simplified97.4%
Taylor expanded in x around 0 70.9%
Final simplification70.9%
(FPCore (x tau) :precision binary32 (/ (* (sin (* PI (* x tau))) (/ 1.0 tau)) (* PI x)))
float code(float x, float tau) {
return (sinf((((float) M_PI) * (x * tau))) * (1.0f / tau)) / (((float) M_PI) * x);
}
function code(x, tau) return Float32(Float32(sin(Float32(Float32(pi) * Float32(x * tau))) * Float32(Float32(1.0) / tau)) / Float32(Float32(pi) * x)) end
function tmp = code(x, tau) tmp = (sin((single(pi) * (x * tau))) * (single(1.0) / tau)) / (single(pi) * x); end
\begin{array}{l}
\\
\frac{\sin \left(\pi \cdot \left(x \cdot tau\right)\right) \cdot \frac{1}{tau}}{\pi \cdot x}
\end{array}
Initial program 97.9%
associate-*l/97.8%
associate-/l*97.8%
associate-*l*97.3%
associate-/l/97.2%
*-commutative97.2%
*-commutative97.2%
associate-*l*97.2%
associate-*l*97.4%
Simplified97.4%
associate-*r/97.3%
*-commutative97.3%
*-commutative97.3%
associate-*r*97.9%
associate-*r/97.8%
*-commutative97.8%
associate-/r*97.7%
associate-*l/97.7%
Applied egg-rr97.8%
Taylor expanded in x around 0 70.9%
Final simplification70.9%
(FPCore (x tau) :precision binary32 (/ (/ (* (sin (* PI (* x tau))) (/ 1.0 tau)) PI) x))
float code(float x, float tau) {
return ((sinf((((float) M_PI) * (x * tau))) * (1.0f / tau)) / ((float) M_PI)) / x;
}
function code(x, tau) return Float32(Float32(Float32(sin(Float32(Float32(pi) * Float32(x * tau))) * Float32(Float32(1.0) / tau)) / Float32(pi)) / x) end
function tmp = code(x, tau) tmp = ((sin((single(pi) * (x * tau))) * (single(1.0) / tau)) / single(pi)) / x; end
\begin{array}{l}
\\
\frac{\frac{\sin \left(\pi \cdot \left(x \cdot tau\right)\right) \cdot \frac{1}{tau}}{\pi}}{x}
\end{array}
Initial program 97.9%
associate-*r/97.7%
times-frac97.4%
associate-/l/97.3%
associate-*l*97.2%
associate-*l*97.4%
Simplified97.4%
add-log-exp77.9%
*-commutative77.9%
Applied egg-rr77.9%
*-commutative77.9%
associate-*r*77.8%
*-commutative77.8%
associate-*r*77.9%
associate-*r/77.9%
associate-*r*78.0%
*-commutative78.0%
*-commutative78.0%
associate-*r*78.0%
frac-times78.0%
Applied egg-rr97.5%
Taylor expanded in x around 0 70.9%
Final simplification70.9%
(FPCore (x tau) :precision binary32 (/ (/ (sin (* PI (* x tau))) x) (* PI tau)))
float code(float x, float tau) {
return (sinf((((float) M_PI) * (x * tau))) / x) / (((float) M_PI) * tau);
}
function code(x, tau) return Float32(Float32(sin(Float32(Float32(pi) * Float32(x * tau))) / x) / Float32(Float32(pi) * tau)) end
function tmp = code(x, tau) tmp = (sin((single(pi) * (x * tau))) / x) / (single(pi) * tau); end
\begin{array}{l}
\\
\frac{\frac{\sin \left(\pi \cdot \left(x \cdot tau\right)\right)}{x}}{\pi \cdot tau}
\end{array}
Initial program 97.9%
associate-*l/97.8%
associate-/l*97.8%
associate-*l*97.3%
associate-/l/97.2%
*-commutative97.2%
*-commutative97.2%
associate-*l*97.2%
associate-*l*97.4%
Simplified97.4%
associate-*r/97.3%
*-commutative97.3%
frac-times97.4%
associate-/r*97.4%
clear-num97.1%
frac-times97.3%
Applied egg-rr97.3%
Taylor expanded in x around 0 70.8%
Final simplification70.8%
(FPCore (x tau) :precision binary32 (fma -0.16666666666666666 (* x (* PI (* PI x))) 1.0))
float code(float x, float tau) {
return fmaf(-0.16666666666666666f, (x * (((float) M_PI) * (((float) M_PI) * x))), 1.0f);
}
function code(x, tau) return fma(Float32(-0.16666666666666666), Float32(x * Float32(Float32(pi) * Float32(Float32(pi) * x))), Float32(1.0)) end
\begin{array}{l}
\\
\mathsf{fma}\left(-0.16666666666666666, x \cdot \left(\pi \cdot \left(\pi \cdot x\right)\right), 1\right)
\end{array}
Initial program 97.9%
associate-*l/97.8%
associate-/l*97.8%
associate-*l*97.3%
associate-/l/97.2%
*-commutative97.2%
*-commutative97.2%
associate-*l*97.2%
associate-*l*97.4%
Simplified97.4%
Taylor expanded in tau around 0 64.4%
Taylor expanded in x around 0 64.4%
+-commutative64.4%
fma-define64.4%
*-commutative64.4%
unpow264.4%
unpow264.4%
swap-sqr64.4%
unpow264.4%
*-commutative64.4%
Simplified64.4%
unpow264.4%
*-commutative64.4%
associate-*r*64.4%
Applied egg-rr64.4%
Final simplification64.4%
(FPCore (x tau) :precision binary32 (+ 1.0 (* -0.16666666666666666 (pow (* PI x) 2.0))))
float code(float x, float tau) {
return 1.0f + (-0.16666666666666666f * powf((((float) M_PI) * x), 2.0f));
}
function code(x, tau) return Float32(Float32(1.0) + Float32(Float32(-0.16666666666666666) * (Float32(Float32(pi) * x) ^ Float32(2.0)))) end
function tmp = code(x, tau) tmp = single(1.0) + (single(-0.16666666666666666) * ((single(pi) * x) ^ single(2.0))); end
\begin{array}{l}
\\
1 + -0.16666666666666666 \cdot {\left(\pi \cdot x\right)}^{2}
\end{array}
Initial program 97.9%
associate-*l/97.8%
associate-/l*97.8%
associate-*l*97.3%
associate-/l/97.2%
*-commutative97.2%
*-commutative97.2%
associate-*l*97.2%
associate-*l*97.4%
Simplified97.4%
Taylor expanded in tau around 0 64.4%
Taylor expanded in x around 0 64.4%
+-commutative64.4%
fma-define64.4%
*-commutative64.4%
unpow264.4%
unpow264.4%
swap-sqr64.4%
unpow264.4%
*-commutative64.4%
Simplified64.4%
fma-undefine64.4%
*-commutative64.4%
Applied egg-rr64.4%
Final simplification64.4%
(FPCore (x tau) :precision binary32 (/ (sin (* PI x)) (* PI x)))
float code(float x, float tau) {
return sinf((((float) M_PI) * x)) / (((float) M_PI) * x);
}
function code(x, tau) return Float32(sin(Float32(Float32(pi) * x)) / Float32(Float32(pi) * x)) end
function tmp = code(x, tau) tmp = sin((single(pi) * x)) / (single(pi) * x); end
\begin{array}{l}
\\
\frac{\sin \left(\pi \cdot x\right)}{\pi \cdot x}
\end{array}
Initial program 97.9%
associate-*l/97.8%
associate-/l*97.8%
associate-*l*97.3%
associate-/l/97.2%
*-commutative97.2%
*-commutative97.2%
associate-*l*97.2%
associate-*l*97.4%
Simplified97.4%
Taylor expanded in tau around 0 64.4%
Final simplification64.4%
(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.8%
associate-/l*97.8%
associate-*l*97.3%
associate-/l/97.2%
*-commutative97.2%
*-commutative97.2%
associate-*l*97.2%
associate-*l*97.4%
Simplified97.4%
associate-*r/97.3%
*-commutative97.3%
*-commutative97.3%
associate-*r*97.9%
associate-*r/97.8%
*-commutative97.8%
associate-/r*97.7%
associate-*l/97.7%
Applied egg-rr97.8%
Taylor expanded in x around 0 63.6%
Final simplification63.6%
herbie shell --seed 2024078
(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))))