
(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 11 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.0%
Simplified98.0%
Final simplification98.0%
(FPCore (x tau) :precision binary32 (let* ((t_1 (* PI (* x tau)))) (* (/ (sin t_1) x) (/ (sin (* PI x)) (* PI t_1)))))
float code(float x, float tau) {
float t_1 = ((float) M_PI) * (x * tau);
return (sinf(t_1) / x) * (sinf((((float) M_PI) * x)) / (((float) M_PI) * t_1));
}
function code(x, tau) t_1 = Float32(Float32(pi) * Float32(x * tau)) return Float32(Float32(sin(t_1) / x) * Float32(sin(Float32(Float32(pi) * x)) / Float32(Float32(pi) * t_1))) end
function tmp = code(x, tau) t_1 = single(pi) * (x * tau); tmp = (sin(t_1) / x) * (sin((single(pi) * x)) / (single(pi) * t_1)); end
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \pi \cdot \left(x \cdot tau\right)\\
\frac{\sin t_1}{x} \cdot \frac{\sin \left(\pi \cdot x\right)}{\pi \cdot t_1}
\end{array}
\end{array}
Initial program 97.9%
associate-/r/97.9%
associate-*l*97.2%
*-commutative97.2%
associate-/l*97.1%
*-commutative97.1%
associate-*l*97.0%
associate-/l/97.0%
*-commutative97.0%
Simplified97.0%
associate-*r*96.9%
*-commutative96.9%
associate-*r*97.0%
*-un-lft-identity97.0%
times-frac96.9%
*-commutative96.9%
associate-/r*96.9%
*-commutative96.9%
*-commutative96.9%
Applied egg-rr96.9%
associate-/r/97.0%
associate-/l/97.1%
associate-*r*97.4%
frac-times97.4%
*-un-lft-identity97.4%
Applied egg-rr97.4%
Final simplification97.4%
(FPCore (x tau) :precision binary32 (* (sin (* tau (* PI x))) (/ (sin (* PI x)) (* tau (pow (* PI x) 2.0)))))
float code(float x, float tau) {
return sinf((tau * (((float) M_PI) * x))) * (sinf((((float) M_PI) * x)) / (tau * powf((((float) M_PI) * x), 2.0f)));
}
function code(x, tau) return Float32(sin(Float32(tau * Float32(Float32(pi) * x))) * Float32(sin(Float32(Float32(pi) * x)) / Float32(tau * (Float32(Float32(pi) * x) ^ Float32(2.0))))) end
function tmp = code(x, tau) tmp = sin((tau * (single(pi) * x))) * (sin((single(pi) * x)) / (tau * ((single(pi) * x) ^ single(2.0)))); end
\begin{array}{l}
\\
\sin \left(tau \cdot \left(\pi \cdot x\right)\right) \cdot \frac{\sin \left(\pi \cdot x\right)}{tau \cdot {\left(\pi \cdot x\right)}^{2}}
\end{array}
Initial program 97.9%
associate-*l/97.7%
*-commutative97.7%
times-frac97.5%
associate-/l/97.4%
associate-*l*97.2%
*-commutative97.2%
associate-*l*97.1%
Simplified97.1%
Taylor expanded in x around inf 97.0%
associate-/l*96.8%
*-commutative96.8%
*-commutative96.8%
*-commutative96.8%
associate-*r*96.9%
*-commutative96.9%
associate-/r/97.0%
Simplified97.2%
Final simplification97.2%
(FPCore (x tau) :precision binary32 (* (sin (* PI x)) (* (sin (* tau (* PI x))) (/ (pow (* PI x) -2.0) tau))))
float code(float x, float tau) {
return sinf((((float) M_PI) * x)) * (sinf((tau * (((float) M_PI) * x))) * (powf((((float) M_PI) * x), -2.0f) / tau));
}
function code(x, tau) return Float32(sin(Float32(Float32(pi) * x)) * Float32(sin(Float32(tau * Float32(Float32(pi) * x))) * Float32((Float32(Float32(pi) * x) ^ Float32(-2.0)) / tau))) end
function tmp = code(x, tau) tmp = sin((single(pi) * x)) * (sin((tau * (single(pi) * x))) * (((single(pi) * x) ^ single(-2.0)) / tau)); end
\begin{array}{l}
\\
\sin \left(\pi \cdot x\right) \cdot \left(\sin \left(tau \cdot \left(\pi \cdot x\right)\right) \cdot \frac{{\left(\pi \cdot x\right)}^{-2}}{tau}\right)
\end{array}
Initial program 97.9%
associate-/r/97.9%
associate-*l*97.2%
*-commutative97.2%
associate-/l*97.1%
associate-*l*97.3%
associate-/l/97.3%
associate-*r*97.2%
*-commutative97.2%
associate-*r*96.9%
associate-*l*96.9%
Simplified96.9%
add-log-exp96.7%
associate-/r/96.7%
associate-*r*96.3%
*-commutative96.3%
associate-*r*96.8%
*-commutative96.8%
associate-*r*96.9%
associate-*r*96.6%
*-commutative96.6%
*-commutative96.6%
associate-*l*96.6%
Applied egg-rr96.8%
*-un-lft-identity96.8%
log-prod96.8%
metadata-eval96.8%
rem-log-exp97.1%
*-commutative97.1%
times-frac97.0%
Applied egg-rr96.9%
+-lft-identity96.9%
associate-*l*96.9%
associate-*r/97.1%
*-commutative97.1%
associate-*r/97.0%
associate-*r*97.3%
Simplified97.3%
Final simplification97.3%
(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 97.9%
*-commutative97.9%
associate-*l*97.2%
*-commutative97.2%
associate-*l*98.0%
Simplified98.0%
expm1-log1p-u97.9%
*-commutative97.9%
Applied egg-rr97.9%
Taylor expanded in x around 0 84.5%
unpow284.5%
unpow284.5%
swap-sqr84.5%
unpow284.5%
Simplified84.5%
Final simplification84.5%
(FPCore (x tau) :precision binary32 (fma (pow x 2.0) (* -0.16666666666666666 (* (+ 1.0 (pow tau 2.0)) (pow PI 2.0))) 1.0))
float code(float x, float tau) {
return fmaf(powf(x, 2.0f), (-0.16666666666666666f * ((1.0f + powf(tau, 2.0f)) * powf(((float) M_PI), 2.0f))), 1.0f);
}
function code(x, tau) return fma((x ^ Float32(2.0)), Float32(Float32(-0.16666666666666666) * Float32(Float32(Float32(1.0) + (tau ^ Float32(2.0))) * (Float32(pi) ^ Float32(2.0)))), Float32(1.0)) end
\begin{array}{l}
\\
\mathsf{fma}\left({x}^{2}, -0.16666666666666666 \cdot \left(\left(1 + {tau}^{2}\right) \cdot {\pi}^{2}\right), 1\right)
\end{array}
Initial program 97.9%
associate-*l/97.7%
*-commutative97.7%
times-frac97.5%
associate-/l/97.4%
associate-*l*97.2%
*-commutative97.2%
associate-*l*97.1%
Simplified97.1%
Taylor expanded in x around 0 76.8%
+-commutative76.8%
fma-def76.8%
distribute-lft-out76.8%
distribute-lft1-in76.8%
Simplified76.8%
Final simplification76.8%
(FPCore (x tau) :precision binary32 (let* ((t_1 (* PI (* x tau)))) (/ (sin t_1) t_1)))
float code(float x, float tau) {
float t_1 = ((float) M_PI) * (x * tau);
return sinf(t_1) / t_1;
}
function code(x, tau) t_1 = Float32(Float32(pi) * Float32(x * tau)) return Float32(sin(t_1) / t_1) end
function tmp = code(x, tau) t_1 = single(pi) * (x * tau); tmp = sin(t_1) / t_1; end
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \pi \cdot \left(x \cdot tau\right)\\
\frac{\sin t_1}{t_1}
\end{array}
\end{array}
Initial program 97.9%
*-commutative97.9%
associate-*l*97.2%
*-commutative97.2%
associate-*l*98.0%
Simplified98.0%
expm1-log1p-u97.9%
*-commutative97.9%
Applied egg-rr97.9%
Taylor expanded in x around 0 69.4%
Final simplification69.4%
(FPCore (x tau) :precision binary32 (fma -0.16666666666666666 (* x (* x (pow PI 2.0))) 1.0))
float code(float x, float tau) {
return fmaf(-0.16666666666666666f, (x * (x * powf(((float) M_PI), 2.0f))), 1.0f);
}
function code(x, tau) return fma(Float32(-0.16666666666666666), Float32(x * Float32(x * (Float32(pi) ^ Float32(2.0)))), Float32(1.0)) end
\begin{array}{l}
\\
\mathsf{fma}\left(-0.16666666666666666, x \cdot \left(x \cdot {\pi}^{2}\right), 1\right)
\end{array}
Initial program 97.9%
associate-*l/97.7%
*-commutative97.7%
times-frac97.5%
associate-/l/97.4%
associate-*l*97.2%
*-commutative97.2%
associate-*l*97.1%
Simplified97.1%
Taylor expanded in tau around 0 62.4%
Taylor expanded in x around 0 62.5%
+-commutative62.5%
fma-def62.5%
*-commutative62.5%
unpow262.5%
unpow262.5%
swap-sqr62.5%
unpow262.5%
*-commutative62.5%
Simplified62.5%
*-commutative62.5%
pow262.5%
associate-*r*62.5%
*-commutative62.5%
associate-*l*62.5%
pow262.5%
Applied egg-rr62.5%
Final simplification62.5%
(FPCore (x tau) :precision binary32 (fma -0.16666666666666666 (pow (* PI x) 2.0) 1.0))
float code(float x, float tau) {
return fmaf(-0.16666666666666666f, powf((((float) M_PI) * x), 2.0f), 1.0f);
}
function code(x, tau) return fma(Float32(-0.16666666666666666), (Float32(Float32(pi) * x) ^ Float32(2.0)), Float32(1.0)) end
\begin{array}{l}
\\
\mathsf{fma}\left(-0.16666666666666666, {\left(\pi \cdot x\right)}^{2}, 1\right)
\end{array}
Initial program 97.9%
associate-*l/97.7%
*-commutative97.7%
times-frac97.5%
associate-/l/97.4%
associate-*l*97.2%
*-commutative97.2%
associate-*l*97.1%
Simplified97.1%
Taylor expanded in tau around 0 62.4%
Taylor expanded in x around 0 62.5%
+-commutative62.5%
fma-def62.5%
*-commutative62.5%
unpow262.5%
unpow262.5%
swap-sqr62.5%
unpow262.5%
*-commutative62.5%
Simplified62.5%
Final simplification62.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 97.9%
associate-*l/97.7%
*-commutative97.7%
times-frac97.5%
associate-/l/97.4%
associate-*l*97.2%
*-commutative97.2%
associate-*l*97.1%
Simplified97.1%
Taylor expanded in tau around 0 62.4%
Taylor expanded in x around 0 62.5%
+-commutative62.5%
fma-def62.5%
*-commutative62.5%
unpow262.5%
unpow262.5%
swap-sqr62.5%
unpow262.5%
*-commutative62.5%
Simplified62.5%
fma-udef62.5%
*-commutative62.5%
Applied egg-rr62.5%
Final simplification62.5%
(FPCore (x tau) :precision binary32 (/ tau tau))
float code(float x, float tau) {
return tau / tau;
}
real(4) function code(x, tau)
real(4), intent (in) :: x
real(4), intent (in) :: tau
code = tau / tau
end function
function code(x, tau) return Float32(tau / tau) end
function tmp = code(x, tau) tmp = tau / tau; end
\begin{array}{l}
\\
\frac{tau}{tau}
\end{array}
Initial program 97.9%
associate-*l/97.7%
*-commutative97.7%
times-frac97.5%
associate-/l/97.4%
associate-*l*97.2%
*-commutative97.2%
associate-*l*97.1%
Simplified97.1%
*-commutative97.1%
associate-*l/96.9%
associate-*r*97.0%
*-commutative97.0%
associate-*r*96.8%
*-commutative96.8%
associate-*r*96.9%
pow296.9%
*-commutative96.9%
Applied egg-rr96.9%
Taylor expanded in x around 0 61.6%
Final simplification61.6%
herbie shell --seed 2023310
(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))))