Lanczos kernel

Percentage Accurate: 100.0% → 100.0%
Time: 1.1s
Alternatives: 1
Speedup: 1.0×

Specification

?
\[\left(10^{-5} \leq x \land x \leq 1\right) \land \left(1 \leq tau \land tau \leq 5\right)\]
\[\begin{array}{l} \\ \begin{array}{l} t_1 := x \cdot \mathsf{PI}\left(\right)\\ t_2 := t\_1 \cdot tau\\ \frac{\sin t\_2}{t\_2} \cdot \frac{\sin t\_1}{t\_1} \end{array} \end{array} \]
(FPCore (x tau)
 :precision binary32
 (let* ((t_1 (* x (PI))) (t_2 (* t_1 tau)))
   (* (/ (sin t_2) t_2) (/ (sin t_1) t_1))))
\begin{array}{l}

\\
\begin{array}{l}
t_1 := x \cdot \mathsf{PI}\left(\right)\\
t_2 := t\_1 \cdot tau\\
\frac{\sin t\_2}{t\_2} \cdot \frac{\sin t\_1}{t\_1}
\end{array}
\end{array}

Sampling outcomes in binary32 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 1 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 100.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x \cdot \mathsf{PI}\left(\right)\\ t_2 := t\_1 \cdot tau\\ \frac{\sin t\_2}{t\_2} \cdot \frac{\sin t\_1}{t\_1} \end{array} \end{array} \]
(FPCore (x tau)
 :precision binary32
 (let* ((t_1 (* x (PI))) (t_2 (* t_1 tau)))
   (* (/ (sin t_2) t_2) (/ (sin t_1) t_1))))
\begin{array}{l}

\\
\begin{array}{l}
t_1 := x \cdot \mathsf{PI}\left(\right)\\
t_2 := t\_1 \cdot tau\\
\frac{\sin t\_2}{t\_2} \cdot \frac{\sin t\_1}{t\_1}
\end{array}
\end{array}

Alternative 1: 100.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \mathsf{PI}\left(\right) \cdot x\\ t_2 := tau \cdot t\_1\\ \frac{\sin t\_1}{t\_1} \cdot \frac{\sin t\_2}{t\_2} \end{array} \end{array} \]
(FPCore (x tau)
 :precision binary32
 (let* ((t_1 (* (PI) x)) (t_2 (* tau t_1)))
   (* (/ (sin t_1) t_1) (/ (sin t_2) t_2))))
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \mathsf{PI}\left(\right) \cdot x\\
t_2 := tau \cdot t\_1\\
\frac{\sin t\_1}{t\_1} \cdot \frac{\sin t\_2}{t\_2}
\end{array}
\end{array}
Derivation
  1. Initial program 97.7%

    \[\frac{\sin \left(\left(x \cdot \mathsf{PI}\left(\right)\right) \cdot tau\right)}{\left(x \cdot \mathsf{PI}\left(\right)\right) \cdot tau} \cdot \frac{\sin \left(x \cdot \mathsf{PI}\left(\right)\right)}{x \cdot \mathsf{PI}\left(\right)} \]
  2. Add Preprocessing
  3. Final simplification97.7%

    \[\leadsto \frac{\sin \left(\mathsf{PI}\left(\right) \cdot x\right)}{\mathsf{PI}\left(\right) \cdot x} \cdot \frac{\sin \left(tau \cdot \left(\mathsf{PI}\left(\right) \cdot x\right)\right)}{tau \cdot \left(\mathsf{PI}\left(\right) \cdot x\right)} \]
  4. Add Preprocessing

Reproduce

?
herbie shell --seed 2024346 
(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)))))