SynthBasics:moogVCF from YampaSynth-0.2

Percentage Accurate: 93.1% → 95.4%
Time: 11.2s
Alternatives: 10
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 10 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.1% 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: 95.4% accurate, 1.0× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;y\_m \leq 3.6 \cdot 10^{+114}:\\ \;\;\;\;x + \left(y\_m \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y\_m}\right) - \tanh \left(\frac{x}{y\_m}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z t)
 :precision binary64
 (if (<= y_m 3.6e+114)
   (+ x (* (* y_m z) (- (tanh (/ t y_m)) (tanh (/ x y_m)))))
   (fma z (- t x) x)))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
	double tmp;
	if (y_m <= 3.6e+114) {
		tmp = x + ((y_m * z) * (tanh((t / y_m)) - tanh((x / y_m))));
	} else {
		tmp = fma(z, (t - x), x);
	}
	return tmp;
}
y_m = abs(y)
function code(x, y_m, z, t)
	tmp = 0.0
	if (y_m <= 3.6e+114)
		tmp = Float64(x + Float64(Float64(y_m * z) * Float64(tanh(Float64(t / y_m)) - tanh(Float64(x / y_m)))));
	else
		tmp = fma(z, Float64(t - x), x);
	end
	return tmp
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_, t_] := If[LessEqual[y$95$m, 3.6e+114], N[(x + N[(N[(y$95$m * z), $MachinePrecision] * N[(N[Tanh[N[(t / y$95$m), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 3.6 \cdot 10^{+114}:\\
\;\;\;\;x + \left(y\_m \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y\_m}\right) - \tanh \left(\frac{x}{y\_m}\right)\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 < 3.6000000000000001e114

    1. Initial program 96.5%

      \[x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \]
    2. Add Preprocessing

    if 3.6000000000000001e114 < y

    1. Initial program 80.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--.f6497.0

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

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

Alternative 2: 68.3% accurate, 0.2× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} t_1 := \tanh \left(\frac{x}{y\_m}\right)\\ t_2 := x + \left(y\_m \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y\_m}\right) - t\_1\right)\\ t_3 := x + \left(y\_m \cdot z\right) \cdot \left(\frac{t}{y\_m} - t\_1\right)\\ \mathbf{if}\;t\_2 \leq -\infty:\\ \;\;\;\;z \cdot \left(t - x\right)\\ \mathbf{elif}\;t\_2 \leq -5 \cdot 10^{-46}:\\ \;\;\;\;t\_3\\ \mathbf{elif}\;t\_2 \leq 5 \cdot 10^{-129}:\\ \;\;\;\;\mathsf{fma}\left(z, -x, x\right)\\ \mathbf{elif}\;t\_2 \leq 4 \cdot 10^{+270}:\\ \;\;\;\;t\_3\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z t)
 :precision binary64
 (let* ((t_1 (tanh (/ x y_m)))
        (t_2 (+ x (* (* y_m z) (- (tanh (/ t y_m)) t_1))))
        (t_3 (+ x (* (* y_m z) (- (/ t y_m) t_1)))))
   (if (<= t_2 (- INFINITY))
     (* z (- t x))
     (if (<= t_2 -5e-46)
       t_3
       (if (<= t_2 5e-129)
         (fma z (- x) x)
         (if (<= t_2 4e+270) t_3 (fma z (- t x) x)))))))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
	double t_1 = tanh((x / y_m));
	double t_2 = x + ((y_m * z) * (tanh((t / y_m)) - t_1));
	double t_3 = x + ((y_m * z) * ((t / y_m) - t_1));
	double tmp;
	if (t_2 <= -((double) INFINITY)) {
		tmp = z * (t - x);
	} else if (t_2 <= -5e-46) {
		tmp = t_3;
	} else if (t_2 <= 5e-129) {
		tmp = fma(z, -x, x);
	} else if (t_2 <= 4e+270) {
		tmp = t_3;
	} else {
		tmp = fma(z, (t - x), x);
	}
	return tmp;
}
y_m = abs(y)
function code(x, y_m, z, t)
	t_1 = tanh(Float64(x / y_m))
	t_2 = Float64(x + Float64(Float64(y_m * z) * Float64(tanh(Float64(t / y_m)) - t_1)))
	t_3 = Float64(x + Float64(Float64(y_m * z) * Float64(Float64(t / y_m) - t_1)))
	tmp = 0.0
	if (t_2 <= Float64(-Inf))
		tmp = Float64(z * Float64(t - x));
	elseif (t_2 <= -5e-46)
		tmp = t_3;
	elseif (t_2 <= 5e-129)
		tmp = fma(z, Float64(-x), x);
	elseif (t_2 <= 4e+270)
		tmp = t_3;
	else
		tmp = fma(z, Float64(t - x), x);
	end
	return tmp
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_, t_] := Block[{t$95$1 = N[Tanh[N[(x / y$95$m), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(x + N[(N[(y$95$m * z), $MachinePrecision] * N[(N[Tanh[N[(t / y$95$m), $MachinePrecision]], $MachinePrecision] - t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(x + N[(N[(y$95$m * z), $MachinePrecision] * N[(N[(t / y$95$m), $MachinePrecision] - t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, -5e-46], t$95$3, If[LessEqual[t$95$2, 5e-129], N[(z * (-x) + x), $MachinePrecision], If[LessEqual[t$95$2, 4e+270], t$95$3, N[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]]]]]]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
t_1 := \tanh \left(\frac{x}{y\_m}\right)\\
t_2 := x + \left(y\_m \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y\_m}\right) - t\_1\right)\\
t_3 := x + \left(y\_m \cdot z\right) \cdot \left(\frac{t}{y\_m} - t\_1\right)\\
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;z \cdot \left(t - x\right)\\

\mathbf{elif}\;t\_2 \leq -5 \cdot 10^{-46}:\\
\;\;\;\;t\_3\\

\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{-129}:\\
\;\;\;\;\mathsf{fma}\left(z, -x, x\right)\\

\mathbf{elif}\;t\_2 \leq 4 \cdot 10^{+270}:\\
\;\;\;\;t\_3\\

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


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

    1. Initial program 49.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. Simplified100.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. lower-*.f64N/A

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

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

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

    if -inf.0 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < -4.99999999999999992e-46 or 5.00000000000000027e-129 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 4.0000000000000002e270

    1. Initial program 99.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 t around 0

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

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

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

    if -4.99999999999999992e-46 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 5.00000000000000027e-129

    1. Initial program 98.5%

      \[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--.f6454.3

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

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

      \[\leadsto \mathsf{fma}\left(z, \color{blue}{-1 \cdot x}, x\right) \]
    7. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{\mathsf{neg}\left(x\right)}, x\right) \]
      2. lower-neg.f6474.5

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{-x}, x\right) \]
    8. Simplified74.5%

      \[\leadsto \mathsf{fma}\left(z, \color{blue}{-x}, x\right) \]

    if 4.0000000000000002e270 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y)))))

    1. Initial program 66.5%

      \[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. Simplified100.0%

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

Alternative 3: 64.3% accurate, 0.2× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} t_1 := z \cdot \left(t - x\right)\\ t_2 := x + \left(y\_m \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y\_m}\right) - \tanh \left(\frac{x}{y\_m}\right)\right)\\ \mathbf{if}\;t\_2 \leq -5 \cdot 10^{+302}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_2 \leq -5 \cdot 10^{+142}:\\ \;\;\;\;\mathsf{fma}\left(t, z, x\right)\\ \mathbf{elif}\;t\_2 \leq 2 \cdot 10^{-7}:\\ \;\;\;\;\mathsf{fma}\left(z, -x, x\right)\\ \mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+305}:\\ \;\;\;\;\mathsf{fma}\left(t, z, x\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z t)
 :precision binary64
 (let* ((t_1 (* z (- t x)))
        (t_2 (+ x (* (* y_m z) (- (tanh (/ t y_m)) (tanh (/ x y_m)))))))
   (if (<= t_2 -5e+302)
     t_1
     (if (<= t_2 -5e+142)
       (fma t z x)
       (if (<= t_2 2e-7)
         (fma z (- x) x)
         (if (<= t_2 5e+305) (fma t z x) t_1))))))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
	double t_1 = z * (t - x);
	double t_2 = x + ((y_m * z) * (tanh((t / y_m)) - tanh((x / y_m))));
	double tmp;
	if (t_2 <= -5e+302) {
		tmp = t_1;
	} else if (t_2 <= -5e+142) {
		tmp = fma(t, z, x);
	} else if (t_2 <= 2e-7) {
		tmp = fma(z, -x, x);
	} else if (t_2 <= 5e+305) {
		tmp = fma(t, z, x);
	} else {
		tmp = t_1;
	}
	return tmp;
}
y_m = abs(y)
function code(x, y_m, z, t)
	t_1 = Float64(z * Float64(t - x))
	t_2 = Float64(x + Float64(Float64(y_m * z) * Float64(tanh(Float64(t / y_m)) - tanh(Float64(x / y_m)))))
	tmp = 0.0
	if (t_2 <= -5e+302)
		tmp = t_1;
	elseif (t_2 <= -5e+142)
		tmp = fma(t, z, x);
	elseif (t_2 <= 2e-7)
		tmp = fma(z, Float64(-x), x);
	elseif (t_2 <= 5e+305)
		tmp = fma(t, z, x);
	else
		tmp = t_1;
	end
	return tmp
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_, t_] := Block[{t$95$1 = N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x + N[(N[(y$95$m * z), $MachinePrecision] * N[(N[Tanh[N[(t / y$95$m), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -5e+302], t$95$1, If[LessEqual[t$95$2, -5e+142], N[(t * z + x), $MachinePrecision], If[LessEqual[t$95$2, 2e-7], N[(z * (-x) + x), $MachinePrecision], If[LessEqual[t$95$2, 5e+305], N[(t * z + x), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
t_1 := z \cdot \left(t - x\right)\\
t_2 := x + \left(y\_m \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y\_m}\right) - \tanh \left(\frac{x}{y\_m}\right)\right)\\
\mathbf{if}\;t\_2 \leq -5 \cdot 10^{+302}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_2 \leq -5 \cdot 10^{+142}:\\
\;\;\;\;\mathsf{fma}\left(t, z, x\right)\\

\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{-7}:\\
\;\;\;\;\mathsf{fma}\left(z, -x, x\right)\\

\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+305}:\\
\;\;\;\;\mathsf{fma}\left(t, z, x\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < -5e302 or 5.00000000000000009e305 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y)))))

    1. Initial program 55.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--.f6497.1

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

      \[\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. lower-*.f64N/A

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

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

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

    if -5e302 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < -5.0000000000000001e142 or 1.9999999999999999e-7 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 5.00000000000000009e305

    1. Initial program 99.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 t around 0

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

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

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

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

        \[\leadsto \color{blue}{t \cdot z + x} \]
      2. lower-fma.f6464.3

        \[\leadsto \color{blue}{\mathsf{fma}\left(t, z, x\right)} \]
    8. Simplified64.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left(t, z, x\right)} \]

    if -5.0000000000000001e142 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 1.9999999999999999e-7

    1. Initial program 99.2%

      \[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--.f6454.8

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

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

      \[\leadsto \mathsf{fma}\left(z, \color{blue}{-1 \cdot x}, x\right) \]
    7. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{\mathsf{neg}\left(x\right)}, x\right) \]
      2. lower-neg.f6463.8

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{-x}, x\right) \]
    8. Simplified63.8%

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

Alternative 4: 62.8% accurate, 0.5× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} t_1 := z \cdot \left(t - x\right)\\ t_2 := x + \left(y\_m \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y\_m}\right) - \tanh \left(\frac{x}{y\_m}\right)\right)\\ \mathbf{if}\;t\_2 \leq -5 \cdot 10^{+302}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+305}:\\ \;\;\;\;x + z \cdot t\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z t)
 :precision binary64
 (let* ((t_1 (* z (- t x)))
        (t_2 (+ x (* (* y_m z) (- (tanh (/ t y_m)) (tanh (/ x y_m)))))))
   (if (<= t_2 -5e+302) t_1 (if (<= t_2 5e+305) (+ x (* z t)) t_1))))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
	double t_1 = z * (t - x);
	double t_2 = x + ((y_m * z) * (tanh((t / y_m)) - tanh((x / y_m))));
	double tmp;
	if (t_2 <= -5e+302) {
		tmp = t_1;
	} else if (t_2 <= 5e+305) {
		tmp = x + (z * t);
	} else {
		tmp = t_1;
	}
	return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_1 = z * (t - x)
    t_2 = x + ((y_m * z) * (tanh((t / y_m)) - tanh((x / y_m))))
    if (t_2 <= (-5d+302)) then
        tmp = t_1
    else if (t_2 <= 5d+305) then
        tmp = x + (z * t)
    else
        tmp = t_1
    end if
    code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z, double t) {
	double t_1 = z * (t - x);
	double t_2 = x + ((y_m * z) * (Math.tanh((t / y_m)) - Math.tanh((x / y_m))));
	double tmp;
	if (t_2 <= -5e+302) {
		tmp = t_1;
	} else if (t_2 <= 5e+305) {
		tmp = x + (z * t);
	} else {
		tmp = t_1;
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z, t):
	t_1 = z * (t - x)
	t_2 = x + ((y_m * z) * (math.tanh((t / y_m)) - math.tanh((x / y_m))))
	tmp = 0
	if t_2 <= -5e+302:
		tmp = t_1
	elif t_2 <= 5e+305:
		tmp = x + (z * t)
	else:
		tmp = t_1
	return tmp
y_m = abs(y)
function code(x, y_m, z, t)
	t_1 = Float64(z * Float64(t - x))
	t_2 = Float64(x + Float64(Float64(y_m * z) * Float64(tanh(Float64(t / y_m)) - tanh(Float64(x / y_m)))))
	tmp = 0.0
	if (t_2 <= -5e+302)
		tmp = t_1;
	elseif (t_2 <= 5e+305)
		tmp = Float64(x + Float64(z * t));
	else
		tmp = t_1;
	end
	return tmp
end
y_m = abs(y);
function tmp_2 = code(x, y_m, z, t)
	t_1 = z * (t - x);
	t_2 = x + ((y_m * z) * (tanh((t / y_m)) - tanh((x / y_m))));
	tmp = 0.0;
	if (t_2 <= -5e+302)
		tmp = t_1;
	elseif (t_2 <= 5e+305)
		tmp = x + (z * t);
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_, t_] := Block[{t$95$1 = N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x + N[(N[(y$95$m * z), $MachinePrecision] * N[(N[Tanh[N[(t / y$95$m), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -5e+302], t$95$1, If[LessEqual[t$95$2, 5e+305], N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
t_1 := z \cdot \left(t - x\right)\\
t_2 := x + \left(y\_m \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y\_m}\right) - \tanh \left(\frac{x}{y\_m}\right)\right)\\
\mathbf{if}\;t\_2 \leq -5 \cdot 10^{+302}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+305}:\\
\;\;\;\;x + z \cdot t\\

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


\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))))) < -5e302 or 5.00000000000000009e305 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y)))))

    1. Initial program 55.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--.f6497.1

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

      \[\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. lower-*.f64N/A

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

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

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

    if -5e302 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 5.00000000000000009e305

    1. Initial program 99.5%

      \[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 t around 0

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

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

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

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

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

      \[\leadsto x + \color{blue}{t \cdot z} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification60.2%

    \[\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^{+302}:\\ \;\;\;\;z \cdot \left(t - x\right)\\ \mathbf{elif}\;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^{+305}:\\ \;\;\;\;x + z \cdot t\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(t - x\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 62.8% accurate, 0.5× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} t_1 := z \cdot \left(t - x\right)\\ t_2 := x + \left(y\_m \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y\_m}\right) - \tanh \left(\frac{x}{y\_m}\right)\right)\\ \mathbf{if}\;t\_2 \leq -5 \cdot 10^{+302}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+305}:\\ \;\;\;\;\mathsf{fma}\left(t, z, x\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z t)
 :precision binary64
 (let* ((t_1 (* z (- t x)))
        (t_2 (+ x (* (* y_m z) (- (tanh (/ t y_m)) (tanh (/ x y_m)))))))
   (if (<= t_2 -5e+302) t_1 (if (<= t_2 5e+305) (fma t z x) t_1))))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
	double t_1 = z * (t - x);
	double t_2 = x + ((y_m * z) * (tanh((t / y_m)) - tanh((x / y_m))));
	double tmp;
	if (t_2 <= -5e+302) {
		tmp = t_1;
	} else if (t_2 <= 5e+305) {
		tmp = fma(t, z, x);
	} else {
		tmp = t_1;
	}
	return tmp;
}
y_m = abs(y)
function code(x, y_m, z, t)
	t_1 = Float64(z * Float64(t - x))
	t_2 = Float64(x + Float64(Float64(y_m * z) * Float64(tanh(Float64(t / y_m)) - tanh(Float64(x / y_m)))))
	tmp = 0.0
	if (t_2 <= -5e+302)
		tmp = t_1;
	elseif (t_2 <= 5e+305)
		tmp = fma(t, z, x);
	else
		tmp = t_1;
	end
	return tmp
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_, t_] := Block[{t$95$1 = N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x + N[(N[(y$95$m * z), $MachinePrecision] * N[(N[Tanh[N[(t / y$95$m), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -5e+302], t$95$1, If[LessEqual[t$95$2, 5e+305], N[(t * z + x), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
t_1 := z \cdot \left(t - x\right)\\
t_2 := x + \left(y\_m \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y\_m}\right) - \tanh \left(\frac{x}{y\_m}\right)\right)\\
\mathbf{if}\;t\_2 \leq -5 \cdot 10^{+302}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+305}:\\
\;\;\;\;\mathsf{fma}\left(t, z, x\right)\\

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


\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))))) < -5e302 or 5.00000000000000009e305 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y)))))

    1. Initial program 55.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--.f6497.1

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

      \[\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. lower-*.f64N/A

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

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

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

    if -5e302 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 5.00000000000000009e305

    1. Initial program 99.5%

      \[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 t around 0

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

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

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

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

        \[\leadsto \color{blue}{t \cdot z + x} \]
      2. lower-fma.f6455.4

        \[\leadsto \color{blue}{\mathsf{fma}\left(t, z, x\right)} \]
    8. Simplified55.4%

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

Alternative 6: 57.6% accurate, 0.9× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x + \left(y\_m \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y\_m}\right) - \tanh \left(\frac{x}{y\_m}\right)\right) \leq 5 \cdot 10^{+305}:\\ \;\;\;\;\mathsf{fma}\left(t, z, x\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(-x\right)\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z t)
 :precision binary64
 (if (<= (+ x (* (* y_m z) (- (tanh (/ t y_m)) (tanh (/ x y_m))))) 5e+305)
   (fma t z x)
   (* z (- x))))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
	double tmp;
	if ((x + ((y_m * z) * (tanh((t / y_m)) - tanh((x / y_m))))) <= 5e+305) {
		tmp = fma(t, z, x);
	} else {
		tmp = z * -x;
	}
	return tmp;
}
y_m = abs(y)
function code(x, y_m, z, t)
	tmp = 0.0
	if (Float64(x + Float64(Float64(y_m * z) * Float64(tanh(Float64(t / y_m)) - tanh(Float64(x / y_m))))) <= 5e+305)
		tmp = fma(t, z, x);
	else
		tmp = Float64(z * Float64(-x));
	end
	return tmp
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_, t_] := If[LessEqual[N[(x + N[(N[(y$95$m * z), $MachinePrecision] * N[(N[Tanh[N[(t / y$95$m), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 5e+305], N[(t * z + x), $MachinePrecision], N[(z * (-x)), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|

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

\mathbf{else}:\\
\;\;\;\;z \cdot \left(-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))))) < 5.00000000000000009e305

    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. Taylor expanded in t around 0

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

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

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

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

        \[\leadsto \color{blue}{t \cdot z + x} \]
      2. lower-fma.f6455.1

        \[\leadsto \color{blue}{\mathsf{fma}\left(t, z, x\right)} \]
    8. Simplified55.1%

      \[\leadsto \color{blue}{\mathsf{fma}\left(t, z, x\right)} \]

    if 5.00000000000000009e305 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y)))))

    1. Initial program 58.1%

      \[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. Simplified100.0%

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

      \[\leadsto \mathsf{fma}\left(z, \color{blue}{-1 \cdot x}, x\right) \]
    7. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{\mathsf{neg}\left(x\right)}, x\right) \]
      2. lower-neg.f6473.7

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{-x}, x\right) \]
    8. Simplified73.7%

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

      \[\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.f6473.7

        \[\leadsto \color{blue}{\left(-x\right)} \cdot z \]
    11. Simplified73.7%

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

    \[\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^{+305}:\\ \;\;\;\;\mathsf{fma}\left(t, z, x\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(-x\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 64.4% accurate, 13.3× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;y\_m \leq 5 \cdot 10^{-27}:\\ \;\;\;\;\mathsf{fma}\left(z, -x, x\right)\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \left(t - x\right)\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z t)
 :precision binary64
 (if (<= y_m 5e-27) (fma z (- x) x) (+ x (* z (- t x)))))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
	double tmp;
	if (y_m <= 5e-27) {
		tmp = fma(z, -x, x);
	} else {
		tmp = x + (z * (t - x));
	}
	return tmp;
}
y_m = abs(y)
function code(x, y_m, z, t)
	tmp = 0.0
	if (y_m <= 5e-27)
		tmp = fma(z, Float64(-x), x);
	else
		tmp = Float64(x + Float64(z * Float64(t - x)));
	end
	return tmp
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_, t_] := If[LessEqual[y$95$m, 5e-27], N[(z * (-x) + x), $MachinePrecision], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 5 \cdot 10^{-27}:\\
\;\;\;\;\mathsf{fma}\left(z, -x, x\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 5.0000000000000002e-27

    1. Initial program 96.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--.f6448.5

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

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

      \[\leadsto \mathsf{fma}\left(z, \color{blue}{-1 \cdot x}, x\right) \]
    7. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{\mathsf{neg}\left(x\right)}, x\right) \]
      2. lower-neg.f6450.8

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{-x}, x\right) \]
    8. Simplified50.8%

      \[\leadsto \mathsf{fma}\left(z, \color{blue}{-x}, x\right) \]

    if 5.0000000000000002e-27 < y

    1. Initial program 88.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 x + \color{blue}{z \cdot \left(t - x\right)} \]
    4. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto x + \color{blue}{z \cdot \left(t - x\right)} \]
      2. lower--.f6483.6

        \[\leadsto x + z \cdot \color{blue}{\left(t - x\right)} \]
    5. Simplified83.6%

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

Alternative 8: 64.4% accurate, 14.9× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;y\_m \leq 5 \cdot 10^{-27}:\\ \;\;\;\;\mathsf{fma}\left(z, -x, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z t)
 :precision binary64
 (if (<= y_m 5e-27) (fma z (- x) x) (fma z (- t x) x)))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
	double tmp;
	if (y_m <= 5e-27) {
		tmp = fma(z, -x, x);
	} else {
		tmp = fma(z, (t - x), x);
	}
	return tmp;
}
y_m = abs(y)
function code(x, y_m, z, t)
	tmp = 0.0
	if (y_m <= 5e-27)
		tmp = fma(z, Float64(-x), x);
	else
		tmp = fma(z, Float64(t - x), x);
	end
	return tmp
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_, t_] := If[LessEqual[y$95$m, 5e-27], N[(z * (-x) + x), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 5 \cdot 10^{-27}:\\
\;\;\;\;\mathsf{fma}\left(z, -x, 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 < 5.0000000000000002e-27

    1. Initial program 96.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--.f6448.5

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

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

      \[\leadsto \mathsf{fma}\left(z, \color{blue}{-1 \cdot x}, x\right) \]
    7. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{\mathsf{neg}\left(x\right)}, x\right) \]
      2. lower-neg.f6450.8

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{-x}, x\right) \]
    8. Simplified50.8%

      \[\leadsto \mathsf{fma}\left(z, \color{blue}{-x}, x\right) \]

    if 5.0000000000000002e-27 < y

    1. Initial program 88.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--.f6483.6

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

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

Alternative 9: 57.6% accurate, 34.1× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \mathsf{fma}\left(t, z, x\right) \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z t) :precision binary64 (fma t z x))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
	return fma(t, z, x);
}
y_m = abs(y)
function code(x, y_m, z, t)
	return fma(t, z, x)
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_, t_] := N[(t * z + x), $MachinePrecision]
\begin{array}{l}
y_m = \left|y\right|

\\
\mathsf{fma}\left(t, z, x\right)
\end{array}
Derivation
  1. Initial program 94.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 t around 0

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

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

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

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

      \[\leadsto \color{blue}{t \cdot z + x} \]
    2. lower-fma.f6453.4

      \[\leadsto \color{blue}{\mathsf{fma}\left(t, z, x\right)} \]
  8. Simplified53.4%

    \[\leadsto \color{blue}{\mathsf{fma}\left(t, z, x\right)} \]
  9. Add Preprocessing

Alternative 10: 16.9% accurate, 39.8× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ z \cdot t \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z t) :precision binary64 (* z t))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
	return z * t;
}
y_m = abs(y)
real(8) function code(x, y_m, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = z * t
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z, double t) {
	return z * t;
}
y_m = math.fabs(y)
def code(x, y_m, z, t):
	return z * t
y_m = abs(y)
function code(x, y_m, z, t)
	return Float64(z * t)
end
y_m = abs(y);
function tmp = code(x, y_m, z, t)
	tmp = z * t;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_, t_] := N[(z * t), $MachinePrecision]
\begin{array}{l}
y_m = \left|y\right|

\\
z \cdot t
\end{array}
Derivation
  1. Initial program 94.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 t around 0

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

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

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

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

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

    \[\leadsto \color{blue}{t \cdot z} \]
  9. Final simplification14.2%

    \[\leadsto z \cdot t \]
  10. Add Preprocessing

Developer Target 1: 97.1% 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 2024215 
(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))))))