SynthBasics:moogVCF from YampaSynth-0.2

Percentage Accurate: 93.7% → 98.7%
Time: 12.0s
Alternatives: 9
Speedup: 1.0×

Specification

?
\[\begin{array}{l} \\ x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))
double code(double x, double y, double z, double t) {
	return x + ((y * z) * (tanh((t / y)) - tanh((x / y))));
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = x + ((y * z) * (tanh((t / y)) - tanh((x / y))))
end function
public static double code(double x, double y, double z, double t) {
	return x + ((y * z) * (Math.tanh((t / y)) - Math.tanh((x / y))));
}
def code(x, y, z, t):
	return x + ((y * z) * (math.tanh((t / y)) - math.tanh((x / y))))
function code(x, y, z, t)
	return Float64(x + Float64(Float64(y * z) * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))))
end
function tmp = code(x, y, z, t)
	tmp = x + ((y * z) * (tanh((t / y)) - tanh((x / y))));
end
code[x_, y_, z_, t_] := N[(x + N[(N[(y * z), $MachinePrecision] * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)
\end{array}

Sampling outcomes in binary64 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 9 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: 93.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))
double code(double x, double y, double z, double t) {
	return x + ((y * z) * (tanh((t / y)) - tanh((x / y))));
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = x + ((y * z) * (tanh((t / y)) - tanh((x / y))))
end function
public static double code(double x, double y, double z, double t) {
	return x + ((y * z) * (Math.tanh((t / y)) - Math.tanh((x / y))));
}
def code(x, y, z, t):
	return x + ((y * z) * (math.tanh((t / y)) - math.tanh((x / y))))
function code(x, y, z, t)
	return Float64(x + Float64(Float64(y * z) * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))))
end
function tmp = code(x, y, z, t)
	tmp = x + ((y * z) * (tanh((t / y)) - tanh((x / y))));
end
code[x_, y_, z_, t_] := N[(x + N[(N[(y * z), $MachinePrecision] * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)
\end{array}

Alternative 1: 98.7% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\\ \mathbf{if}\;x + \left(y \cdot z\right) \cdot t\_1 \leq 5 \cdot 10^{+303}:\\ \;\;\;\;\mathsf{fma}\left(y \cdot t\_1, z, x\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(t - x\right)\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (- (tanh (/ t y)) (tanh (/ x y)))))
   (if (<= (+ x (* (* y z) t_1)) 5e+303) (fma (* y t_1) z x) (* z (- t x)))))
double code(double x, double y, double z, double t) {
	double t_1 = tanh((t / y)) - tanh((x / y));
	double tmp;
	if ((x + ((y * z) * t_1)) <= 5e+303) {
		tmp = fma((y * t_1), z, x);
	} else {
		tmp = z * (t - x);
	}
	return tmp;
}
function code(x, y, z, t)
	t_1 = Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))
	tmp = 0.0
	if (Float64(x + Float64(Float64(y * z) * t_1)) <= 5e+303)
		tmp = fma(Float64(y * t_1), z, x);
	else
		tmp = Float64(z * Float64(t - x));
	end
	return tmp
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x + N[(N[(y * z), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision], 5e+303], N[(N[(y * t$95$1), $MachinePrecision] * z + x), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\\
\mathbf{if}\;x + \left(y \cdot z\right) \cdot t\_1 \leq 5 \cdot 10^{+303}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot t\_1, z, x\right)\\

\mathbf{else}:\\
\;\;\;\;z \cdot \left(t - x\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 4.9999999999999997e303

    1. Initial program 98.8%

      \[x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto x + \color{blue}{\left(y \cdot z\right)} \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \]
      2. lift-/.f64N/A

        \[\leadsto x + \left(y \cdot z\right) \cdot \left(\tanh \color{blue}{\left(\frac{t}{y}\right)} - \tanh \left(\frac{x}{y}\right)\right) \]
      3. lift-tanh.f64N/A

        \[\leadsto x + \left(y \cdot z\right) \cdot \left(\color{blue}{\tanh \left(\frac{t}{y}\right)} - \tanh \left(\frac{x}{y}\right)\right) \]
      4. lift-/.f64N/A

        \[\leadsto x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \color{blue}{\left(\frac{x}{y}\right)}\right) \]
      5. lift-tanh.f64N/A

        \[\leadsto x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \color{blue}{\tanh \left(\frac{x}{y}\right)}\right) \]
      6. lift--.f64N/A

        \[\leadsto x + \left(y \cdot z\right) \cdot \color{blue}{\left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)} \]
      7. lift-*.f64N/A

        \[\leadsto x + \color{blue}{\left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)} \]
      8. +-commutativeN/A

        \[\leadsto \color{blue}{\left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) + x} \]
      9. lift-*.f64N/A

        \[\leadsto \color{blue}{\left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)} + x \]
      10. *-commutativeN/A

        \[\leadsto \color{blue}{\left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot \left(y \cdot z\right)} + x \]
      11. lift-*.f64N/A

        \[\leadsto \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot \color{blue}{\left(y \cdot z\right)} + x \]
      12. associate-*r*N/A

        \[\leadsto \color{blue}{\left(\left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot y\right) \cdot z} + x \]
      13. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot y, z, x\right)} \]
      14. lower-*.f64100.0

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot y}, z, x\right) \]
    4. Applied rewrites100.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot y, z, x\right)} \]

    if 4.9999999999999997e303 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y)))))

    1. Initial program 51.3%

      \[x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \]
    2. Add Preprocessing
    3. Taylor expanded in y around inf

      \[\leadsto \color{blue}{x + z \cdot \left(t - x\right)} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{z \cdot \left(t - x\right) + x} \]
      2. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(z, t - x, x\right)} \]
      3. lower--.f64100.0

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{t - x}, x\right) \]
    5. Applied rewrites100.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(z, t - x, x\right)} \]
    6. Taylor expanded in z around inf

      \[\leadsto \color{blue}{z \cdot \left(t - x\right)} \]
    7. Step-by-step derivation
      1. remove-double-negN/A

        \[\leadsto z \cdot \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(t - x\right)\right)\right)\right)\right)} \]
      2. mul-1-negN/A

        \[\leadsto z \cdot \left(\mathsf{neg}\left(\color{blue}{-1 \cdot \left(t - x\right)}\right)\right) \]
      3. distribute-lft-out--N/A

        \[\leadsto z \cdot \left(\mathsf{neg}\left(\color{blue}{\left(-1 \cdot t - -1 \cdot x\right)}\right)\right) \]
      4. mul-1-negN/A

        \[\leadsto z \cdot \color{blue}{\left(-1 \cdot \left(-1 \cdot t - -1 \cdot x\right)\right)} \]
      5. lower-*.f64N/A

        \[\leadsto \color{blue}{z \cdot \left(-1 \cdot \left(-1 \cdot t - -1 \cdot x\right)\right)} \]
      6. mul-1-negN/A

        \[\leadsto z \cdot \color{blue}{\left(\mathsf{neg}\left(\left(-1 \cdot t - -1 \cdot x\right)\right)\right)} \]
      7. distribute-lft-out--N/A

        \[\leadsto z \cdot \left(\mathsf{neg}\left(\color{blue}{-1 \cdot \left(t - x\right)}\right)\right) \]
      8. mul-1-negN/A

        \[\leadsto z \cdot \left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\left(t - x\right)\right)\right)}\right)\right) \]
      9. remove-double-negN/A

        \[\leadsto z \cdot \color{blue}{\left(t - x\right)} \]
      10. lower--.f64100.0

        \[\leadsto z \cdot \color{blue}{\left(t - x\right)} \]
    8. Applied rewrites100.0%

      \[\leadsto \color{blue}{z \cdot \left(t - x\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification100.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \leq 5 \cdot 10^{+303}:\\ \;\;\;\;\mathsf{fma}\left(y \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), z, x\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(t - x\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 60.7% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \leq 5 \cdot 10^{+303}:\\ \;\;\;\;x + z \cdot t\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(t - x\right)\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (<= (+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))) 5e+303)
   (+ x (* z t))
   (* z (- t x))))
double code(double x, double y, double z, double t) {
	double tmp;
	if ((x + ((y * z) * (tanh((t / y)) - tanh((x / y))))) <= 5e+303) {
		tmp = x + (z * t);
	} else {
		tmp = z * (t - x);
	}
	return tmp;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if ((x + ((y * z) * (tanh((t / y)) - tanh((x / y))))) <= 5d+303) then
        tmp = x + (z * t)
    else
        tmp = z * (t - x)
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double tmp;
	if ((x + ((y * z) * (Math.tanh((t / y)) - Math.tanh((x / y))))) <= 5e+303) {
		tmp = x + (z * t);
	} else {
		tmp = z * (t - x);
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if (x + ((y * z) * (math.tanh((t / y)) - math.tanh((x / y))))) <= 5e+303:
		tmp = x + (z * t)
	else:
		tmp = z * (t - x)
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if (Float64(x + Float64(Float64(y * z) * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y))))) <= 5e+303)
		tmp = Float64(x + Float64(z * t));
	else
		tmp = Float64(z * Float64(t - x));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if ((x + ((y * z) * (tanh((t / y)) - tanh((x / y))))) <= 5e+303)
		tmp = x + (z * t);
	else
		tmp = z * (t - x);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[LessEqual[N[(x + N[(N[(y * z), $MachinePrecision] * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 5e+303], N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \leq 5 \cdot 10^{+303}:\\
\;\;\;\;x + z \cdot t\\

\mathbf{else}:\\
\;\;\;\;z \cdot \left(t - x\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 4.9999999999999997e303

    1. Initial program 98.8%

      \[x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \]
    2. Add Preprocessing
    3. Taylor expanded in y around inf

      \[\leadsto x + \left(y \cdot z\right) \cdot \color{blue}{\frac{t - x}{y}} \]
    4. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto x + \left(y \cdot z\right) \cdot \color{blue}{\frac{t - x}{y}} \]
      2. lower--.f6447.3

        \[\leadsto x + \left(y \cdot z\right) \cdot \frac{\color{blue}{t - x}}{y} \]
    5. Applied rewrites47.3%

      \[\leadsto x + \left(y \cdot z\right) \cdot \color{blue}{\frac{t - x}{y}} \]
    6. Taylor expanded in t around inf

      \[\leadsto x + \color{blue}{t \cdot z} \]
    7. Step-by-step derivation
      1. lower-*.f6461.4

        \[\leadsto x + \color{blue}{t \cdot z} \]
    8. Applied rewrites61.4%

      \[\leadsto x + \color{blue}{t \cdot z} \]

    if 4.9999999999999997e303 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y)))))

    1. Initial program 51.3%

      \[x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \]
    2. Add Preprocessing
    3. Taylor expanded in y around inf

      \[\leadsto \color{blue}{x + z \cdot \left(t - x\right)} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{z \cdot \left(t - x\right) + x} \]
      2. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(z, t - x, x\right)} \]
      3. lower--.f64100.0

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{t - x}, x\right) \]
    5. Applied rewrites100.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(z, t - x, x\right)} \]
    6. Taylor expanded in z around inf

      \[\leadsto \color{blue}{z \cdot \left(t - x\right)} \]
    7. Step-by-step derivation
      1. remove-double-negN/A

        \[\leadsto z \cdot \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(t - x\right)\right)\right)\right)\right)} \]
      2. mul-1-negN/A

        \[\leadsto z \cdot \left(\mathsf{neg}\left(\color{blue}{-1 \cdot \left(t - x\right)}\right)\right) \]
      3. distribute-lft-out--N/A

        \[\leadsto z \cdot \left(\mathsf{neg}\left(\color{blue}{\left(-1 \cdot t - -1 \cdot x\right)}\right)\right) \]
      4. mul-1-negN/A

        \[\leadsto z \cdot \color{blue}{\left(-1 \cdot \left(-1 \cdot t - -1 \cdot x\right)\right)} \]
      5. lower-*.f64N/A

        \[\leadsto \color{blue}{z \cdot \left(-1 \cdot \left(-1 \cdot t - -1 \cdot x\right)\right)} \]
      6. mul-1-negN/A

        \[\leadsto z \cdot \color{blue}{\left(\mathsf{neg}\left(\left(-1 \cdot t - -1 \cdot x\right)\right)\right)} \]
      7. distribute-lft-out--N/A

        \[\leadsto z \cdot \left(\mathsf{neg}\left(\color{blue}{-1 \cdot \left(t - x\right)}\right)\right) \]
      8. mul-1-negN/A

        \[\leadsto z \cdot \left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\left(t - x\right)\right)\right)}\right)\right) \]
      9. remove-double-negN/A

        \[\leadsto z \cdot \color{blue}{\left(t - x\right)} \]
      10. lower--.f64100.0

        \[\leadsto z \cdot \color{blue}{\left(t - x\right)} \]
    8. Applied rewrites100.0%

      \[\leadsto \color{blue}{z \cdot \left(t - x\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification64.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \leq 5 \cdot 10^{+303}:\\ \;\;\;\;x + z \cdot t\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(t - x\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 97.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 1.6 \cdot 10^{+250}:\\ \;\;\;\;\mathsf{fma}\left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), y, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (<= y 1.6e+250)
   (fma (* z (- (tanh (/ t y)) (tanh (/ x y)))) y x)
   (fma z (- t x) x)))
double code(double x, double y, double z, double t) {
	double tmp;
	if (y <= 1.6e+250) {
		tmp = fma((z * (tanh((t / y)) - tanh((x / y)))), y, x);
	} else {
		tmp = fma(z, (t - x), x);
	}
	return tmp;
}
function code(x, y, z, t)
	tmp = 0.0
	if (y <= 1.6e+250)
		tmp = fma(Float64(z * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))), y, x);
	else
		tmp = fma(z, Float64(t - x), x);
	end
	return tmp
end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.6e+250], N[(N[(z * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.6 \cdot 10^{+250}:\\
\;\;\;\;\mathsf{fma}\left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), y, x\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 1.5999999999999999e250

    1. Initial program 96.8%

      \[x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto x + \color{blue}{\left(y \cdot z\right)} \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \]
      2. lift-/.f64N/A

        \[\leadsto x + \left(y \cdot z\right) \cdot \left(\tanh \color{blue}{\left(\frac{t}{y}\right)} - \tanh \left(\frac{x}{y}\right)\right) \]
      3. lift-tanh.f64N/A

        \[\leadsto x + \left(y \cdot z\right) \cdot \left(\color{blue}{\tanh \left(\frac{t}{y}\right)} - \tanh \left(\frac{x}{y}\right)\right) \]
      4. lift-/.f64N/A

        \[\leadsto x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \color{blue}{\left(\frac{x}{y}\right)}\right) \]
      5. lift-tanh.f64N/A

        \[\leadsto x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \color{blue}{\tanh \left(\frac{x}{y}\right)}\right) \]
      6. lift--.f64N/A

        \[\leadsto x + \left(y \cdot z\right) \cdot \color{blue}{\left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)} \]
      7. lift-*.f64N/A

        \[\leadsto x + \color{blue}{\left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)} \]
      8. +-commutativeN/A

        \[\leadsto \color{blue}{\left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) + x} \]
      9. lift-*.f64N/A

        \[\leadsto \color{blue}{\left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)} + x \]
      10. lift-*.f64N/A

        \[\leadsto \color{blue}{\left(y \cdot z\right)} \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) + x \]
      11. associate-*l*N/A

        \[\leadsto \color{blue}{y \cdot \left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right)} + x \]
      12. *-commutativeN/A

        \[\leadsto \color{blue}{\left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right) \cdot y} + x \]
      13. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), y, x\right)} \]
      14. lower-*.f6498.6

        \[\leadsto \mathsf{fma}\left(\color{blue}{z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)}, y, x\right) \]
    4. Applied rewrites98.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), y, x\right)} \]

    if 1.5999999999999999e250 < y

    1. Initial program 69.7%

      \[x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \]
    2. Add Preprocessing
    3. Taylor expanded in y around inf

      \[\leadsto \color{blue}{x + z \cdot \left(t - x\right)} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{z \cdot \left(t - x\right) + x} \]
      2. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(z, t - x, x\right)} \]
      3. lower--.f64100.0

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{t - x}, x\right) \]
    5. Applied rewrites100.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(z, t - x, x\right)} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 4: 77.3% accurate, 1.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.9 \cdot 10^{+75}:\\ \;\;\;\;x + z \cdot t\\ \mathbf{elif}\;x \leq 7 \cdot 10^{+107}:\\ \;\;\;\;\mathsf{fma}\left(y \cdot \left(\tanh \left(\frac{t}{y}\right) - \frac{x}{y}\right), z, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y \cdot \left(\frac{t}{y} - \tanh \left(\frac{x}{y}\right)\right), z, x\right)\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (<= x -1.9e+75)
   (+ x (* z t))
   (if (<= x 7e+107)
     (fma (* y (- (tanh (/ t y)) (/ x y))) z x)
     (fma (* y (- (/ t y) (tanh (/ x y)))) z x))))
double code(double x, double y, double z, double t) {
	double tmp;
	if (x <= -1.9e+75) {
		tmp = x + (z * t);
	} else if (x <= 7e+107) {
		tmp = fma((y * (tanh((t / y)) - (x / y))), z, x);
	} else {
		tmp = fma((y * ((t / y) - tanh((x / y)))), z, x);
	}
	return tmp;
}
function code(x, y, z, t)
	tmp = 0.0
	if (x <= -1.9e+75)
		tmp = Float64(x + Float64(z * t));
	elseif (x <= 7e+107)
		tmp = fma(Float64(y * Float64(tanh(Float64(t / y)) - Float64(x / y))), z, x);
	else
		tmp = fma(Float64(y * Float64(Float64(t / y) - tanh(Float64(x / y)))), z, x);
	end
	return tmp
end
code[x_, y_, z_, t_] := If[LessEqual[x, -1.9e+75], N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 7e+107], N[(N[(y * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * z + x), $MachinePrecision], N[(N[(y * N[(N[(t / y), $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * z + x), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.9 \cdot 10^{+75}:\\
\;\;\;\;x + z \cdot t\\

\mathbf{elif}\;x \leq 7 \cdot 10^{+107}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot \left(\tanh \left(\frac{t}{y}\right) - \frac{x}{y}\right), z, x\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot \left(\frac{t}{y} - \tanh \left(\frac{x}{y}\right)\right), z, x\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.9000000000000001e75

    1. Initial program 100.0%

      \[x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \]
    2. Add Preprocessing
    3. Taylor expanded in y around inf

      \[\leadsto x + \left(y \cdot z\right) \cdot \color{blue}{\frac{t - x}{y}} \]
    4. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto x + \left(y \cdot z\right) \cdot \color{blue}{\frac{t - x}{y}} \]
      2. lower--.f6438.1

        \[\leadsto x + \left(y \cdot z\right) \cdot \frac{\color{blue}{t - x}}{y} \]
    5. Applied rewrites38.1%

      \[\leadsto x + \left(y \cdot z\right) \cdot \color{blue}{\frac{t - x}{y}} \]
    6. Taylor expanded in t around inf

      \[\leadsto x + \color{blue}{t \cdot z} \]
    7. Step-by-step derivation
      1. lower-*.f6470.8

        \[\leadsto x + \color{blue}{t \cdot z} \]
    8. Applied rewrites70.8%

      \[\leadsto x + \color{blue}{t \cdot z} \]

    if -1.9000000000000001e75 < x < 6.9999999999999995e107

    1. Initial program 92.8%

      \[x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \color{blue}{\frac{x}{y}}\right) \]
    4. Step-by-step derivation
      1. lower-/.f6476.3

        \[\leadsto x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \color{blue}{\frac{x}{y}}\right) \]
    5. Applied rewrites76.3%

      \[\leadsto x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \color{blue}{\frac{x}{y}}\right) \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto x + \color{blue}{\left(y \cdot z\right)} \cdot \left(\tanh \left(\frac{t}{y}\right) - \frac{x}{y}\right) \]
      2. lift-/.f64N/A

        \[\leadsto x + \left(y \cdot z\right) \cdot \left(\tanh \color{blue}{\left(\frac{t}{y}\right)} - \frac{x}{y}\right) \]
      3. lift-tanh.f64N/A

        \[\leadsto x + \left(y \cdot z\right) \cdot \left(\color{blue}{\tanh \left(\frac{t}{y}\right)} - \frac{x}{y}\right) \]
      4. lift-/.f64N/A

        \[\leadsto x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \color{blue}{\frac{x}{y}}\right) \]
      5. lift--.f64N/A

        \[\leadsto x + \left(y \cdot z\right) \cdot \color{blue}{\left(\tanh \left(\frac{t}{y}\right) - \frac{x}{y}\right)} \]
      6. lift-*.f64N/A

        \[\leadsto x + \color{blue}{\left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \frac{x}{y}\right)} \]
      7. +-commutativeN/A

        \[\leadsto \color{blue}{\left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \frac{x}{y}\right) + x} \]
      8. lift-*.f64N/A

        \[\leadsto \color{blue}{\left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \frac{x}{y}\right)} + x \]
      9. *-commutativeN/A

        \[\leadsto \color{blue}{\left(\tanh \left(\frac{t}{y}\right) - \frac{x}{y}\right) \cdot \left(y \cdot z\right)} + x \]
      10. lift-*.f64N/A

        \[\leadsto \left(\tanh \left(\frac{t}{y}\right) - \frac{x}{y}\right) \cdot \color{blue}{\left(y \cdot z\right)} + x \]
      11. associate-*r*N/A

        \[\leadsto \color{blue}{\left(\left(\tanh \left(\frac{t}{y}\right) - \frac{x}{y}\right) \cdot y\right) \cdot z} + x \]
      12. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\left(\tanh \left(\frac{t}{y}\right) - \frac{x}{y}\right) \cdot y, z, x\right)} \]
      13. lower-*.f6480.6

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\tanh \left(\frac{t}{y}\right) - \frac{x}{y}\right) \cdot y}, z, x\right) \]
    7. Applied rewrites80.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\left(\tanh \left(\frac{t}{y}\right) - \frac{x}{y}\right) \cdot y, z, x\right)} \]

    if 6.9999999999999995e107 < x

    1. Initial program 100.0%

      \[x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto x + \color{blue}{\left(y \cdot z\right)} \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \]
      2. lift-/.f64N/A

        \[\leadsto x + \left(y \cdot z\right) \cdot \left(\tanh \color{blue}{\left(\frac{t}{y}\right)} - \tanh \left(\frac{x}{y}\right)\right) \]
      3. lift-tanh.f64N/A

        \[\leadsto x + \left(y \cdot z\right) \cdot \left(\color{blue}{\tanh \left(\frac{t}{y}\right)} - \tanh \left(\frac{x}{y}\right)\right) \]
      4. lift-/.f64N/A

        \[\leadsto x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \color{blue}{\left(\frac{x}{y}\right)}\right) \]
      5. lift-tanh.f64N/A

        \[\leadsto x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \color{blue}{\tanh \left(\frac{x}{y}\right)}\right) \]
      6. lift--.f64N/A

        \[\leadsto x + \left(y \cdot z\right) \cdot \color{blue}{\left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)} \]
      7. lift-*.f64N/A

        \[\leadsto x + \color{blue}{\left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)} \]
      8. +-commutativeN/A

        \[\leadsto \color{blue}{\left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) + x} \]
      9. lift-*.f64N/A

        \[\leadsto \color{blue}{\left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)} + x \]
      10. *-commutativeN/A

        \[\leadsto \color{blue}{\left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot \left(y \cdot z\right)} + x \]
      11. lift-*.f64N/A

        \[\leadsto \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot \color{blue}{\left(y \cdot z\right)} + x \]
      12. associate-*r*N/A

        \[\leadsto \color{blue}{\left(\left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot y\right) \cdot z} + x \]
      13. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot y, z, x\right)} \]
      14. lower-*.f64100.0

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot y}, z, x\right) \]
    4. Applied rewrites100.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot y, z, x\right)} \]
    5. Taylor expanded in t around 0

      \[\leadsto \mathsf{fma}\left(\left(\color{blue}{\frac{t}{y}} - \tanh \left(\frac{x}{y}\right)\right) \cdot y, z, x\right) \]
    6. Step-by-step derivation
      1. lower-/.f6485.9

        \[\leadsto \mathsf{fma}\left(\left(\color{blue}{\frac{t}{y}} - \tanh \left(\frac{x}{y}\right)\right) \cdot y, z, x\right) \]
    7. Applied rewrites85.9%

      \[\leadsto \mathsf{fma}\left(\left(\color{blue}{\frac{t}{y}} - \tanh \left(\frac{x}{y}\right)\right) \cdot y, z, x\right) \]
  3. Recombined 3 regimes into one program.
  4. Final simplification79.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.9 \cdot 10^{+75}:\\ \;\;\;\;x + z \cdot t\\ \mathbf{elif}\;x \leq 7 \cdot 10^{+107}:\\ \;\;\;\;\mathsf{fma}\left(y \cdot \left(\tanh \left(\frac{t}{y}\right) - \frac{x}{y}\right), z, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y \cdot \left(\frac{t}{y} - \tanh \left(\frac{x}{y}\right)\right), z, x\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 76.1% accurate, 1.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x + z \cdot t\\ \mathbf{if}\;x \leq -1.9 \cdot 10^{+75}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq 6.6 \cdot 10^{+122}:\\ \;\;\;\;\mathsf{fma}\left(y \cdot \left(\tanh \left(\frac{t}{y}\right) - \frac{x}{y}\right), z, x\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (+ x (* z t))))
   (if (<= x -1.9e+75)
     t_1
     (if (<= x 6.6e+122) (fma (* y (- (tanh (/ t y)) (/ x y))) z x) t_1))))
double code(double x, double y, double z, double t) {
	double t_1 = x + (z * t);
	double tmp;
	if (x <= -1.9e+75) {
		tmp = t_1;
	} else if (x <= 6.6e+122) {
		tmp = fma((y * (tanh((t / y)) - (x / y))), z, x);
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(x, y, z, t)
	t_1 = Float64(x + Float64(z * t))
	tmp = 0.0
	if (x <= -1.9e+75)
		tmp = t_1;
	elseif (x <= 6.6e+122)
		tmp = fma(Float64(y * Float64(tanh(Float64(t / y)) - Float64(x / y))), z, x);
	else
		tmp = t_1;
	end
	return tmp
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.9e+75], t$95$1, If[LessEqual[x, 6.6e+122], N[(N[(y * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * z + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := x + z \cdot t\\
\mathbf{if}\;x \leq -1.9 \cdot 10^{+75}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq 6.6 \cdot 10^{+122}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot \left(\tanh \left(\frac{t}{y}\right) - \frac{x}{y}\right), z, x\right)\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.9000000000000001e75 or 6.5999999999999998e122 < x

    1. Initial program 100.0%

      \[x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \]
    2. Add Preprocessing
    3. Taylor expanded in y around inf

      \[\leadsto x + \left(y \cdot z\right) \cdot \color{blue}{\frac{t - x}{y}} \]
    4. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto x + \left(y \cdot z\right) \cdot \color{blue}{\frac{t - x}{y}} \]
      2. lower--.f6437.9

        \[\leadsto x + \left(y \cdot z\right) \cdot \frac{\color{blue}{t - x}}{y} \]
    5. Applied rewrites37.9%

      \[\leadsto x + \left(y \cdot z\right) \cdot \color{blue}{\frac{t - x}{y}} \]
    6. Taylor expanded in t around inf

      \[\leadsto x + \color{blue}{t \cdot z} \]
    7. Step-by-step derivation
      1. lower-*.f6472.6

        \[\leadsto x + \color{blue}{t \cdot z} \]
    8. Applied rewrites72.6%

      \[\leadsto x + \color{blue}{t \cdot z} \]

    if -1.9000000000000001e75 < x < 6.5999999999999998e122

    1. Initial program 92.9%

      \[x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \color{blue}{\frac{x}{y}}\right) \]
    4. Step-by-step derivation
      1. lower-/.f6476.2

        \[\leadsto x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \color{blue}{\frac{x}{y}}\right) \]
    5. Applied rewrites76.2%

      \[\leadsto x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \color{blue}{\frac{x}{y}}\right) \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto x + \color{blue}{\left(y \cdot z\right)} \cdot \left(\tanh \left(\frac{t}{y}\right) - \frac{x}{y}\right) \]
      2. lift-/.f64N/A

        \[\leadsto x + \left(y \cdot z\right) \cdot \left(\tanh \color{blue}{\left(\frac{t}{y}\right)} - \frac{x}{y}\right) \]
      3. lift-tanh.f64N/A

        \[\leadsto x + \left(y \cdot z\right) \cdot \left(\color{blue}{\tanh \left(\frac{t}{y}\right)} - \frac{x}{y}\right) \]
      4. lift-/.f64N/A

        \[\leadsto x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \color{blue}{\frac{x}{y}}\right) \]
      5. lift--.f64N/A

        \[\leadsto x + \left(y \cdot z\right) \cdot \color{blue}{\left(\tanh \left(\frac{t}{y}\right) - \frac{x}{y}\right)} \]
      6. lift-*.f64N/A

        \[\leadsto x + \color{blue}{\left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \frac{x}{y}\right)} \]
      7. +-commutativeN/A

        \[\leadsto \color{blue}{\left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \frac{x}{y}\right) + x} \]
      8. lift-*.f64N/A

        \[\leadsto \color{blue}{\left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \frac{x}{y}\right)} + x \]
      9. *-commutativeN/A

        \[\leadsto \color{blue}{\left(\tanh \left(\frac{t}{y}\right) - \frac{x}{y}\right) \cdot \left(y \cdot z\right)} + x \]
      10. lift-*.f64N/A

        \[\leadsto \left(\tanh \left(\frac{t}{y}\right) - \frac{x}{y}\right) \cdot \color{blue}{\left(y \cdot z\right)} + x \]
      11. associate-*r*N/A

        \[\leadsto \color{blue}{\left(\left(\tanh \left(\frac{t}{y}\right) - \frac{x}{y}\right) \cdot y\right) \cdot z} + x \]
      12. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\left(\tanh \left(\frac{t}{y}\right) - \frac{x}{y}\right) \cdot y, z, x\right)} \]
      13. lower-*.f6480.4

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\tanh \left(\frac{t}{y}\right) - \frac{x}{y}\right) \cdot y}, z, x\right) \]
    7. Applied rewrites80.4%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\left(\tanh \left(\frac{t}{y}\right) - \frac{x}{y}\right) \cdot y, z, x\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification77.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.9 \cdot 10^{+75}:\\ \;\;\;\;x + z \cdot t\\ \mathbf{elif}\;x \leq 6.6 \cdot 10^{+122}:\\ \;\;\;\;\mathsf{fma}\left(y \cdot \left(\tanh \left(\frac{t}{y}\right) - \frac{x}{y}\right), z, x\right)\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot t\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 61.2% accurate, 14.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 2.5 \cdot 10^{+102}:\\ \;\;\;\;x + z \cdot t\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (<= y 2.5e+102) (+ x (* z t)) (fma z (- t x) x)))
double code(double x, double y, double z, double t) {
	double tmp;
	if (y <= 2.5e+102) {
		tmp = x + (z * t);
	} else {
		tmp = fma(z, (t - x), x);
	}
	return tmp;
}
function code(x, y, z, t)
	tmp = 0.0
	if (y <= 2.5e+102)
		tmp = Float64(x + Float64(z * t));
	else
		tmp = fma(z, Float64(t - x), x);
	end
	return tmp
end
code[x_, y_, z_, t_] := If[LessEqual[y, 2.5e+102], N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.5 \cdot 10^{+102}:\\
\;\;\;\;x + z \cdot t\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 2.5e102

    1. Initial program 97.3%

      \[x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \]
    2. Add Preprocessing
    3. Taylor expanded in y around inf

      \[\leadsto x + \left(y \cdot z\right) \cdot \color{blue}{\frac{t - x}{y}} \]
    4. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto x + \left(y \cdot z\right) \cdot \color{blue}{\frac{t - x}{y}} \]
      2. lower--.f6443.9

        \[\leadsto x + \left(y \cdot z\right) \cdot \frac{\color{blue}{t - x}}{y} \]
    5. Applied rewrites43.9%

      \[\leadsto x + \left(y \cdot z\right) \cdot \color{blue}{\frac{t - x}{y}} \]
    6. Taylor expanded in t around inf

      \[\leadsto x + \color{blue}{t \cdot z} \]
    7. Step-by-step derivation
      1. lower-*.f6460.1

        \[\leadsto x + \color{blue}{t \cdot z} \]
    8. Applied rewrites60.1%

      \[\leadsto x + \color{blue}{t \cdot z} \]

    if 2.5e102 < y

    1. Initial program 83.9%

      \[x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \]
    2. Add Preprocessing
    3. Taylor expanded in y around inf

      \[\leadsto \color{blue}{x + z \cdot \left(t - x\right)} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{z \cdot \left(t - x\right) + x} \]
      2. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(z, t - x, x\right)} \]
      3. lower--.f6485.9

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{t - x}, x\right) \]
    5. Applied rewrites85.9%

      \[\leadsto \color{blue}{\mathsf{fma}\left(z, t - x, x\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification63.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 2.5 \cdot 10^{+102}:\\ \;\;\;\;x + z \cdot t\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 19.4% accurate, 17.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 8 \cdot 10^{-21}:\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(-x\right)\\ \end{array} \end{array} \]
(FPCore (x y z t) :precision binary64 (if (<= x 8e-21) (* z t) (* z (- x))))
double code(double x, double y, double z, double t) {
	double tmp;
	if (x <= 8e-21) {
		tmp = z * t;
	} else {
		tmp = z * -x;
	}
	return tmp;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if (x <= 8d-21) then
        tmp = z * t
    else
        tmp = z * -x
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (x <= 8e-21) {
		tmp = z * t;
	} else {
		tmp = z * -x;
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if x <= 8e-21:
		tmp = z * t
	else:
		tmp = z * -x
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if (x <= 8e-21)
		tmp = Float64(z * t);
	else
		tmp = Float64(z * Float64(-x));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (x <= 8e-21)
		tmp = z * t;
	else
		tmp = z * -x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[LessEqual[x, 8e-21], N[(z * t), $MachinePrecision], N[(z * (-x)), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 8 \cdot 10^{-21}:\\
\;\;\;\;z \cdot t\\

\mathbf{else}:\\
\;\;\;\;z \cdot \left(-x\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 7.99999999999999926e-21

    1. Initial program 94.0%

      \[x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \]
    2. Add Preprocessing
    3. Taylor expanded in y around inf

      \[\leadsto \color{blue}{x + z \cdot \left(t - x\right)} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{z \cdot \left(t - x\right) + x} \]
      2. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(z, t - x, x\right)} \]
      3. lower--.f6461.7

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{t - x}, x\right) \]
    5. Applied rewrites61.7%

      \[\leadsto \color{blue}{\mathsf{fma}\left(z, t - x, x\right)} \]
    6. Taylor expanded in t around inf

      \[\leadsto \color{blue}{t \cdot z} \]
    7. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \color{blue}{z \cdot t} \]
      2. lower-*.f6421.2

        \[\leadsto \color{blue}{z \cdot t} \]
    8. Applied rewrites21.2%

      \[\leadsto \color{blue}{z \cdot t} \]

    if 7.99999999999999926e-21 < x

    1. Initial program 98.8%

      \[x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \]
    2. Add Preprocessing
    3. Taylor expanded in y around inf

      \[\leadsto \color{blue}{x + z \cdot \left(t - x\right)} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{z \cdot \left(t - x\right) + x} \]
      2. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(z, t - x, x\right)} \]
      3. lower--.f6456.7

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{t - x}, x\right) \]
    5. Applied rewrites56.7%

      \[\leadsto \color{blue}{\mathsf{fma}\left(z, t - x, x\right)} \]
    6. Taylor expanded in z around inf

      \[\leadsto \color{blue}{z \cdot \left(t - x\right)} \]
    7. Step-by-step derivation
      1. remove-double-negN/A

        \[\leadsto z \cdot \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(t - x\right)\right)\right)\right)\right)} \]
      2. mul-1-negN/A

        \[\leadsto z \cdot \left(\mathsf{neg}\left(\color{blue}{-1 \cdot \left(t - x\right)}\right)\right) \]
      3. distribute-lft-out--N/A

        \[\leadsto z \cdot \left(\mathsf{neg}\left(\color{blue}{\left(-1 \cdot t - -1 \cdot x\right)}\right)\right) \]
      4. mul-1-negN/A

        \[\leadsto z \cdot \color{blue}{\left(-1 \cdot \left(-1 \cdot t - -1 \cdot x\right)\right)} \]
      5. lower-*.f64N/A

        \[\leadsto \color{blue}{z \cdot \left(-1 \cdot \left(-1 \cdot t - -1 \cdot x\right)\right)} \]
      6. mul-1-negN/A

        \[\leadsto z \cdot \color{blue}{\left(\mathsf{neg}\left(\left(-1 \cdot t - -1 \cdot x\right)\right)\right)} \]
      7. distribute-lft-out--N/A

        \[\leadsto z \cdot \left(\mathsf{neg}\left(\color{blue}{-1 \cdot \left(t - x\right)}\right)\right) \]
      8. mul-1-negN/A

        \[\leadsto z \cdot \left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\left(t - x\right)\right)\right)}\right)\right) \]
      9. remove-double-negN/A

        \[\leadsto z \cdot \color{blue}{\left(t - x\right)} \]
      10. lower--.f6413.8

        \[\leadsto z \cdot \color{blue}{\left(t - x\right)} \]
    8. Applied rewrites13.8%

      \[\leadsto \color{blue}{z \cdot \left(t - x\right)} \]
    9. Taylor expanded in t around 0

      \[\leadsto \color{blue}{-1 \cdot \left(x \cdot z\right)} \]
    10. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \color{blue}{\left(-1 \cdot x\right) \cdot z} \]
      2. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(-1 \cdot x\right) \cdot z} \]
      3. mul-1-negN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot z \]
      4. lower-neg.f6413.8

        \[\leadsto \color{blue}{\left(-x\right)} \cdot z \]
    11. Applied rewrites13.8%

      \[\leadsto \color{blue}{\left(-x\right) \cdot z} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification19.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 8 \cdot 10^{-21}:\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(-x\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 26.9% accurate, 26.6× speedup?

\[\begin{array}{l} \\ z \cdot \left(t - x\right) \end{array} \]
(FPCore (x y z t) :precision binary64 (* z (- t x)))
double code(double x, double y, double z, double t) {
	return z * (t - x);
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = z * (t - x)
end function
public static double code(double x, double y, double z, double t) {
	return z * (t - x);
}
def code(x, y, z, t):
	return z * (t - x)
function code(x, y, z, t)
	return Float64(z * Float64(t - x))
end
function tmp = code(x, y, z, t)
	tmp = z * (t - x);
end
code[x_, y_, z_, t_] := N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
z \cdot \left(t - x\right)
\end{array}
Derivation
  1. Initial program 95.4%

    \[x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \]
  2. Add Preprocessing
  3. Taylor expanded in y around inf

    \[\leadsto \color{blue}{x + z \cdot \left(t - x\right)} \]
  4. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto \color{blue}{z \cdot \left(t - x\right) + x} \]
    2. lower-fma.f64N/A

      \[\leadsto \color{blue}{\mathsf{fma}\left(z, t - x, x\right)} \]
    3. lower--.f6460.2

      \[\leadsto \mathsf{fma}\left(z, \color{blue}{t - x}, x\right) \]
  5. Applied rewrites60.2%

    \[\leadsto \color{blue}{\mathsf{fma}\left(z, t - x, x\right)} \]
  6. Taylor expanded in z around inf

    \[\leadsto \color{blue}{z \cdot \left(t - x\right)} \]
  7. Step-by-step derivation
    1. remove-double-negN/A

      \[\leadsto z \cdot \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(t - x\right)\right)\right)\right)\right)} \]
    2. mul-1-negN/A

      \[\leadsto z \cdot \left(\mathsf{neg}\left(\color{blue}{-1 \cdot \left(t - x\right)}\right)\right) \]
    3. distribute-lft-out--N/A

      \[\leadsto z \cdot \left(\mathsf{neg}\left(\color{blue}{\left(-1 \cdot t - -1 \cdot x\right)}\right)\right) \]
    4. mul-1-negN/A

      \[\leadsto z \cdot \color{blue}{\left(-1 \cdot \left(-1 \cdot t - -1 \cdot x\right)\right)} \]
    5. lower-*.f64N/A

      \[\leadsto \color{blue}{z \cdot \left(-1 \cdot \left(-1 \cdot t - -1 \cdot x\right)\right)} \]
    6. mul-1-negN/A

      \[\leadsto z \cdot \color{blue}{\left(\mathsf{neg}\left(\left(-1 \cdot t - -1 \cdot x\right)\right)\right)} \]
    7. distribute-lft-out--N/A

      \[\leadsto z \cdot \left(\mathsf{neg}\left(\color{blue}{-1 \cdot \left(t - x\right)}\right)\right) \]
    8. mul-1-negN/A

      \[\leadsto z \cdot \left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\left(t - x\right)\right)\right)}\right)\right) \]
    9. remove-double-negN/A

      \[\leadsto z \cdot \color{blue}{\left(t - x\right)} \]
    10. lower--.f6422.0

      \[\leadsto z \cdot \color{blue}{\left(t - x\right)} \]
  8. Applied rewrites22.0%

    \[\leadsto \color{blue}{z \cdot \left(t - x\right)} \]
  9. Add Preprocessing

Alternative 9: 17.4% accurate, 39.8× speedup?

\[\begin{array}{l} \\ z \cdot t \end{array} \]
(FPCore (x y z t) :precision binary64 (* z t))
double code(double x, double y, double z, double t) {
	return z * t;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = z * t
end function
public static double code(double x, double y, double z, double t) {
	return z * t;
}
def code(x, y, z, t):
	return z * t
function code(x, y, z, t)
	return Float64(z * t)
end
function tmp = code(x, y, z, t)
	tmp = z * t;
end
code[x_, y_, z_, t_] := N[(z * t), $MachinePrecision]
\begin{array}{l}

\\
z \cdot t
\end{array}
Derivation
  1. Initial program 95.4%

    \[x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \]
  2. Add Preprocessing
  3. Taylor expanded in y around inf

    \[\leadsto \color{blue}{x + z \cdot \left(t - x\right)} \]
  4. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto \color{blue}{z \cdot \left(t - x\right) + x} \]
    2. lower-fma.f64N/A

      \[\leadsto \color{blue}{\mathsf{fma}\left(z, t - x, x\right)} \]
    3. lower--.f6460.2

      \[\leadsto \mathsf{fma}\left(z, \color{blue}{t - x}, x\right) \]
  5. Applied rewrites60.2%

    \[\leadsto \color{blue}{\mathsf{fma}\left(z, t - x, x\right)} \]
  6. Taylor expanded in t around inf

    \[\leadsto \color{blue}{t \cdot z} \]
  7. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto \color{blue}{z \cdot t} \]
    2. lower-*.f6416.0

      \[\leadsto \color{blue}{z \cdot t} \]
  8. Applied rewrites16.0%

    \[\leadsto \color{blue}{z \cdot t} \]
  9. Add Preprocessing

Developer Target 1: 97.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ x + y \cdot \left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right) \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (+ x (* y (* z (- (tanh (/ t y)) (tanh (/ x y)))))))
double code(double x, double y, double z, double t) {
	return x + (y * (z * (tanh((t / y)) - tanh((x / y)))));
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = x + (y * (z * (tanh((t / y)) - tanh((x / y)))))
end function
public static double code(double x, double y, double z, double t) {
	return x + (y * (z * (Math.tanh((t / y)) - Math.tanh((x / y)))));
}
def code(x, y, z, t):
	return x + (y * (z * (math.tanh((t / y)) - math.tanh((x / y)))))
function code(x, y, z, t)
	return Float64(x + Float64(y * Float64(z * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y))))))
end
function tmp = code(x, y, z, t)
	tmp = x + (y * (z * (tanh((t / y)) - tanh((x / y)))));
end
code[x_, y_, z_, t_] := N[(x + N[(y * N[(z * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x + y \cdot \left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right)
\end{array}

Reproduce

?
herbie shell --seed 2024216 
(FPCore (x y z t)
  :name "SynthBasics:moogVCF from YampaSynth-0.2"
  :precision binary64

  :alt
  (! :herbie-platform default (+ x (* y (* z (- (tanh (/ t y)) (tanh (/ x y)))))))

  (+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))