
(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 13 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))) (t_2 (expm1 (log1p (* PI x))))) (* (/ (sin t_1) t_1) (/ (sin t_2) t_2))))
float code(float x, float tau) {
float t_1 = ((float) M_PI) * (x * tau);
float t_2 = expm1f(log1pf((((float) M_PI) * x)));
return (sinf(t_1) / t_1) * (sinf(t_2) / t_2);
}
function code(x, tau) t_1 = Float32(Float32(pi) * Float32(x * tau)) t_2 = expm1(log1p(Float32(Float32(pi) * x))) return Float32(Float32(sin(t_1) / t_1) * Float32(sin(t_2) / t_2)) end
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \pi \cdot \left(x \cdot tau\right)\\
t_2 := \mathsf{expm1}\left(\mathsf{log1p}\left(\pi \cdot x\right)\right)\\
\frac{\sin t_1}{t_1} \cdot \frac{\sin t_2}{t_2}
\end{array}
\end{array}
Initial program 98.1%
*-commutative98.1%
associate-*l*97.6%
*-commutative97.6%
associate-*l*98.1%
Simplified98.1%
expm1-log1p-u98.0%
Applied egg-rr98.0%
expm1-log1p-u98.0%
Applied egg-rr98.1%
Final simplification98.1%
(FPCore (x tau) :precision binary32 (let* ((t_1 (* x (* PI tau)))) (* (/ (sin t_1) (* PI x)) (/ (sin (* PI x)) t_1))))
float code(float x, float tau) {
float t_1 = x * (((float) M_PI) * tau);
return (sinf(t_1) / (((float) M_PI) * x)) * (sinf((((float) M_PI) * x)) / t_1);
}
function code(x, tau) t_1 = Float32(x * Float32(Float32(pi) * tau)) return Float32(Float32(sin(t_1) / Float32(Float32(pi) * x)) * Float32(sin(Float32(Float32(pi) * x)) / t_1)) end
function tmp = code(x, tau) t_1 = x * (single(pi) * tau); tmp = (sin(t_1) / (single(pi) * x)) * (sin((single(pi) * x)) / t_1); end
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot \left(\pi \cdot tau\right)\\
\frac{\sin t_1}{\pi \cdot x} \cdot \frac{\sin \left(\pi \cdot x\right)}{t_1}
\end{array}
\end{array}
Initial program 98.1%
associate-*l/98.1%
times-frac97.8%
associate-*l*97.5%
associate-/l/97.4%
*-commutative97.4%
associate-*l*97.9%
Simplified97.9%
Final simplification97.9%
(FPCore (x tau) :precision binary32 (let* ((t_1 (* x (* PI tau)))) (* (/ (sin (* PI x)) (* PI x)) (/ (sin t_1) t_1))))
float code(float x, float tau) {
float t_1 = x * (((float) M_PI) * tau);
return (sinf((((float) M_PI) * x)) / (((float) M_PI) * x)) * (sinf(t_1) / t_1);
}
function code(x, tau) t_1 = Float32(x * Float32(Float32(pi) * tau)) 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 = x * (single(pi) * tau); tmp = (sin((single(pi) * x)) / (single(pi) * x)) * (sin(t_1) / t_1); end
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot \left(\pi \cdot tau\right)\\
\frac{\sin \left(\pi \cdot x\right)}{\pi \cdot x} \cdot \frac{\sin t_1}{t_1}
\end{array}
\end{array}
Initial program 98.1%
associate-*l*97.6%
associate-*l*98.1%
Simplified98.1%
Final simplification98.1%
(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 98.1%
*-commutative98.1%
associate-*l*97.6%
*-commutative97.6%
associate-*l*98.1%
Simplified98.1%
Final simplification98.1%
(FPCore (x tau) :precision binary32 (* (/ (sin (* tau (* PI x))) tau) (/ (sin (* PI x)) (pow (* PI x) 2.0))))
float code(float x, float tau) {
return (sinf((tau * (((float) M_PI) * x))) / tau) * (sinf((((float) M_PI) * x)) / powf((((float) M_PI) * x), 2.0f));
}
function code(x, tau) return Float32(Float32(sin(Float32(tau * Float32(Float32(pi) * x))) / tau) * Float32(sin(Float32(Float32(pi) * x)) / (Float32(Float32(pi) * x) ^ Float32(2.0)))) end
function tmp = code(x, tau) tmp = (sin((tau * (single(pi) * x))) / tau) * (sin((single(pi) * x)) / ((single(pi) * x) ^ single(2.0))); end
\begin{array}{l}
\\
\frac{\sin \left(tau \cdot \left(\pi \cdot x\right)\right)}{tau} \cdot \frac{\sin \left(\pi \cdot x\right)}{{\left(\pi \cdot x\right)}^{2}}
\end{array}
Initial program 98.1%
associate-*l/98.1%
times-frac97.8%
associate-*l*97.5%
associate-/l/97.4%
*-commutative97.4%
associate-*l*97.9%
Simplified97.9%
expm1-log1p-u97.6%
Applied egg-rr97.6%
associate-/r*97.4%
expm1-log1p-u97.7%
frac-times97.7%
associate-*r*97.0%
*-commutative97.0%
associate-*r*97.5%
*-commutative97.5%
associate-*r*97.5%
*-commutative97.5%
associate-*r*97.8%
Applied egg-rr97.8%
Taylor expanded in x around inf 97.0%
times-frac97.0%
*-commutative97.0%
unpow297.0%
unpow297.0%
swap-sqr97.5%
unpow297.5%
*-commutative97.5%
Simplified97.5%
Final simplification97.5%
(FPCore (x tau)
:precision binary32
(let* ((t_1 (* x (* PI tau))))
(*
(/ (sin t_1) t_1)
(+ 1.0 (* -0.16666666666666666 (* (* x x) (pow PI 2.0)))))))
float code(float x, float tau) {
float t_1 = x * (((float) M_PI) * tau);
return (sinf(t_1) / t_1) * (1.0f + (-0.16666666666666666f * ((x * x) * powf(((float) M_PI), 2.0f))));
}
function code(x, tau) t_1 = Float32(x * Float32(Float32(pi) * tau)) return Float32(Float32(sin(t_1) / t_1) * Float32(Float32(1.0) + Float32(Float32(-0.16666666666666666) * Float32(Float32(x * x) * (Float32(pi) ^ Float32(2.0)))))) end
function tmp = code(x, tau) t_1 = x * (single(pi) * tau); tmp = (sin(t_1) / t_1) * (single(1.0) + (single(-0.16666666666666666) * ((x * x) * (single(pi) ^ single(2.0))))); end
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot \left(\pi \cdot tau\right)\\
\frac{\sin t_1}{t_1} \cdot \left(1 + -0.16666666666666666 \cdot \left(\left(x \cdot x\right) \cdot {\pi}^{2}\right)\right)
\end{array}
\end{array}
Initial program 98.1%
associate-*l*97.6%
associate-*l*98.1%
Simplified98.1%
Taylor expanded in x around 0 85.9%
unpow264.5%
Simplified85.9%
Final simplification85.9%
(FPCore (x tau) :precision binary32 (let* ((t_1 (* PI (* x tau)))) (* (/ (sin t_1) t_1) (+ 1.0 (* (pow (* PI x) 2.0) -0.16666666666666666)))))
float code(float x, float tau) {
float t_1 = ((float) M_PI) * (x * tau);
return (sinf(t_1) / t_1) * (1.0f + (powf((((float) M_PI) * x), 2.0f) * -0.16666666666666666f));
}
function code(x, tau) t_1 = Float32(Float32(pi) * Float32(x * tau)) return Float32(Float32(sin(t_1) / t_1) * Float32(Float32(1.0) + Float32((Float32(Float32(pi) * x) ^ Float32(2.0)) * Float32(-0.16666666666666666)))) end
function tmp = code(x, tau) t_1 = single(pi) * (x * tau); tmp = (sin(t_1) / t_1) * (single(1.0) + (((single(pi) * x) ^ single(2.0)) * single(-0.16666666666666666))); end
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \pi \cdot \left(x \cdot tau\right)\\
\frac{\sin t_1}{t_1} \cdot \left(1 + {\left(\pi \cdot x\right)}^{2} \cdot -0.16666666666666666\right)
\end{array}
\end{array}
Initial program 98.1%
*-commutative98.1%
associate-*l*97.6%
*-commutative97.6%
associate-*l*98.1%
Simplified98.1%
Taylor expanded in x around 0 85.9%
unpow264.5%
Simplified85.9%
*-commutative64.5%
pow264.5%
pow-prod-down64.5%
Applied egg-rr85.9%
Final simplification85.9%
(FPCore (x tau) :precision binary32 (exp (* -0.16666666666666666 (* (pow (* PI x) 2.0) (fma tau tau 1.0)))))
float code(float x, float tau) {
return expf((-0.16666666666666666f * (powf((((float) M_PI) * x), 2.0f) * fmaf(tau, tau, 1.0f))));
}
function code(x, tau) return exp(Float32(Float32(-0.16666666666666666) * Float32((Float32(Float32(pi) * x) ^ Float32(2.0)) * fma(tau, tau, Float32(1.0))))) end
\begin{array}{l}
\\
e^{-0.16666666666666666 \cdot \left({\left(\pi \cdot x\right)}^{2} \cdot \mathsf{fma}\left(tau, tau, 1\right)\right)}
\end{array}
Initial program 98.1%
associate-*l/98.1%
times-frac97.8%
associate-*l*97.5%
associate-/l/97.4%
*-commutative97.4%
associate-*l*97.9%
Simplified97.9%
clear-num97.8%
frac-times97.9%
*-un-lft-identity97.9%
*-commutative97.9%
associate-/l*97.6%
Applied egg-rr97.6%
*-un-lft-identity97.6%
times-frac97.6%
clear-num97.7%
associate-/r*97.9%
expm1-log1p-u97.6%
add-exp-log94.2%
Applied egg-rr94.7%
Taylor expanded in x around 0 81.4%
unpow281.4%
distribute-lft-out81.4%
*-commutative81.4%
unpow281.4%
Simplified81.4%
Taylor expanded in x around 0 81.4%
associate-*r*81.4%
*-commutative81.4%
associate-*r*81.4%
distribute-lft-out81.4%
distribute-rgt-in81.4%
associate-*r*81.4%
associate-*r*81.4%
*-commutative81.4%
associate-*r*81.4%
associate-*r*81.4%
*-commutative81.4%
distribute-lft-out81.4%
Simplified81.4%
Final simplification81.4%
(FPCore (x tau) :precision binary32 (exp (* (* -0.16666666666666666 (* x x)) (* (pow PI 2.0) (+ 1.0 (* tau tau))))))
float code(float x, float tau) {
return expf(((-0.16666666666666666f * (x * x)) * (powf(((float) M_PI), 2.0f) * (1.0f + (tau * tau)))));
}
function code(x, tau) return exp(Float32(Float32(Float32(-0.16666666666666666) * Float32(x * x)) * Float32((Float32(pi) ^ Float32(2.0)) * Float32(Float32(1.0) + Float32(tau * tau))))) end
function tmp = code(x, tau) tmp = exp(((single(-0.16666666666666666) * (x * x)) * ((single(pi) ^ single(2.0)) * (single(1.0) + (tau * tau))))); end
\begin{array}{l}
\\
e^{\left(-0.16666666666666666 \cdot \left(x \cdot x\right)\right) \cdot \left({\pi}^{2} \cdot \left(1 + tau \cdot tau\right)\right)}
\end{array}
Initial program 98.1%
associate-*l/98.1%
times-frac97.8%
associate-*l*97.5%
associate-/l/97.4%
*-commutative97.4%
associate-*l*97.9%
Simplified97.9%
clear-num97.8%
frac-times97.9%
*-un-lft-identity97.9%
*-commutative97.9%
associate-/l*97.6%
Applied egg-rr97.6%
*-un-lft-identity97.6%
times-frac97.6%
clear-num97.7%
associate-/r*97.9%
expm1-log1p-u97.6%
add-exp-log94.2%
Applied egg-rr94.7%
Taylor expanded in x around 0 81.4%
unpow281.4%
distribute-lft-out81.4%
*-commutative81.4%
unpow281.4%
Simplified81.4%
Taylor expanded in x around 0 81.4%
associate-*r*81.4%
unpow281.4%
distribute-lft1-in81.4%
unpow281.4%
Simplified81.4%
Final simplification81.4%
(FPCore (x tau) :precision binary32 (+ 1.0 (* (* x x) (* -0.16666666666666666 (* (pow PI 2.0) (+ 1.0 (* tau tau)))))))
float code(float x, float tau) {
return 1.0f + ((x * x) * (-0.16666666666666666f * (powf(((float) M_PI), 2.0f) * (1.0f + (tau * tau)))));
}
function code(x, tau) return Float32(Float32(1.0) + Float32(Float32(x * x) * Float32(Float32(-0.16666666666666666) * Float32((Float32(pi) ^ Float32(2.0)) * Float32(Float32(1.0) + Float32(tau * tau)))))) end
function tmp = code(x, tau) tmp = single(1.0) + ((x * x) * (single(-0.16666666666666666) * ((single(pi) ^ single(2.0)) * (single(1.0) + (tau * tau))))); end
\begin{array}{l}
\\
1 + \left(x \cdot x\right) \cdot \left(-0.16666666666666666 \cdot \left({\pi}^{2} \cdot \left(1 + tau \cdot tau\right)\right)\right)
\end{array}
Initial program 98.1%
associate-*l/98.1%
times-frac97.8%
associate-*l*97.5%
associate-/l/97.4%
*-commutative97.4%
associate-*l*97.9%
Simplified97.9%
expm1-log1p-u97.6%
Applied egg-rr97.6%
associate-/r*97.4%
expm1-log1p-u97.7%
frac-times97.7%
associate-*r*97.0%
*-commutative97.0%
associate-*r*97.5%
*-commutative97.5%
associate-*r*97.5%
*-commutative97.5%
associate-*r*97.8%
Applied egg-rr97.8%
Taylor expanded in x around 0 79.4%
+-commutative79.4%
unpow279.4%
+-commutative79.4%
distribute-lft-out79.4%
distribute-lft1-in79.4%
unpow279.4%
Simplified79.4%
Final simplification79.4%
(FPCore (x tau) :precision binary32 (+ 1.0 (* -0.16666666666666666 (* (* x x) (pow PI 2.0)))))
float code(float x, float tau) {
return 1.0f + (-0.16666666666666666f * ((x * x) * powf(((float) M_PI), 2.0f)));
}
function code(x, tau) return Float32(Float32(1.0) + Float32(Float32(-0.16666666666666666) * Float32(Float32(x * x) * (Float32(pi) ^ Float32(2.0))))) end
function tmp = code(x, tau) tmp = single(1.0) + (single(-0.16666666666666666) * ((x * x) * (single(pi) ^ single(2.0)))); end
\begin{array}{l}
\\
1 + -0.16666666666666666 \cdot \left(\left(x \cdot x\right) \cdot {\pi}^{2}\right)
\end{array}
Initial program 98.1%
associate-*l/98.1%
times-frac97.8%
associate-*l*97.5%
associate-/l/97.4%
*-commutative97.4%
associate-*l*97.9%
Simplified97.9%
Taylor expanded in tau around 0 64.5%
Taylor expanded in x around 0 64.5%
unpow264.5%
Simplified64.5%
Final simplification64.5%
(FPCore (x tau) :precision binary32 (+ 1.0 (* (pow (* PI x) 2.0) -0.16666666666666666)))
float code(float x, float tau) {
return 1.0f + (powf((((float) M_PI) * x), 2.0f) * -0.16666666666666666f);
}
function code(x, tau) return Float32(Float32(1.0) + Float32((Float32(Float32(pi) * x) ^ Float32(2.0)) * Float32(-0.16666666666666666))) end
function tmp = code(x, tau) tmp = single(1.0) + (((single(pi) * x) ^ single(2.0)) * single(-0.16666666666666666)); end
\begin{array}{l}
\\
1 + {\left(\pi \cdot x\right)}^{2} \cdot -0.16666666666666666
\end{array}
Initial program 98.1%
associate-*l/98.1%
times-frac97.8%
associate-*l*97.5%
associate-/l/97.4%
*-commutative97.4%
associate-*l*97.9%
Simplified97.9%
Taylor expanded in tau around 0 64.5%
Taylor expanded in x around 0 64.5%
unpow264.5%
Simplified64.5%
*-commutative64.5%
pow264.5%
pow-prod-down64.5%
Applied egg-rr64.5%
Final simplification64.5%
(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 98.1%
associate-*l/98.1%
times-frac97.8%
associate-*l*97.5%
associate-/l/97.4%
*-commutative97.4%
associate-*l*97.9%
Simplified97.9%
Taylor expanded in x around 0 63.6%
Final simplification63.6%
herbie shell --seed 2023279
(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))))