
(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 10 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 (* 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 97.8%
*-commutative97.8%
associate-*l*97.5%
associate-*l*97.9%
Simplified97.9%
Final simplification97.9%
(FPCore (x tau) :precision binary32 (* (/ (sin (* x (* PI tau))) tau) (/ (sin (* x PI)) (pow (* x PI) 2.0))))
float code(float x, float tau) {
return (sinf((x * (((float) M_PI) * tau))) / tau) * (sinf((x * ((float) M_PI))) / powf((x * ((float) M_PI)), 2.0f));
}
function code(x, tau) return Float32(Float32(sin(Float32(x * Float32(Float32(pi) * tau))) / tau) * Float32(sin(Float32(x * Float32(pi))) / (Float32(x * Float32(pi)) ^ Float32(2.0)))) end
function tmp = code(x, tau) tmp = (sin((x * (single(pi) * tau))) / tau) * (sin((x * single(pi))) / ((x * single(pi)) ^ single(2.0))); end
\begin{array}{l}
\\
\frac{\sin \left(x \cdot \left(\pi \cdot tau\right)\right)}{tau} \cdot \frac{\sin \left(x \cdot \pi\right)}{{\left(x \cdot \pi\right)}^{2}}
\end{array}
Initial program 97.8%
associate-*l/97.8%
associate-*l*97.4%
*-commutative97.4%
*-commutative97.4%
*-commutative97.4%
*-commutative97.4%
*-commutative97.4%
associate-*l*97.8%
Simplified97.8%
*-commutative97.8%
times-frac97.3%
associate-*r*97.2%
*-commutative97.2%
associate-*l*97.1%
Applied egg-rr97.1%
Taylor expanded in x around inf 96.7%
times-frac96.7%
*-commutative96.7%
*-commutative96.7%
*-commutative96.7%
associate-*r*96.9%
*-commutative96.9%
Simplified96.9%
*-un-lft-identity96.9%
pow-prod-down97.3%
Applied egg-rr97.3%
*-lft-identity97.3%
Simplified97.3%
Final simplification97.3%
(FPCore (x tau) :precision binary32 (/ (/ (sin (* x (* PI tau))) tau) (/ (pow (* x PI) 2.0) (sin (* x PI)))))
float code(float x, float tau) {
return (sinf((x * (((float) M_PI) * tau))) / tau) / (powf((x * ((float) M_PI)), 2.0f) / sinf((x * ((float) M_PI))));
}
function code(x, tau) return Float32(Float32(sin(Float32(x * Float32(Float32(pi) * tau))) / tau) / Float32((Float32(x * Float32(pi)) ^ Float32(2.0)) / sin(Float32(x * Float32(pi))))) end
function tmp = code(x, tau) tmp = (sin((x * (single(pi) * tau))) / tau) / (((x * single(pi)) ^ single(2.0)) / sin((x * single(pi)))); end
\begin{array}{l}
\\
\frac{\frac{\sin \left(x \cdot \left(\pi \cdot tau\right)\right)}{tau}}{\frac{{\left(x \cdot \pi\right)}^{2}}{\sin \left(x \cdot \pi\right)}}
\end{array}
Initial program 97.8%
associate-*l/97.8%
associate-*l*97.4%
*-commutative97.4%
*-commutative97.4%
*-commutative97.4%
*-commutative97.4%
*-commutative97.4%
associate-*l*97.8%
Simplified97.8%
associate-/l*97.8%
associate-/r/97.8%
associate-*r*97.4%
*-commutative97.4%
associate-*l*97.3%
associate-*r*97.4%
*-commutative97.4%
associate-*l*97.7%
Applied egg-rr97.7%
associate-*l/97.8%
associate-*r*97.2%
*-commutative97.2%
times-frac97.2%
associate-/r*97.1%
unpow297.1%
pow-prod-down96.8%
clear-num96.8%
*-commutative96.8%
associate-*r*96.8%
Applied egg-rr97.4%
Final simplification97.4%
(FPCore (x tau) :precision binary32 (let* ((t_1 (* x (* PI tau)))) (* (/ (sin t_1) t_1) (+ 1.0 (* (pow (* x PI) 2.0) -0.16666666666666666)))))
float code(float x, float tau) {
float t_1 = x * (((float) M_PI) * tau);
return (sinf(t_1) / t_1) * (1.0f + (powf((x * ((float) M_PI)), 2.0f) * -0.16666666666666666f));
}
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(x * Float32(pi)) ^ Float32(2.0)) * Float32(-0.16666666666666666)))) end
function tmp = code(x, tau) t_1 = x * (single(pi) * tau); tmp = (sin(t_1) / t_1) * (single(1.0) + (((x * single(pi)) ^ single(2.0)) * single(-0.16666666666666666))); 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 + {\left(x \cdot \pi\right)}^{2} \cdot -0.16666666666666666\right)
\end{array}
\end{array}
Initial program 97.8%
*-commutative97.8%
associate-*l*97.5%
associate-*l*97.9%
Simplified97.9%
Taylor expanded in x around 0 84.2%
unpow262.0%
unpow262.0%
swap-sqr62.0%
unpow262.0%
Simplified84.2%
Final simplification84.2%
(FPCore (x tau) :precision binary32 (* (/ (sin (* x (* PI tau))) tau) (+ (* (* x PI) -0.16666666666666666) (/ 1.0 (* x PI)))))
float code(float x, float tau) {
return (sinf((x * (((float) M_PI) * tau))) / tau) * (((x * ((float) M_PI)) * -0.16666666666666666f) + (1.0f / (x * ((float) M_PI))));
}
function code(x, tau) return Float32(Float32(sin(Float32(x * Float32(Float32(pi) * tau))) / tau) * Float32(Float32(Float32(x * Float32(pi)) * Float32(-0.16666666666666666)) + Float32(Float32(1.0) / Float32(x * Float32(pi))))) end
function tmp = code(x, tau) tmp = (sin((x * (single(pi) * tau))) / tau) * (((x * single(pi)) * single(-0.16666666666666666)) + (single(1.0) / (x * single(pi)))); end
\begin{array}{l}
\\
\frac{\sin \left(x \cdot \left(\pi \cdot tau\right)\right)}{tau} \cdot \left(\left(x \cdot \pi\right) \cdot -0.16666666666666666 + \frac{1}{x \cdot \pi}\right)
\end{array}
Initial program 97.8%
associate-*l/97.8%
associate-*l*97.4%
*-commutative97.4%
*-commutative97.4%
*-commutative97.4%
*-commutative97.4%
*-commutative97.4%
associate-*l*97.8%
Simplified97.8%
*-commutative97.8%
times-frac97.3%
associate-*r*97.2%
*-commutative97.2%
associate-*l*97.1%
Applied egg-rr97.1%
Taylor expanded in x around inf 96.7%
times-frac96.7%
*-commutative96.7%
*-commutative96.7%
*-commutative96.7%
associate-*r*96.9%
*-commutative96.9%
Simplified96.9%
Taylor expanded in x around 0 83.6%
Final simplification83.6%
(FPCore (x tau) :precision binary32 (+ 1.0 (* -0.16666666666666666 (* (* (+ 1.0 (pow tau 2.0)) (pow PI 2.0)) (pow x 2.0)))))
float code(float x, float tau) {
return 1.0f + (-0.16666666666666666f * (((1.0f + powf(tau, 2.0f)) * powf(((float) M_PI), 2.0f)) * powf(x, 2.0f)));
}
function code(x, tau) return Float32(Float32(1.0) + Float32(Float32(-0.16666666666666666) * Float32(Float32(Float32(Float32(1.0) + (tau ^ Float32(2.0))) * (Float32(pi) ^ Float32(2.0))) * (x ^ Float32(2.0))))) end
function tmp = code(x, tau) tmp = single(1.0) + (single(-0.16666666666666666) * (((single(1.0) + (tau ^ single(2.0))) * (single(pi) ^ single(2.0))) * (x ^ single(2.0)))); end
\begin{array}{l}
\\
1 + -0.16666666666666666 \cdot \left(\left(\left(1 + {tau}^{2}\right) \cdot {\pi}^{2}\right) \cdot {x}^{2}\right)
\end{array}
Initial program 97.8%
associate-*l/97.8%
associate-*l*97.4%
*-commutative97.4%
*-commutative97.4%
*-commutative97.4%
*-commutative97.4%
*-commutative97.4%
associate-*l*97.8%
Simplified97.8%
Taylor expanded in x around 0 77.5%
*-commutative77.5%
distribute-lft-out77.5%
associate-*l*77.5%
distribute-lft1-in77.5%
Simplified77.5%
Final simplification77.5%
(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(x * Float32(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 := x \cdot \left(\pi \cdot tau\right)\\
\frac{\sin t_1}{t_1}
\end{array}
\end{array}
Initial program 97.8%
*-commutative97.8%
associate-*l*97.5%
associate-*l*97.9%
Simplified97.9%
expm1-log1p-u97.9%
Applied egg-rr97.9%
Taylor expanded in x around 0 68.8%
Final simplification68.8%
(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(x * Float32(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(x \cdot \left(x \cdot {\pi}^{2}\right)\right)
\end{array}
Initial program 97.8%
associate-*l/97.8%
associate-*l*97.4%
*-commutative97.4%
*-commutative97.4%
*-commutative97.4%
*-commutative97.4%
*-commutative97.4%
associate-*l*97.8%
Simplified97.8%
Taylor expanded in tau around 0 61.8%
Taylor expanded in x around 0 62.0%
unpow262.0%
unpow262.0%
swap-sqr62.0%
unpow262.0%
Simplified62.0%
pow-prod-down62.0%
*-commutative62.0%
unpow262.0%
associate-*r*62.0%
Applied egg-rr62.0%
Final simplification62.0%
(FPCore (x tau) :precision binary32 (+ 1.0 (* (pow (* x PI) 2.0) -0.16666666666666666)))
float code(float x, float tau) {
return 1.0f + (powf((x * ((float) M_PI)), 2.0f) * -0.16666666666666666f);
}
function code(x, tau) return Float32(Float32(1.0) + Float32((Float32(x * Float32(pi)) ^ Float32(2.0)) * Float32(-0.16666666666666666))) end
function tmp = code(x, tau) tmp = single(1.0) + (((x * single(pi)) ^ single(2.0)) * single(-0.16666666666666666)); end
\begin{array}{l}
\\
1 + {\left(x \cdot \pi\right)}^{2} \cdot -0.16666666666666666
\end{array}
Initial program 97.8%
associate-*l/97.8%
associate-*l*97.4%
*-commutative97.4%
*-commutative97.4%
*-commutative97.4%
*-commutative97.4%
*-commutative97.4%
associate-*l*97.8%
Simplified97.8%
Taylor expanded in tau around 0 61.8%
Taylor expanded in x around 0 62.0%
unpow262.0%
unpow262.0%
swap-sqr62.0%
unpow262.0%
Simplified62.0%
Final simplification62.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 97.8%
associate-*l/97.8%
associate-*l*97.4%
*-commutative97.4%
*-commutative97.4%
*-commutative97.4%
*-commutative97.4%
*-commutative97.4%
associate-*l*97.8%
Simplified97.8%
associate-/l*97.8%
associate-/r/97.8%
associate-*r*97.4%
*-commutative97.4%
associate-*l*97.3%
associate-*r*97.4%
*-commutative97.4%
associate-*l*97.7%
Applied egg-rr97.7%
Taylor expanded in x around 0 60.9%
Final simplification60.9%
herbie shell --seed 2023301
(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))))