Lanczos kernel

Percentage Accurate: 97.9% → 97.9%
Time: 14.1s
Alternatives: 8
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 := \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}

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 8 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: 97.9% accurate, 1.0× speedup?

\[\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}

Alternative 1: 97.9% accurate, 1.0× speedup?

\[\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} \]
(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}
Derivation
  1. Initial program 98.3%

    \[\frac{\sin \left(\left(x \cdot \pi\right) \cdot tau\right)}{\left(x \cdot \pi\right) \cdot tau} \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi} \]
  2. Step-by-step derivation
    1. *-commutative98.3%

      \[\leadsto \frac{\sin \left(\left(x \cdot \pi\right) \cdot tau\right)}{\color{blue}{\left(\pi \cdot x\right)} \cdot tau} \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi} \]
    2. associate-*l*97.7%

      \[\leadsto \frac{\sin \left(\left(x \cdot \pi\right) \cdot tau\right)}{\color{blue}{\pi \cdot \left(x \cdot tau\right)}} \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi} \]
    3. *-commutative97.7%

      \[\leadsto \frac{\sin \left(\color{blue}{\left(\pi \cdot x\right)} \cdot tau\right)}{\pi \cdot \left(x \cdot tau\right)} \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi} \]
    4. associate-*l*98.4%

      \[\leadsto \frac{\sin \color{blue}{\left(\pi \cdot \left(x \cdot tau\right)\right)}}{\pi \cdot \left(x \cdot tau\right)} \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi} \]
  3. Simplified98.4%

    \[\leadsto \color{blue}{\frac{\sin \left(\pi \cdot \left(x \cdot tau\right)\right)}{\pi \cdot \left(x \cdot tau\right)} \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi}} \]
  4. Add Preprocessing
  5. Final simplification98.4%

    \[\leadsto \frac{\sin \left(\pi \cdot \left(x \cdot tau\right)\right)}{\pi \cdot \left(x \cdot tau\right)} \cdot \frac{\sin \left(\pi \cdot x\right)}{\pi \cdot x} \]
  6. Add Preprocessing

Alternative 2: 97.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{\sin \left(\pi \cdot x\right)}{\pi \cdot x} \cdot \frac{\sin \left(tau \cdot \left(\pi \cdot x\right)\right)}{x \cdot \left(\pi \cdot tau\right)} \end{array} \]
(FPCore (x tau)
 :precision binary32
 (* (/ (sin (* PI x)) (* PI x)) (/ (sin (* tau (* PI x))) (* x (* PI tau)))))
float code(float x, float tau) {
	return (sinf((((float) M_PI) * x)) / (((float) M_PI) * x)) * (sinf((tau * (((float) M_PI) * x))) / (x * (((float) M_PI) * tau)));
}
function code(x, tau)
	return Float32(Float32(sin(Float32(Float32(pi) * x)) / Float32(Float32(pi) * x)) * Float32(sin(Float32(tau * Float32(Float32(pi) * x))) / Float32(x * Float32(Float32(pi) * tau))))
end
function tmp = code(x, tau)
	tmp = (sin((single(pi) * x)) / (single(pi) * x)) * (sin((tau * (single(pi) * x))) / (x * (single(pi) * tau)));
end
\begin{array}{l}

\\
\frac{\sin \left(\pi \cdot x\right)}{\pi \cdot x} \cdot \frac{\sin \left(tau \cdot \left(\pi \cdot x\right)\right)}{x \cdot \left(\pi \cdot tau\right)}
\end{array}
Derivation
  1. Initial program 98.3%

    \[\frac{\sin \left(\left(x \cdot \pi\right) \cdot tau\right)}{\left(x \cdot \pi\right) \cdot tau} \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi} \]
  2. Step-by-step derivation
    1. associate-*l*97.4%

      \[\leadsto \frac{\sin \color{blue}{\left(x \cdot \left(\pi \cdot tau\right)\right)}}{\left(x \cdot \pi\right) \cdot tau} \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi} \]
    2. associate-*l*98.3%

      \[\leadsto \frac{\sin \left(x \cdot \left(\pi \cdot tau\right)\right)}{\color{blue}{x \cdot \left(\pi \cdot tau\right)}} \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi} \]
  3. Simplified98.3%

    \[\leadsto \color{blue}{\frac{\sin \left(x \cdot \left(\pi \cdot tau\right)\right)}{x \cdot \left(\pi \cdot tau\right)} \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi}} \]
  4. Add Preprocessing
  5. Taylor expanded in x around inf 97.6%

    \[\leadsto \frac{\color{blue}{\sin \left(tau \cdot \left(x \cdot \pi\right)\right)}}{x \cdot \left(\pi \cdot tau\right)} \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi} \]
  6. Final simplification97.6%

    \[\leadsto \frac{\sin \left(\pi \cdot x\right)}{\pi \cdot x} \cdot \frac{\sin \left(tau \cdot \left(\pi \cdot x\right)\right)}{x \cdot \left(\pi \cdot tau\right)} \]
  7. Add Preprocessing

Alternative 3: 97.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x \cdot \left(\pi \cdot tau\right)\\ \frac{\sin \left(\pi \cdot x\right)}{\pi \cdot x} \cdot \frac{\sin t_1}{t_1} \end{array} \end{array} \]
(FPCore (x tau)
 :precision binary32
 (let* ((t_1 (* x (* PI tau))))
   (* (/ (sin (* PI x)) (* PI x)) (/ (sin t_1) t_1))))
float code(float x, float tau) {
	float t_1 = x * (((float) M_PI) * tau);
	return (sinf((((float) M_PI) * x)) / (((float) M_PI) * x)) * (sinf(t_1) / t_1);
}
function code(x, tau)
	t_1 = Float32(x * Float32(Float32(pi) * tau))
	return Float32(Float32(sin(Float32(Float32(pi) * x)) / Float32(Float32(pi) * x)) * Float32(sin(t_1) / t_1))
end
function tmp = code(x, tau)
	t_1 = x * (single(pi) * tau);
	tmp = (sin((single(pi) * x)) / (single(pi) * x)) * (sin(t_1) / t_1);
end
\begin{array}{l}

\\
\begin{array}{l}
t_1 := x \cdot \left(\pi \cdot tau\right)\\
\frac{\sin \left(\pi \cdot x\right)}{\pi \cdot x} \cdot \frac{\sin t_1}{t_1}
\end{array}
\end{array}
Derivation
  1. Initial program 98.3%

    \[\frac{\sin \left(\left(x \cdot \pi\right) \cdot tau\right)}{\left(x \cdot \pi\right) \cdot tau} \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi} \]
  2. Step-by-step derivation
    1. associate-*l*97.4%

      \[\leadsto \frac{\sin \color{blue}{\left(x \cdot \left(\pi \cdot tau\right)\right)}}{\left(x \cdot \pi\right) \cdot tau} \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi} \]
    2. associate-*l*98.3%

      \[\leadsto \frac{\sin \left(x \cdot \left(\pi \cdot tau\right)\right)}{\color{blue}{x \cdot \left(\pi \cdot tau\right)}} \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi} \]
  3. Simplified98.3%

    \[\leadsto \color{blue}{\frac{\sin \left(x \cdot \left(\pi \cdot tau\right)\right)}{x \cdot \left(\pi \cdot tau\right)} \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi}} \]
  4. Add Preprocessing
  5. Final simplification98.3%

    \[\leadsto \frac{\sin \left(\pi \cdot x\right)}{\pi \cdot x} \cdot \frac{\sin \left(x \cdot \left(\pi \cdot tau\right)\right)}{x \cdot \left(\pi \cdot tau\right)} \]
  6. Add Preprocessing

Alternative 4: 70.8% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \frac{\sin \left(tau \cdot \left(\pi \cdot x\right)\right)}{x \cdot \left(\pi \cdot tau\right)} \end{array} \]
(FPCore (x tau)
 :precision binary32
 (/ (sin (* tau (* PI x))) (* x (* PI tau))))
float code(float x, float tau) {
	return sinf((tau * (((float) M_PI) * x))) / (x * (((float) M_PI) * tau));
}
function code(x, tau)
	return Float32(sin(Float32(tau * Float32(Float32(pi) * x))) / Float32(x * Float32(Float32(pi) * tau)))
end
function tmp = code(x, tau)
	tmp = sin((tau * (single(pi) * x))) / (x * (single(pi) * tau));
end
\begin{array}{l}

\\
\frac{\sin \left(tau \cdot \left(\pi \cdot x\right)\right)}{x \cdot \left(\pi \cdot tau\right)}
\end{array}
Derivation
  1. Initial program 98.3%

    \[\frac{\sin \left(\left(x \cdot \pi\right) \cdot tau\right)}{\left(x \cdot \pi\right) \cdot tau} \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi} \]
  2. Step-by-step derivation
    1. associate-*l*97.4%

      \[\leadsto \frac{\sin \color{blue}{\left(x \cdot \left(\pi \cdot tau\right)\right)}}{\left(x \cdot \pi\right) \cdot tau} \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi} \]
    2. associate-*l*98.3%

      \[\leadsto \frac{\sin \left(x \cdot \left(\pi \cdot tau\right)\right)}{\color{blue}{x \cdot \left(\pi \cdot tau\right)}} \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi} \]
  3. Simplified98.3%

    \[\leadsto \color{blue}{\frac{\sin \left(x \cdot \left(\pi \cdot tau\right)\right)}{x \cdot \left(\pi \cdot tau\right)} \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi}} \]
  4. Add Preprocessing
  5. Taylor expanded in x around 0 72.7%

    \[\leadsto \frac{\sin \left(x \cdot \left(\pi \cdot tau\right)\right)}{x \cdot \left(\pi \cdot tau\right)} \cdot \color{blue}{1} \]
  6. Taylor expanded in x around inf 72.3%

    \[\leadsto \frac{\color{blue}{\sin \left(tau \cdot \left(x \cdot \pi\right)\right)}}{x \cdot \left(\pi \cdot tau\right)} \cdot 1 \]
  7. Final simplification72.3%

    \[\leadsto \frac{\sin \left(tau \cdot \left(\pi \cdot x\right)\right)}{x \cdot \left(\pi \cdot tau\right)} \]
  8. Add Preprocessing

Alternative 5: 71.0% accurate, 2.0× speedup?

\[\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} \]
(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}
Derivation
  1. Initial program 98.3%

    \[\frac{\sin \left(\left(x \cdot \pi\right) \cdot tau\right)}{\left(x \cdot \pi\right) \cdot tau} \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi} \]
  2. Step-by-step derivation
    1. associate-*l*97.4%

      \[\leadsto \frac{\sin \color{blue}{\left(x \cdot \left(\pi \cdot tau\right)\right)}}{\left(x \cdot \pi\right) \cdot tau} \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi} \]
    2. associate-*l*98.3%

      \[\leadsto \frac{\sin \left(x \cdot \left(\pi \cdot tau\right)\right)}{\color{blue}{x \cdot \left(\pi \cdot tau\right)}} \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi} \]
  3. Simplified98.3%

    \[\leadsto \color{blue}{\frac{\sin \left(x \cdot \left(\pi \cdot tau\right)\right)}{x \cdot \left(\pi \cdot tau\right)} \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi}} \]
  4. Add Preprocessing
  5. Taylor expanded in x around 0 72.7%

    \[\leadsto \frac{\sin \left(x \cdot \left(\pi \cdot tau\right)\right)}{x \cdot \left(\pi \cdot tau\right)} \cdot \color{blue}{1} \]
  6. Final simplification72.7%

    \[\leadsto \frac{\sin \left(x \cdot \left(\pi \cdot tau\right)\right)}{x \cdot \left(\pi \cdot tau\right)} \]
  7. Add Preprocessing

Alternative 6: 64.4% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \frac{\sin \left(\pi \cdot x\right)}{\pi \cdot x} \end{array} \]
(FPCore (x tau) :precision binary32 (/ (sin (* PI x)) (* PI x)))
float code(float x, float tau) {
	return sinf((((float) M_PI) * x)) / (((float) M_PI) * x);
}
function code(x, tau)
	return Float32(sin(Float32(Float32(pi) * x)) / Float32(Float32(pi) * x))
end
function tmp = code(x, tau)
	tmp = sin((single(pi) * x)) / (single(pi) * x);
end
\begin{array}{l}

\\
\frac{\sin \left(\pi \cdot x\right)}{\pi \cdot x}
\end{array}
Derivation
  1. Initial program 98.3%

    \[\frac{\sin \left(\left(x \cdot \pi\right) \cdot tau\right)}{\left(x \cdot \pi\right) \cdot tau} \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi} \]
  2. Step-by-step derivation
    1. associate-*l*97.4%

      \[\leadsto \frac{\sin \color{blue}{\left(x \cdot \left(\pi \cdot tau\right)\right)}}{\left(x \cdot \pi\right) \cdot tau} \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi} \]
    2. associate-*l*98.3%

      \[\leadsto \frac{\sin \left(x \cdot \left(\pi \cdot tau\right)\right)}{\color{blue}{x \cdot \left(\pi \cdot tau\right)}} \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi} \]
  3. Simplified98.3%

    \[\leadsto \color{blue}{\frac{\sin \left(x \cdot \left(\pi \cdot tau\right)\right)}{x \cdot \left(\pi \cdot tau\right)} \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi}} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. clear-num98.1%

      \[\leadsto \color{blue}{\frac{1}{\frac{x \cdot \left(\pi \cdot tau\right)}{\sin \left(x \cdot \left(\pi \cdot tau\right)\right)}}} \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi} \]
    2. associate-/r/98.0%

      \[\leadsto \color{blue}{\left(\frac{1}{x \cdot \left(\pi \cdot tau\right)} \cdot \sin \left(x \cdot \left(\pi \cdot tau\right)\right)\right)} \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi} \]
    3. associate-*r*97.5%

      \[\leadsto \left(\frac{1}{\color{blue}{\left(x \cdot \pi\right) \cdot tau}} \cdot \sin \left(x \cdot \left(\pi \cdot tau\right)\right)\right) \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi} \]
    4. *-commutative97.5%

      \[\leadsto \left(\frac{1}{\color{blue}{\left(\pi \cdot x\right)} \cdot tau} \cdot \sin \left(x \cdot \left(\pi \cdot tau\right)\right)\right) \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi} \]
    5. associate-*r*97.5%

      \[\leadsto \left(\frac{1}{\color{blue}{\pi \cdot \left(x \cdot tau\right)}} \cdot \sin \left(x \cdot \left(\pi \cdot tau\right)\right)\right) \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi} \]
    6. associate-*r*97.8%

      \[\leadsto \left(\frac{1}{\pi \cdot \left(x \cdot tau\right)} \cdot \sin \color{blue}{\left(\left(x \cdot \pi\right) \cdot tau\right)}\right) \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi} \]
    7. *-commutative97.8%

      \[\leadsto \left(\frac{1}{\pi \cdot \left(x \cdot tau\right)} \cdot \sin \left(\color{blue}{\left(\pi \cdot x\right)} \cdot tau\right)\right) \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi} \]
    8. associate-*r*98.1%

      \[\leadsto \left(\frac{1}{\pi \cdot \left(x \cdot tau\right)} \cdot \sin \color{blue}{\left(\pi \cdot \left(x \cdot tau\right)\right)}\right) \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi} \]
  6. Applied egg-rr98.1%

    \[\leadsto \color{blue}{\left(\frac{1}{\pi \cdot \left(x \cdot tau\right)} \cdot \sin \left(\pi \cdot \left(x \cdot tau\right)\right)\right)} \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi} \]
  7. Step-by-step derivation
    1. associate-*r*97.8%

      \[\leadsto \left(\frac{1}{\pi \cdot \left(x \cdot tau\right)} \cdot \sin \color{blue}{\left(\left(\pi \cdot x\right) \cdot tau\right)}\right) \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi} \]
    2. *-commutative97.8%

      \[\leadsto \left(\frac{1}{\pi \cdot \left(x \cdot tau\right)} \cdot \sin \left(\color{blue}{\left(x \cdot \pi\right)} \cdot tau\right)\right) \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi} \]
    3. associate-*r*98.2%

      \[\leadsto \left(\frac{1}{\color{blue}{\left(\pi \cdot x\right) \cdot tau}} \cdot \sin \left(\left(x \cdot \pi\right) \cdot tau\right)\right) \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi} \]
    4. *-commutative98.2%

      \[\leadsto \left(\frac{1}{\color{blue}{\left(x \cdot \pi\right)} \cdot tau} \cdot \sin \left(\left(x \cdot \pi\right) \cdot tau\right)\right) \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi} \]
    5. associate-*l/98.3%

      \[\leadsto \color{blue}{\frac{1 \cdot \sin \left(\left(x \cdot \pi\right) \cdot tau\right)}{\left(x \cdot \pi\right) \cdot tau}} \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi} \]
    6. associate-*r*97.6%

      \[\leadsto \frac{1 \cdot \sin \left(\left(x \cdot \pi\right) \cdot tau\right)}{\color{blue}{x \cdot \left(\pi \cdot tau\right)}} \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi} \]
    7. *-un-lft-identity97.6%

      \[\leadsto \frac{\color{blue}{\sin \left(\left(x \cdot \pi\right) \cdot tau\right)}}{x \cdot \left(\pi \cdot tau\right)} \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi} \]
    8. associate-/r*97.6%

      \[\leadsto \color{blue}{\frac{\frac{\sin \left(\left(x \cdot \pi\right) \cdot tau\right)}{x}}{\pi \cdot tau}} \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi} \]
  8. Applied egg-rr97.9%

    \[\leadsto \color{blue}{\frac{\frac{\sin \left(x \cdot \left(\pi \cdot tau\right)\right)}{x}}{\pi \cdot tau}} \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi} \]
  9. Taylor expanded in x around 0 67.0%

    \[\leadsto \color{blue}{1} \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi} \]
  10. Final simplification67.0%

    \[\leadsto \frac{\sin \left(\pi \cdot x\right)}{\pi \cdot x} \]
  11. Add Preprocessing

Alternative 7: 63.6% accurate, 16.8× speedup?

\[\begin{array}{l} \\ \frac{\pi \cdot \left(x \cdot tau\right)}{\frac{x \cdot tau}{\frac{1}{\pi}}} \end{array} \]
(FPCore (x tau)
 :precision binary32
 (/ (* PI (* x tau)) (/ (* x tau) (/ 1.0 PI))))
float code(float x, float tau) {
	return (((float) M_PI) * (x * tau)) / ((x * tau) / (1.0f / ((float) M_PI)));
}
function code(x, tau)
	return Float32(Float32(Float32(pi) * Float32(x * tau)) / Float32(Float32(x * tau) / Float32(Float32(1.0) / Float32(pi))))
end
function tmp = code(x, tau)
	tmp = (single(pi) * (x * tau)) / ((x * tau) / (single(1.0) / single(pi)));
end
\begin{array}{l}

\\
\frac{\pi \cdot \left(x \cdot tau\right)}{\frac{x \cdot tau}{\frac{1}{\pi}}}
\end{array}
Derivation
  1. Initial program 98.3%

    \[\frac{\sin \left(\left(x \cdot \pi\right) \cdot tau\right)}{\left(x \cdot \pi\right) \cdot tau} \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi} \]
  2. Step-by-step derivation
    1. associate-*l*97.4%

      \[\leadsto \frac{\sin \color{blue}{\left(x \cdot \left(\pi \cdot tau\right)\right)}}{\left(x \cdot \pi\right) \cdot tau} \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi} \]
    2. associate-*l*98.3%

      \[\leadsto \frac{\sin \left(x \cdot \left(\pi \cdot tau\right)\right)}{\color{blue}{x \cdot \left(\pi \cdot tau\right)}} \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi} \]
  3. Simplified98.3%

    \[\leadsto \color{blue}{\frac{\sin \left(x \cdot \left(\pi \cdot tau\right)\right)}{x \cdot \left(\pi \cdot tau\right)} \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi}} \]
  4. Add Preprocessing
  5. Taylor expanded in x around 0 72.7%

    \[\leadsto \frac{\sin \left(x \cdot \left(\pi \cdot tau\right)\right)}{x \cdot \left(\pi \cdot tau\right)} \cdot \color{blue}{1} \]
  6. Taylor expanded in x around 0 65.9%

    \[\leadsto \frac{\color{blue}{tau \cdot \left(x \cdot \pi\right)}}{x \cdot \left(\pi \cdot tau\right)} \cdot 1 \]
  7. Step-by-step derivation
    1. *-commutative65.9%

      \[\leadsto \frac{\color{blue}{\left(x \cdot \pi\right) \cdot tau}}{x \cdot \left(\pi \cdot tau\right)} \cdot 1 \]
    2. *-commutative65.9%

      \[\leadsto \frac{\color{blue}{\left(\pi \cdot x\right)} \cdot tau}{x \cdot \left(\pi \cdot tau\right)} \cdot 1 \]
    3. associate-*r*65.9%

      \[\leadsto \frac{\color{blue}{\pi \cdot \left(x \cdot tau\right)}}{x \cdot \left(\pi \cdot tau\right)} \cdot 1 \]
  8. Simplified65.9%

    \[\leadsto \frac{\color{blue}{\pi \cdot \left(x \cdot tau\right)}}{x \cdot \left(\pi \cdot tau\right)} \cdot 1 \]
  9. Step-by-step derivation
    1. associate-*r*65.9%

      \[\leadsto \frac{\pi \cdot \left(x \cdot tau\right)}{\color{blue}{\left(x \cdot \pi\right) \cdot tau}} \cdot 1 \]
    2. /-rgt-identity65.9%

      \[\leadsto \frac{\pi \cdot \left(x \cdot tau\right)}{\color{blue}{\frac{\left(x \cdot \pi\right) \cdot tau}{1}}} \cdot 1 \]
    3. *-commutative65.9%

      \[\leadsto \frac{\pi \cdot \left(x \cdot tau\right)}{\frac{\color{blue}{tau \cdot \left(x \cdot \pi\right)}}{1}} \cdot 1 \]
    4. associate-*r*66.1%

      \[\leadsto \frac{\pi \cdot \left(x \cdot tau\right)}{\frac{\color{blue}{\left(tau \cdot x\right) \cdot \pi}}{1}} \cdot 1 \]
    5. *-commutative66.1%

      \[\leadsto \frac{\pi \cdot \left(x \cdot tau\right)}{\frac{\color{blue}{\left(x \cdot tau\right)} \cdot \pi}{1}} \cdot 1 \]
    6. associate-/l*66.1%

      \[\leadsto \frac{\pi \cdot \left(x \cdot tau\right)}{\color{blue}{\frac{x \cdot tau}{\frac{1}{\pi}}}} \cdot 1 \]
  10. Applied egg-rr66.1%

    \[\leadsto \frac{\pi \cdot \left(x \cdot tau\right)}{\color{blue}{\frac{x \cdot tau}{\frac{1}{\pi}}}} \cdot 1 \]
  11. Final simplification66.1%

    \[\leadsto \frac{\pi \cdot \left(x \cdot tau\right)}{\frac{x \cdot tau}{\frac{1}{\pi}}} \]
  12. Add Preprocessing

Alternative 8: 63.6% accurate, 43.8× speedup?

\[\begin{array}{l} \\ x \cdot \frac{1}{x} \end{array} \]
(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}
Derivation
  1. Initial program 98.3%

    \[\frac{\sin \left(\left(x \cdot \pi\right) \cdot tau\right)}{\left(x \cdot \pi\right) \cdot tau} \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi} \]
  2. Step-by-step derivation
    1. associate-*l*97.4%

      \[\leadsto \frac{\sin \color{blue}{\left(x \cdot \left(\pi \cdot tau\right)\right)}}{\left(x \cdot \pi\right) \cdot tau} \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi} \]
    2. associate-*l*98.3%

      \[\leadsto \frac{\sin \left(x \cdot \left(\pi \cdot tau\right)\right)}{\color{blue}{x \cdot \left(\pi \cdot tau\right)}} \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi} \]
  3. Simplified98.3%

    \[\leadsto \color{blue}{\frac{\sin \left(x \cdot \left(\pi \cdot tau\right)\right)}{x \cdot \left(\pi \cdot tau\right)} \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi}} \]
  4. Add Preprocessing
  5. Taylor expanded in x around 0 72.7%

    \[\leadsto \frac{\sin \left(x \cdot \left(\pi \cdot tau\right)\right)}{x \cdot \left(\pi \cdot tau\right)} \cdot \color{blue}{1} \]
  6. Step-by-step derivation
    1. associate-*r*72.4%

      \[\leadsto \frac{\sin \left(x \cdot \left(\pi \cdot tau\right)\right)}{\color{blue}{\left(x \cdot \pi\right) \cdot tau}} \cdot 1 \]
    2. /-rgt-identity72.4%

      \[\leadsto \frac{\sin \left(x \cdot \left(\pi \cdot tau\right)\right)}{\color{blue}{\frac{\left(x \cdot \pi\right) \cdot tau}{1}}} \cdot 1 \]
    3. *-commutative72.4%

      \[\leadsto \frac{\sin \left(x \cdot \left(\pi \cdot tau\right)\right)}{\frac{\color{blue}{\left(\pi \cdot x\right)} \cdot tau}{1}} \cdot 1 \]
    4. associate-*r*72.4%

      \[\leadsto \frac{\sin \left(x \cdot \left(\pi \cdot tau\right)\right)}{\frac{\color{blue}{\pi \cdot \left(x \cdot tau\right)}}{1}} \cdot 1 \]
    5. associate-/l*72.5%

      \[\leadsto \frac{\sin \left(x \cdot \left(\pi \cdot tau\right)\right)}{\color{blue}{\frac{\pi}{\frac{1}{x \cdot tau}}}} \cdot 1 \]
  7. Applied egg-rr72.5%

    \[\leadsto \frac{\sin \left(x \cdot \left(\pi \cdot tau\right)\right)}{\color{blue}{\frac{\pi}{\frac{1}{x \cdot tau}}}} \cdot 1 \]
  8. Step-by-step derivation
    1. associate-/r/72.4%

      \[\leadsto \frac{\sin \left(x \cdot \left(\pi \cdot tau\right)\right)}{\color{blue}{\frac{\pi}{1} \cdot \left(x \cdot tau\right)}} \cdot 1 \]
    2. /-rgt-identity72.4%

      \[\leadsto \frac{\sin \left(x \cdot \left(\pi \cdot tau\right)\right)}{\color{blue}{\pi} \cdot \left(x \cdot tau\right)} \cdot 1 \]
    3. associate-*r*72.4%

      \[\leadsto \frac{\sin \left(x \cdot \left(\pi \cdot tau\right)\right)}{\color{blue}{\left(\pi \cdot x\right) \cdot tau}} \cdot 1 \]
    4. *-commutative72.4%

      \[\leadsto \frac{\sin \left(x \cdot \left(\pi \cdot tau\right)\right)}{\color{blue}{\left(x \cdot \pi\right)} \cdot tau} \cdot 1 \]
    5. associate-/l/72.4%

      \[\leadsto \color{blue}{\frac{\frac{\sin \left(x \cdot \left(\pi \cdot tau\right)\right)}{tau}}{x \cdot \pi}} \cdot 1 \]
    6. *-un-lft-identity72.4%

      \[\leadsto \frac{\color{blue}{1 \cdot \frac{\sin \left(x \cdot \left(\pi \cdot tau\right)\right)}{tau}}}{x \cdot \pi} \cdot 1 \]
    7. times-frac72.4%

      \[\leadsto \color{blue}{\left(\frac{1}{x} \cdot \frac{\frac{\sin \left(x \cdot \left(\pi \cdot tau\right)\right)}{tau}}{\pi}\right)} \cdot 1 \]
  9. Applied egg-rr72.4%

    \[\leadsto \color{blue}{\left(\frac{1}{x} \cdot \frac{\frac{\sin \left(x \cdot \left(\pi \cdot tau\right)\right)}{tau}}{\pi}\right)} \cdot 1 \]
  10. Taylor expanded in x around 0 66.1%

    \[\leadsto \left(\frac{1}{x} \cdot \color{blue}{x}\right) \cdot 1 \]
  11. Final simplification66.1%

    \[\leadsto x \cdot \frac{1}{x} \]
  12. Add Preprocessing

Reproduce

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