
(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 8 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 97.8%
Final simplification97.8%
(FPCore (x tau) :precision binary32 (let* ((t_1 (* x (* PI tau)))) (* (sin (* x PI)) (/ (/ (sin t_1) t_1) (* x PI)))))
float code(float x, float tau) {
float t_1 = x * (((float) M_PI) * tau);
return sinf((x * ((float) M_PI))) * ((sinf(t_1) / t_1) / (x * ((float) M_PI)));
}
function code(x, tau) t_1 = Float32(x * Float32(Float32(pi) * tau)) return Float32(sin(Float32(x * Float32(pi))) * Float32(Float32(sin(t_1) / t_1) / Float32(x * Float32(pi)))) end
function tmp = code(x, tau) t_1 = x * (single(pi) * tau); tmp = sin((x * single(pi))) * ((sin(t_1) / t_1) / (x * single(pi))); end
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot \left(\pi \cdot tau\right)\\
\sin \left(x \cdot \pi\right) \cdot \frac{\frac{\sin t\_1}{t\_1}}{x \cdot \pi}
\end{array}
\end{array}
Initial program 97.8%
associate-*l/97.8%
associate-/l*97.7%
associate-*l*97.1%
associate-/l/97.2%
*-commutative97.2%
*-commutative97.2%
associate-*l*97.0%
associate-*l*97.1%
Simplified97.1%
associate-*r*97.0%
associate-*r*97.2%
*-commutative97.2%
*-commutative97.2%
associate-*r*97.0%
*-commutative97.0%
associate-*r*97.1%
*-commutative97.1%
associate-*r/97.2%
Applied egg-rr97.7%
div-inv97.6%
associate-/l*97.5%
associate-*l*97.5%
Applied egg-rr97.5%
associate-*l/97.6%
associate-*r/97.8%
*-rgt-identity97.8%
associate-/r*97.7%
associate-/l/97.3%
associate-/r*97.2%
remove-double-neg97.2%
distribute-neg-frac297.2%
distribute-frac-neg97.2%
Simplified97.8%
Final simplification97.8%
(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 97.8%
*-commutative97.8%
associate-*l*97.4%
*-commutative97.4%
associate-*l*97.8%
Simplified97.8%
Final simplification97.8%
(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 97.8%
associate-*l/97.8%
associate-/l*97.7%
associate-*l*97.1%
associate-/l/97.2%
*-commutative97.2%
*-commutative97.2%
associate-*l*97.0%
associate-*l*97.1%
Simplified97.1%
associate-*r*97.0%
associate-*r*97.2%
*-commutative97.2%
*-commutative97.2%
associate-*r*97.0%
*-commutative97.0%
associate-*r*97.1%
*-commutative97.1%
associate-*r/97.2%
Applied egg-rr97.4%
Taylor expanded in x around 0 69.7%
Taylor expanded in x around inf 69.7%
Final simplification69.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(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%
associate-*l/97.8%
associate-/l*97.7%
associate-*l*97.1%
associate-/l/97.2%
*-commutative97.2%
*-commutative97.2%
associate-*l*97.0%
associate-*l*97.1%
Simplified97.1%
associate-*r*97.0%
associate-*r*97.2%
*-commutative97.2%
*-commutative97.2%
associate-*r*97.0%
*-commutative97.0%
associate-*r*97.1%
*-commutative97.1%
associate-*r/97.2%
Applied egg-rr97.4%
Taylor expanded in x around 0 69.7%
Taylor expanded in x around inf 69.7%
*-commutative69.7%
associate-*r*69.5%
*-commutative69.5%
*-commutative69.5%
associate-*r*69.7%
*-commutative69.7%
Simplified69.7%
Final simplification69.7%
(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 97.8%
associate-*l/97.8%
associate-/l*97.7%
associate-*l*97.1%
associate-/l/97.2%
*-commutative97.2%
*-commutative97.2%
associate-*l*97.0%
associate-*l*97.1%
Simplified97.1%
Taylor expanded in tau around 0 63.1%
Final simplification63.1%
(FPCore (x tau) :precision binary32 (* x (/ 1.0 x)))
float code(float x, float tau) {
return x * (1.0f / x);
}
real(4) function code(x, tau)
real(4), intent (in) :: x
real(4), intent (in) :: tau
code = x * (1.0e0 / x)
end function
function code(x, tau) return Float32(x * Float32(Float32(1.0) / x)) end
function tmp = code(x, tau) tmp = x * (single(1.0) / x); end
\begin{array}{l}
\\
x \cdot \frac{1}{x}
\end{array}
Initial program 97.8%
associate-*l/97.8%
associate-/l*97.7%
associate-*l*97.1%
associate-/l/97.2%
*-commutative97.2%
*-commutative97.2%
associate-*l*97.0%
associate-*l*97.1%
Simplified97.1%
associate-*r*97.0%
associate-*r*97.2%
*-commutative97.2%
*-commutative97.2%
associate-*r*97.0%
*-commutative97.0%
associate-*r*97.1%
*-commutative97.1%
associate-*r/97.2%
Applied egg-rr97.7%
*-un-lft-identity97.7%
times-frac97.3%
*-commutative97.3%
times-frac97.0%
Applied egg-rr97.0%
times-frac96.9%
associate-/r*97.1%
*-commutative97.1%
associate-/l/97.3%
Simplified97.3%
Taylor expanded in x around 0 62.3%
Final simplification62.3%
(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.7%
associate-*l*97.1%
associate-/l/97.2%
*-commutative97.2%
*-commutative97.2%
associate-*l*97.0%
associate-*l*97.1%
Simplified97.1%
Taylor expanded in tau around 0 63.1%
Taylor expanded in x around 0 62.3%
Final simplification62.3%
herbie shell --seed 2024071
(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))))