
(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 (* (* 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 98.1%
Final simplification98.1%
(FPCore (x tau) :precision binary32 (let* ((t_1 (* x (* PI tau)))) (* (/ (sin t_1) (* x PI)) (/ (sin (* x PI)) t_1))))
float code(float x, float tau) {
float t_1 = x * (((float) M_PI) * tau);
return (sinf(t_1) / (x * ((float) M_PI))) * (sinf((x * ((float) M_PI))) / t_1);
}
function code(x, tau) t_1 = Float32(x * Float32(Float32(pi) * tau)) return Float32(Float32(sin(t_1) / Float32(x * Float32(pi))) * Float32(sin(Float32(x * Float32(pi))) / t_1)) end
function tmp = code(x, tau) t_1 = x * (single(pi) * tau); tmp = (sin(t_1) / (x * single(pi))) * (sin((x * single(pi))) / t_1); end
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot \left(\pi \cdot tau\right)\\
\frac{\sin t_1}{x \cdot \pi} \cdot \frac{\sin \left(x \cdot \pi\right)}{t_1}
\end{array}
\end{array}
Initial program 98.1%
associate-*l/98.0%
times-frac97.5%
associate-*l*97.3%
associate-/l/97.2%
*-commutative97.2%
associate-*l*97.7%
Simplified97.7%
Final simplification97.7%
(FPCore (x tau) :precision binary32 (let* ((t_1 (* x (* PI tau)))) (* (/ (sin (* x PI)) (* x PI)) (/ (sin t_1) t_1))))
float code(float x, float tau) {
float t_1 = x * (((float) M_PI) * tau);
return (sinf((x * ((float) M_PI))) / (x * ((float) M_PI))) * (sinf(t_1) / t_1);
}
function code(x, tau) t_1 = Float32(x * Float32(Float32(pi) * tau)) return Float32(Float32(sin(Float32(x * Float32(pi))) / Float32(x * Float32(pi))) * Float32(sin(t_1) / t_1)) end
function tmp = code(x, tau) t_1 = x * (single(pi) * tau); tmp = (sin((x * single(pi))) / (x * single(pi))) * (sin(t_1) / t_1); end
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot \left(\pi \cdot tau\right)\\
\frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi} \cdot \frac{\sin t_1}{t_1}
\end{array}
\end{array}
Initial program 98.1%
associate-*l*97.4%
associate-*l*97.9%
Simplified97.9%
Final simplification97.9%
(FPCore (x tau) :precision binary32 (let* ((t_1 (* PI (* x tau)))) (* (/ (sin (* x PI)) (* x PI)) (/ (sin t_1) t_1))))
float code(float x, float tau) {
float t_1 = ((float) M_PI) * (x * tau);
return (sinf((x * ((float) M_PI))) / (x * ((float) M_PI))) * (sinf(t_1) / t_1);
}
function code(x, tau) t_1 = Float32(Float32(pi) * Float32(x * tau)) return Float32(Float32(sin(Float32(x * Float32(pi))) / Float32(x * Float32(pi))) * Float32(sin(t_1) / t_1)) end
function tmp = code(x, tau) t_1 = single(pi) * (x * tau); tmp = (sin((x * single(pi))) / (x * single(pi))) * (sin(t_1) / t_1); end
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \pi \cdot \left(x \cdot tau\right)\\
\frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi} \cdot \frac{\sin t_1}{t_1}
\end{array}
\end{array}
Initial program 98.1%
*-commutative98.1%
associate-*l*97.4%
*-commutative97.4%
associate-*l*98.0%
Simplified98.0%
Final simplification98.0%
(FPCore (x tau) :precision binary32 (* (sin (* x (* PI tau))) (* (pow (* x PI) -2.0) (/ (sin (* x PI)) tau))))
float code(float x, float tau) {
return sinf((x * (((float) M_PI) * tau))) * (powf((x * ((float) M_PI)), -2.0f) * (sinf((x * ((float) M_PI))) / tau));
}
function code(x, tau) return Float32(sin(Float32(x * Float32(Float32(pi) * tau))) * Float32((Float32(x * Float32(pi)) ^ Float32(-2.0)) * Float32(sin(Float32(x * Float32(pi))) / tau))) end
function tmp = code(x, tau) tmp = sin((x * (single(pi) * tau))) * (((x * single(pi)) ^ single(-2.0)) * (sin((x * single(pi))) / tau)); end
\begin{array}{l}
\\
\sin \left(x \cdot \left(\pi \cdot tau\right)\right) \cdot \left({\left(x \cdot \pi\right)}^{-2} \cdot \frac{\sin \left(x \cdot \pi\right)}{tau}\right)
\end{array}
Initial program 98.1%
associate-*l/98.0%
times-frac97.5%
associate-*l*97.3%
associate-/l/97.2%
*-commutative97.2%
associate-*l*97.7%
Simplified97.7%
frac-times97.8%
associate-/l*97.9%
associate-*r*97.4%
associate-*r*97.4%
pow297.4%
Applied egg-rr97.4%
expm1-log1p-u97.2%
Applied egg-rr97.2%
div-inv97.1%
clear-num97.1%
*-un-lft-identity97.1%
times-frac96.8%
metadata-eval96.8%
expm1-log1p-u97.0%
unpow297.0%
frac-times96.8%
inv-pow96.8%
inv-pow96.8%
pow-prod-up97.3%
metadata-eval97.3%
Applied egg-rr97.3%
Final simplification97.3%
(FPCore (x tau) :precision binary32 (* (sin (* x PI)) (/ (sin (* (* x PI) tau)) (* tau (pow (* x PI) 2.0)))))
float code(float x, float tau) {
return sinf((x * ((float) M_PI))) * (sinf(((x * ((float) M_PI)) * tau)) / (tau * powf((x * ((float) M_PI)), 2.0f)));
}
function code(x, tau) return Float32(sin(Float32(x * Float32(pi))) * Float32(sin(Float32(Float32(x * Float32(pi)) * tau)) / Float32(tau * (Float32(x * Float32(pi)) ^ Float32(2.0))))) end
function tmp = code(x, tau) tmp = sin((x * single(pi))) * (sin(((x * single(pi)) * tau)) / (tau * ((x * single(pi)) ^ single(2.0)))); end
\begin{array}{l}
\\
\sin \left(x \cdot \pi\right) \cdot \frac{\sin \left(\left(x \cdot \pi\right) \cdot tau\right)}{tau \cdot {\left(x \cdot \pi\right)}^{2}}
\end{array}
Initial program 98.1%
associate-*l/98.0%
times-frac97.5%
associate-*l*97.3%
associate-/l/97.2%
*-commutative97.2%
associate-*l*97.7%
Simplified97.7%
frac-times97.8%
associate-/l*97.9%
associate-*r*97.4%
associate-*r*97.4%
pow297.4%
Applied egg-rr97.4%
Taylor expanded in x around inf 96.9%
times-frac97.0%
*-commutative97.0%
*-commutative97.0%
unpow297.0%
unpow297.0%
swap-sqr97.5%
unpow297.5%
associate-*r/97.7%
associate-*l/97.6%
Simplified97.6%
Final simplification97.6%
(FPCore (x tau) :precision binary32 (let* ((t_1 (* x (* PI tau)))) (* (/ (sin t_1) t_1) (+ 1.0 (* -0.16666666666666666 (pow (* x 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 * powf((x * ((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(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 * 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(x \cdot \pi\right)}^{2}\right)
\end{array}
\end{array}
Initial program 98.1%
associate-*l*97.4%
associate-*l*97.9%
Simplified97.9%
Taylor expanded in x around 0 84.8%
associate-*r*84.8%
unpow284.8%
Simplified84.8%
Taylor expanded in x around 0 84.8%
unpow284.8%
unpow284.8%
swap-sqr84.8%
unpow284.8%
Simplified84.8%
Final simplification84.8%
(FPCore (x tau) :precision binary32 (* (sin (* x PI)) (+ (/ 1.0 (* x PI)) (* -0.16666666666666666 (* (* x PI) (pow tau 2.0))))))
float code(float x, float tau) {
return sinf((x * ((float) M_PI))) * ((1.0f / (x * ((float) M_PI))) + (-0.16666666666666666f * ((x * ((float) M_PI)) * powf(tau, 2.0f))));
}
function code(x, tau) return Float32(sin(Float32(x * Float32(pi))) * Float32(Float32(Float32(1.0) / Float32(x * Float32(pi))) + Float32(Float32(-0.16666666666666666) * Float32(Float32(x * Float32(pi)) * (tau ^ Float32(2.0)))))) end
function tmp = code(x, tau) tmp = sin((x * single(pi))) * ((single(1.0) / (x * single(pi))) + (single(-0.16666666666666666) * ((x * single(pi)) * (tau ^ single(2.0))))); end
\begin{array}{l}
\\
\sin \left(x \cdot \pi\right) \cdot \left(\frac{1}{x \cdot \pi} + -0.16666666666666666 \cdot \left(\left(x \cdot \pi\right) \cdot {tau}^{2}\right)\right)
\end{array}
Initial program 98.1%
associate-*l/98.0%
times-frac97.5%
associate-*l*97.3%
associate-/l/97.2%
*-commutative97.2%
associate-*l*97.7%
Simplified97.7%
frac-times97.8%
associate-/l*97.9%
associate-*r*97.4%
associate-*r*97.4%
pow297.4%
Applied egg-rr97.4%
Taylor expanded in x around inf 96.9%
times-frac97.0%
*-commutative97.0%
*-commutative97.0%
unpow297.0%
unpow297.0%
swap-sqr97.5%
unpow297.5%
associate-*r/97.7%
associate-*l/97.6%
Simplified97.6%
Taylor expanded in tau around 0 78.3%
Final simplification78.3%
(FPCore (x tau) :precision binary32 (* (sin (* x PI)) (fma -0.16666666666666666 (* (* x PI) (* tau tau)) (/ 1.0 (* x PI)))))
float code(float x, float tau) {
return sinf((x * ((float) M_PI))) * fmaf(-0.16666666666666666f, ((x * ((float) M_PI)) * (tau * tau)), (1.0f / (x * ((float) M_PI))));
}
function code(x, tau) return Float32(sin(Float32(x * Float32(pi))) * fma(Float32(-0.16666666666666666), Float32(Float32(x * Float32(pi)) * Float32(tau * tau)), Float32(Float32(1.0) / Float32(x * Float32(pi))))) end
\begin{array}{l}
\\
\sin \left(x \cdot \pi\right) \cdot \mathsf{fma}\left(-0.16666666666666666, \left(x \cdot \pi\right) \cdot \left(tau \cdot tau\right), \frac{1}{x \cdot \pi}\right)
\end{array}
Initial program 98.1%
associate-*l/98.0%
times-frac97.5%
associate-*l*97.3%
associate-/l/97.2%
*-commutative97.2%
associate-*l*97.7%
Simplified97.7%
frac-times97.8%
associate-/l*97.9%
associate-*r*97.4%
associate-*r*97.4%
pow297.4%
Applied egg-rr97.4%
Taylor expanded in x around inf 96.9%
times-frac97.0%
*-commutative97.0%
*-commutative97.0%
unpow297.0%
unpow297.0%
swap-sqr97.5%
unpow297.5%
associate-*r/97.7%
associate-*l/97.6%
Simplified97.6%
Taylor expanded in tau around 0 78.3%
+-commutative78.3%
*-commutative78.3%
fma-def78.3%
unpow278.3%
Simplified78.3%
Final simplification78.3%
(FPCore (x tau) :precision binary32 (fma (* -0.16666666666666666 (* (+ 1.0 (* tau tau)) (pow PI 2.0))) (* x x) 1.0))
float code(float x, float tau) {
return fmaf((-0.16666666666666666f * ((1.0f + (tau * tau)) * powf(((float) M_PI), 2.0f))), (x * x), 1.0f);
}
function code(x, tau) return fma(Float32(Float32(-0.16666666666666666) * Float32(Float32(Float32(1.0) + Float32(tau * tau)) * (Float32(pi) ^ Float32(2.0)))), Float32(x * x), Float32(1.0)) end
\begin{array}{l}
\\
\mathsf{fma}\left(-0.16666666666666666 \cdot \left(\left(1 + tau \cdot tau\right) \cdot {\pi}^{2}\right), x \cdot x, 1\right)
\end{array}
Initial program 98.1%
associate-*l/98.0%
times-frac97.5%
associate-*l*97.3%
associate-/l/97.2%
*-commutative97.2%
associate-*l*97.7%
Simplified97.7%
Taylor expanded in x around 0 77.7%
+-commutative77.7%
fma-def77.7%
distribute-lft-out77.7%
distribute-rgt1-in77.7%
unpow277.7%
unpow277.7%
Simplified77.7%
Final simplification77.7%
(FPCore (x tau) :precision binary32 (let* ((t_1 (* (* x PI) tau))) (/ (sin t_1) t_1)))
float code(float x, float tau) {
float t_1 = (x * ((float) M_PI)) * tau;
return sinf(t_1) / t_1;
}
function code(x, tau) t_1 = Float32(Float32(x * Float32(pi)) * tau) return Float32(sin(t_1) / t_1) end
function tmp = code(x, tau) t_1 = (x * single(pi)) * tau; tmp = sin(t_1) / t_1; end
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(x \cdot \pi\right) \cdot tau\\
\frac{\sin t_1}{t_1}
\end{array}
\end{array}
Initial program 98.1%
associate-*l/98.0%
times-frac97.5%
associate-*l*97.3%
associate-/l/97.2%
*-commutative97.2%
associate-*l*97.7%
Simplified97.7%
*-commutative97.7%
clear-num97.5%
associate-/r*97.2%
frac-times97.4%
*-un-lft-identity97.4%
associate-/l*97.3%
Applied egg-rr97.3%
Taylor expanded in x around 0 70.3%
Taylor expanded in x around -inf 70.5%
Final simplification70.5%
(FPCore (x tau) :precision binary32 (fma -0.16666666666666666 (pow (* x (* PI tau)) 2.0) 1.0))
float code(float x, float tau) {
return fmaf(-0.16666666666666666f, powf((x * (((float) M_PI) * tau)), 2.0f), 1.0f);
}
function code(x, tau) return fma(Float32(-0.16666666666666666), (Float32(x * Float32(Float32(pi) * tau)) ^ Float32(2.0)), Float32(1.0)) end
\begin{array}{l}
\\
\mathsf{fma}\left(-0.16666666666666666, {\left(x \cdot \left(\pi \cdot tau\right)\right)}^{2}, 1\right)
\end{array}
Initial program 98.1%
associate-*l/98.0%
times-frac97.5%
associate-*l*97.3%
associate-/l/97.2%
*-commutative97.2%
associate-*l*97.7%
Simplified97.7%
*-commutative97.7%
clear-num97.5%
associate-/r*97.2%
frac-times97.4%
*-un-lft-identity97.4%
associate-/l*97.3%
Applied egg-rr97.3%
Taylor expanded in x around 0 70.3%
Taylor expanded in x around 0 69.0%
+-commutative69.0%
unpow269.0%
*-commutative69.0%
unpow269.0%
fma-def69.0%
Simplified69.0%
Final simplification69.0%
(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 98.1%
associate-*l/98.0%
times-frac97.5%
associate-*l*97.3%
associate-/l/97.2%
*-commutative97.2%
associate-*l*97.7%
Simplified97.7%
Taylor expanded in tau around 0 64.1%
*-commutative64.1%
Simplified64.1%
Final simplification64.1%
(FPCore (x tau) :precision binary32 (* tau (+ (/ 1.0 tau) (* -0.16666666666666666 (/ (pow PI 2.0) (/ tau (* x x)))))))
float code(float x, float tau) {
return tau * ((1.0f / tau) + (-0.16666666666666666f * (powf(((float) M_PI), 2.0f) / (tau / (x * x)))));
}
function code(x, tau) return Float32(tau * Float32(Float32(Float32(1.0) / tau) + Float32(Float32(-0.16666666666666666) * Float32((Float32(pi) ^ Float32(2.0)) / Float32(tau / Float32(x * x)))))) end
function tmp = code(x, tau) tmp = tau * ((single(1.0) / tau) + (single(-0.16666666666666666) * ((single(pi) ^ single(2.0)) / (tau / (x * x))))); end
\begin{array}{l}
\\
tau \cdot \left(\frac{1}{tau} + -0.16666666666666666 \cdot \frac{{\pi}^{2}}{\frac{tau}{x \cdot x}}\right)
\end{array}
Initial program 98.1%
associate-*l/98.0%
times-frac97.5%
associate-*l*97.3%
associate-/l/97.2%
*-commutative97.2%
associate-*l*97.7%
Simplified97.7%
Taylor expanded in x around 0 63.9%
Taylor expanded in x around 0 64.0%
associate-/l*64.0%
unpow264.0%
Simplified64.0%
Final simplification64.0%
(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.0%
times-frac97.5%
associate-*l*97.3%
associate-/l/97.2%
*-commutative97.2%
associate-*l*97.7%
Simplified97.7%
Taylor expanded in x around 0 63.3%
Final simplification63.3%
herbie shell --seed 2023274
(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))))