SynthBasics:moogVCF from YampaSynth-0.2

Percentage Accurate: 93.0% → 98.2%
Time: 11.5s
Alternatives: 12
Speedup: 0.4×

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 12 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.0% 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.2% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\\ \mathbf{if}\;t\_1 \leq -\infty \lor \neg \left(t\_1 \leq 5 \cdot 10^{+304}\right):\\ \;\;\;\;z \cdot \left(t - x\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y)))))))
   (if (or (<= t_1 (- INFINITY)) (not (<= t_1 5e+304))) (* z (- t x)) t_1)))
double code(double x, double y, double z, double t) {
	double t_1 = x + ((y * z) * (tanh((t / y)) - tanh((x / y))));
	double tmp;
	if ((t_1 <= -((double) INFINITY)) || !(t_1 <= 5e+304)) {
		tmp = z * (t - x);
	} else {
		tmp = t_1;
	}
	return tmp;
}
public static double code(double x, double y, double z, double t) {
	double t_1 = x + ((y * z) * (Math.tanh((t / y)) - Math.tanh((x / y))));
	double tmp;
	if ((t_1 <= -Double.POSITIVE_INFINITY) || !(t_1 <= 5e+304)) {
		tmp = z * (t - x);
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = x + ((y * z) * (math.tanh((t / y)) - math.tanh((x / y))))
	tmp = 0
	if (t_1 <= -math.inf) or not (t_1 <= 5e+304):
		tmp = z * (t - x)
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t)
	t_1 = Float64(x + Float64(Float64(y * z) * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))))
	tmp = 0.0
	if ((t_1 <= Float64(-Inf)) || !(t_1 <= 5e+304))
		tmp = Float64(z * Float64(t - x));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = x + ((y * z) * (tanh((t / y)) - tanh((x / y))));
	tmp = 0.0;
	if ((t_1 <= -Inf) || ~((t_1 <= 5e+304)))
		tmp = z * (t - x);
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = 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]}, If[Or[LessEqual[t$95$1, (-Infinity)], N[Not[LessEqual[t$95$1, 5e+304]], $MachinePrecision]], N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision], t$95$1]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\\
\mathbf{if}\;t\_1 \leq -\infty \lor \neg \left(t\_1 \leq 5 \cdot 10^{+304}\right):\\
\;\;\;\;z \cdot \left(t - 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))))) < -inf.0 or 4.9999999999999997e304 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y)))))

    1. Initial program 44.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 100.0%

      \[\leadsto x + \color{blue}{z \cdot \left(t - x\right)} \]
    4. Taylor expanded in z around inf 100.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.9999999999999997e304

    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. Recombined 2 regimes into one program.
  4. Final simplification99.9%

    \[\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 -\infty \lor \neg \left(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^{+304}\right):\\ \;\;\;\;z \cdot \left(t - x\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 97.5% accurate, 0.4× 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^{+304}:\\ \;\;\;\;\mathsf{fma}\left(y, z \cdot t\_1, 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+304) (fma y (* z t_1) 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+304) {
		tmp = fma(y, (z * t_1), 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+304)
		tmp = fma(y, Float64(z * t_1), 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+304], N[(y * N[(z * t$95$1), $MachinePrecision] + 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^{+304}:\\
\;\;\;\;\mathsf{fma}\left(y, z \cdot t\_1, 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.9999999999999997e304

    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. Step-by-step derivation
      1. +-commutative96.8%

        \[\leadsto \color{blue}{\left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) + x} \]
      2. associate-*l*99.9%

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

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

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

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

    1. Initial program 46.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 100.0%

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

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

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

Alternative 3: 82.6% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
t_1 := z \cdot \tanh \left(\frac{t}{y}\right)\\
\mathbf{if}\;y \leq 6.2 \cdot 10^{+40}:\\
\;\;\;\;x + y \cdot t\_1\\

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


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

    1. Initial program 95.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 x around 0 26.0%

      \[\leadsto x + \color{blue}{y \cdot \left(z \cdot \left(\frac{e^{\frac{t}{y}}}{e^{\frac{t}{y}} + \frac{1}{e^{\frac{t}{y}}}} - \frac{1}{e^{\frac{t}{y}} \cdot \left(e^{\frac{t}{y}} + \frac{1}{e^{\frac{t}{y}}}\right)}\right)\right)} \]
    4. Step-by-step derivation
      1. associate-/r*26.0%

        \[\leadsto x + y \cdot \left(z \cdot \left(\frac{e^{\frac{t}{y}}}{e^{\frac{t}{y}} + \frac{1}{e^{\frac{t}{y}}}} - \color{blue}{\frac{\frac{1}{e^{\frac{t}{y}}}}{e^{\frac{t}{y}} + \frac{1}{e^{\frac{t}{y}}}}}\right)\right) \]
      2. rec-exp26.0%

        \[\leadsto x + y \cdot \left(z \cdot \left(\frac{e^{\frac{t}{y}}}{e^{\frac{t}{y}} + \frac{1}{e^{\frac{t}{y}}}} - \frac{\color{blue}{e^{-\frac{t}{y}}}}{e^{\frac{t}{y}} + \frac{1}{e^{\frac{t}{y}}}}\right)\right) \]
      3. div-sub26.0%

        \[\leadsto x + y \cdot \left(z \cdot \color{blue}{\frac{e^{\frac{t}{y}} - e^{-\frac{t}{y}}}{e^{\frac{t}{y}} + \frac{1}{e^{\frac{t}{y}}}}}\right) \]
      4. rec-exp26.0%

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

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

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

    if 6.1999999999999995e40 < y

    1. Initial program 85.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 x around 0 49.6%

      \[\leadsto \color{blue}{x \cdot \left(1 + -1 \cdot z\right) + y \cdot \left(z \cdot \left(\frac{e^{\frac{t}{y}}}{e^{\frac{t}{y}} + \frac{1}{e^{\frac{t}{y}}}} - \frac{1}{e^{\frac{t}{y}} \cdot \left(e^{\frac{t}{y}} + \frac{1}{e^{\frac{t}{y}}}\right)}\right)\right)} \]
    4. Step-by-step derivation
      1. +-commutative49.6%

        \[\leadsto \color{blue}{y \cdot \left(z \cdot \left(\frac{e^{\frac{t}{y}}}{e^{\frac{t}{y}} + \frac{1}{e^{\frac{t}{y}}}} - \frac{1}{e^{\frac{t}{y}} \cdot \left(e^{\frac{t}{y}} + \frac{1}{e^{\frac{t}{y}}}\right)}\right)\right) + x \cdot \left(1 + -1 \cdot z\right)} \]
      2. fma-define49.6%

        \[\leadsto \color{blue}{\mathsf{fma}\left(y, z \cdot \left(\frac{e^{\frac{t}{y}}}{e^{\frac{t}{y}} + \frac{1}{e^{\frac{t}{y}}}} - \frac{1}{e^{\frac{t}{y}} \cdot \left(e^{\frac{t}{y}} + \frac{1}{e^{\frac{t}{y}}}\right)}\right), x \cdot \left(1 + -1 \cdot z\right)\right)} \]
    5. Simplified94.2%

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

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

Alternative 4: 68.2% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 3100:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.6 \cdot 10^{+64}:\\ \;\;\;\;z \cdot \left(y \cdot \tanh \left(\frac{t}{y}\right) - 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 3100.0)
   x
   (if (<= y 1.6e+64) (* z (- (* y (tanh (/ t y))) x)) (fma z (- t x) x))))
double code(double x, double y, double z, double t) {
	double tmp;
	if (y <= 3100.0) {
		tmp = x;
	} else if (y <= 1.6e+64) {
		tmp = z * ((y * tanh((t / y))) - x);
	} else {
		tmp = fma(z, (t - x), x);
	}
	return tmp;
}
function code(x, y, z, t)
	tmp = 0.0
	if (y <= 3100.0)
		tmp = x;
	elseif (y <= 1.6e+64)
		tmp = Float64(z * Float64(Float64(y * tanh(Float64(t / y))) - x));
	else
		tmp = fma(z, Float64(t - x), x);
	end
	return tmp
end
code[x_, y_, z_, t_] := If[LessEqual[y, 3100.0], x, If[LessEqual[y, 1.6e+64], N[(z * N[(N[(y * N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq 3100:\\
\;\;\;\;x\\

\mathbf{elif}\;y \leq 1.6 \cdot 10^{+64}:\\
\;\;\;\;z \cdot \left(y \cdot \tanh \left(\frac{t}{y}\right) - x\right)\\

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


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

    1. Initial program 95.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 x around inf 64.1%

      \[\leadsto \color{blue}{x} \]

    if 3100 < y < 1.60000000000000009e64

    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 x around 0 12.1%

      \[\leadsto \color{blue}{x \cdot \left(1 + -1 \cdot z\right) + y \cdot \left(z \cdot \left(\frac{e^{\frac{t}{y}}}{e^{\frac{t}{y}} + \frac{1}{e^{\frac{t}{y}}}} - \frac{1}{e^{\frac{t}{y}} \cdot \left(e^{\frac{t}{y}} + \frac{1}{e^{\frac{t}{y}}}\right)}\right)\right)} \]
    4. Step-by-step derivation
      1. +-commutative12.1%

        \[\leadsto \color{blue}{y \cdot \left(z \cdot \left(\frac{e^{\frac{t}{y}}}{e^{\frac{t}{y}} + \frac{1}{e^{\frac{t}{y}}}} - \frac{1}{e^{\frac{t}{y}} \cdot \left(e^{\frac{t}{y}} + \frac{1}{e^{\frac{t}{y}}}\right)}\right)\right) + x \cdot \left(1 + -1 \cdot z\right)} \]
      2. fma-define12.1%

        \[\leadsto \color{blue}{\mathsf{fma}\left(y, z \cdot \left(\frac{e^{\frac{t}{y}}}{e^{\frac{t}{y}} + \frac{1}{e^{\frac{t}{y}}}} - \frac{1}{e^{\frac{t}{y}} \cdot \left(e^{\frac{t}{y}} + \frac{1}{e^{\frac{t}{y}}}\right)}\right), x \cdot \left(1 + -1 \cdot z\right)\right)} \]
    5. Simplified83.1%

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

      \[\leadsto \color{blue}{z \cdot \left(-1 \cdot x + \frac{y \cdot \left(e^{\frac{t}{y}} - \frac{1}{e^{\frac{t}{y}}}\right)}{e^{\frac{t}{y}} + \frac{1}{e^{\frac{t}{y}}}}\right)} \]
    7. Step-by-step derivation
      1. neg-mul-18.4%

        \[\leadsto z \cdot \left(\color{blue}{\left(-x\right)} + \frac{y \cdot \left(e^{\frac{t}{y}} - \frac{1}{e^{\frac{t}{y}}}\right)}{e^{\frac{t}{y}} + \frac{1}{e^{\frac{t}{y}}}}\right) \]
      2. +-commutative8.4%

        \[\leadsto z \cdot \color{blue}{\left(\frac{y \cdot \left(e^{\frac{t}{y}} - \frac{1}{e^{\frac{t}{y}}}\right)}{e^{\frac{t}{y}} + \frac{1}{e^{\frac{t}{y}}}} + \left(-x\right)\right)} \]
      3. associate-/l*8.4%

        \[\leadsto z \cdot \left(\color{blue}{y \cdot \frac{e^{\frac{t}{y}} - \frac{1}{e^{\frac{t}{y}}}}{e^{\frac{t}{y}} + \frac{1}{e^{\frac{t}{y}}}}} + \left(-x\right)\right) \]
      4. div-sub8.4%

        \[\leadsto z \cdot \left(y \cdot \color{blue}{\left(\frac{e^{\frac{t}{y}}}{e^{\frac{t}{y}} + \frac{1}{e^{\frac{t}{y}}}} - \frac{\frac{1}{e^{\frac{t}{y}}}}{e^{\frac{t}{y}} + \frac{1}{e^{\frac{t}{y}}}}\right)} + \left(-x\right)\right) \]
      5. associate-/r*8.4%

        \[\leadsto z \cdot \left(y \cdot \left(\frac{e^{\frac{t}{y}}}{e^{\frac{t}{y}} + \frac{1}{e^{\frac{t}{y}}}} - \color{blue}{\frac{1}{e^{\frac{t}{y}} \cdot \left(e^{\frac{t}{y}} + \frac{1}{e^{\frac{t}{y}}}\right)}}\right) + \left(-x\right)\right) \]
    8. Simplified65.9%

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

    if 1.60000000000000009e64 < y

    1. Initial program 82.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 82.4%

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

        \[\leadsto \color{blue}{z \cdot \left(t - x\right) + x} \]
      2. fma-define82.4%

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

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

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

Alternative 5: 68.3% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq 58000:\\
\;\;\;\;x\\

\mathbf{elif}\;y \leq 1.02 \cdot 10^{+47}:\\
\;\;\;\;z \cdot \left(y \cdot \tanh \left(\frac{t}{y}\right)\right)\\

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


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

    1. Initial program 95.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 x around inf 64.1%

      \[\leadsto \color{blue}{x} \]

    if 58000 < y < 1.0199999999999999e47

    1. Initial program 99.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 7.8%

      \[\leadsto \color{blue}{x \cdot \left(1 + -1 \cdot z\right) + y \cdot \left(z \cdot \left(\frac{e^{\frac{t}{y}}}{e^{\frac{t}{y}} + \frac{1}{e^{\frac{t}{y}}}} - \frac{1}{e^{\frac{t}{y}} \cdot \left(e^{\frac{t}{y}} + \frac{1}{e^{\frac{t}{y}}}\right)}\right)\right)} \]
    4. Step-by-step derivation
      1. +-commutative7.8%

        \[\leadsto \color{blue}{y \cdot \left(z \cdot \left(\frac{e^{\frac{t}{y}}}{e^{\frac{t}{y}} + \frac{1}{e^{\frac{t}{y}}}} - \frac{1}{e^{\frac{t}{y}} \cdot \left(e^{\frac{t}{y}} + \frac{1}{e^{\frac{t}{y}}}\right)}\right)\right) + x \cdot \left(1 + -1 \cdot z\right)} \]
      2. fma-define7.8%

        \[\leadsto \color{blue}{\mathsf{fma}\left(y, z \cdot \left(\frac{e^{\frac{t}{y}}}{e^{\frac{t}{y}} + \frac{1}{e^{\frac{t}{y}}}} - \frac{1}{e^{\frac{t}{y}} \cdot \left(e^{\frac{t}{y}} + \frac{1}{e^{\frac{t}{y}}}\right)}\right), x \cdot \left(1 + -1 \cdot z\right)\right)} \]
    5. Simplified73.7%

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

      \[\leadsto \color{blue}{\frac{y \cdot \left(z \cdot \left(e^{\frac{t}{y}} - \frac{1}{e^{\frac{t}{y}}}\right)\right)}{e^{\frac{t}{y}} + \frac{1}{e^{\frac{t}{y}}}}} \]
    7. Step-by-step derivation
      1. associate-*r*1.1%

        \[\leadsto \frac{\color{blue}{\left(y \cdot z\right) \cdot \left(e^{\frac{t}{y}} - \frac{1}{e^{\frac{t}{y}}}\right)}}{e^{\frac{t}{y}} + \frac{1}{e^{\frac{t}{y}}}} \]
      2. associate-*r/1.1%

        \[\leadsto \color{blue}{\left(y \cdot z\right) \cdot \frac{e^{\frac{t}{y}} - \frac{1}{e^{\frac{t}{y}}}}{e^{\frac{t}{y}} + \frac{1}{e^{\frac{t}{y}}}}} \]
      3. rec-exp1.1%

        \[\leadsto \left(y \cdot z\right) \cdot \frac{e^{\frac{t}{y}} - \color{blue}{e^{-\frac{t}{y}}}}{e^{\frac{t}{y}} + \frac{1}{e^{\frac{t}{y}}}} \]
      4. rec-exp1.1%

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

        \[\leadsto \left(y \cdot z\right) \cdot \color{blue}{\tanh \left(\frac{t}{y}\right)} \]
      6. *-commutative56.1%

        \[\leadsto \color{blue}{\left(z \cdot y\right)} \cdot \tanh \left(\frac{t}{y}\right) \]
      7. associate-*r*56.1%

        \[\leadsto \color{blue}{z \cdot \left(y \cdot \tanh \left(\frac{t}{y}\right)\right)} \]
    8. Simplified56.1%

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

    if 1.0199999999999999e47 < y

    1. Initial program 84.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 78.5%

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

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

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

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

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

Alternative 6: 82.1% accurate, 1.9× speedup?

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

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

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


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

    1. Initial program 94.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 x around 0 25.4%

      \[\leadsto x + \color{blue}{y \cdot \left(z \cdot \left(\frac{e^{\frac{t}{y}}}{e^{\frac{t}{y}} + \frac{1}{e^{\frac{t}{y}}}} - \frac{1}{e^{\frac{t}{y}} \cdot \left(e^{\frac{t}{y}} + \frac{1}{e^{\frac{t}{y}}}\right)}\right)\right)} \]
    4. Step-by-step derivation
      1. associate-/r*25.4%

        \[\leadsto x + y \cdot \left(z \cdot \left(\frac{e^{\frac{t}{y}}}{e^{\frac{t}{y}} + \frac{1}{e^{\frac{t}{y}}}} - \color{blue}{\frac{\frac{1}{e^{\frac{t}{y}}}}{e^{\frac{t}{y}} + \frac{1}{e^{\frac{t}{y}}}}}\right)\right) \]
      2. rec-exp25.4%

        \[\leadsto x + y \cdot \left(z \cdot \left(\frac{e^{\frac{t}{y}}}{e^{\frac{t}{y}} + \frac{1}{e^{\frac{t}{y}}}} - \frac{\color{blue}{e^{-\frac{t}{y}}}}{e^{\frac{t}{y}} + \frac{1}{e^{\frac{t}{y}}}}\right)\right) \]
      3. div-sub25.4%

        \[\leadsto x + y \cdot \left(z \cdot \color{blue}{\frac{e^{\frac{t}{y}} - e^{-\frac{t}{y}}}{e^{\frac{t}{y}} + \frac{1}{e^{\frac{t}{y}}}}}\right) \]
      4. rec-exp25.4%

        \[\leadsto x + y \cdot \left(z \cdot \frac{e^{\frac{t}{y}} - e^{-\frac{t}{y}}}{e^{\frac{t}{y}} + \color{blue}{e^{-\frac{t}{y}}}}\right) \]
      5. tanh-def-a81.9%

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

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

    if 4.2999999999999998e153 < y

    1. Initial program 77.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 95.5%

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

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

Alternative 7: 69.0% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq 3500:\\
\;\;\;\;x\\

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


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

    1. Initial program 95.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 x around inf 64.1%

      \[\leadsto \color{blue}{x} \]

    if 3500 < y

    1. Initial program 86.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 71.2%

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

        \[\leadsto \color{blue}{z \cdot \left(t - x\right) + x} \]
      2. fma-define71.2%

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

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

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

Alternative 8: 63.8% accurate, 14.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 1.1 \cdot 10^{+42}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 4 \cdot 10^{+191}:\\ \;\;\;\;x \cdot \left(1 - z\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(t - x\right)\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (<= y 1.1e+42) x (if (<= y 4e+191) (* x (- 1.0 z)) (* z (- t x)))))
double code(double x, double y, double z, double t) {
	double tmp;
	if (y <= 1.1e+42) {
		tmp = x;
	} else if (y <= 4e+191) {
		tmp = x * (1.0 - z);
	} 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 (y <= 1.1d+42) then
        tmp = x
    else if (y <= 4d+191) then
        tmp = x * (1.0d0 - z)
    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 (y <= 1.1e+42) {
		tmp = x;
	} else if (y <= 4e+191) {
		tmp = x * (1.0 - z);
	} else {
		tmp = z * (t - x);
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if y <= 1.1e+42:
		tmp = x
	elif y <= 4e+191:
		tmp = x * (1.0 - z)
	else:
		tmp = z * (t - x)
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if (y <= 1.1e+42)
		tmp = x;
	elseif (y <= 4e+191)
		tmp = Float64(x * Float64(1.0 - z));
	else
		tmp = Float64(z * Float64(t - x));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (y <= 1.1e+42)
		tmp = x;
	elseif (y <= 4e+191)
		tmp = x * (1.0 - z);
	else
		tmp = z * (t - x);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.1e+42], x, If[LessEqual[y, 4e+191], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.1 \cdot 10^{+42}:\\
\;\;\;\;x\\

\mathbf{elif}\;y \leq 4 \cdot 10^{+191}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < 1.1000000000000001e42

    1. Initial program 95.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 x around inf 63.0%

      \[\leadsto \color{blue}{x} \]

    if 1.1000000000000001e42 < y < 4.00000000000000029e191

    1. Initial program 92.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 66.3%

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

      \[\leadsto \color{blue}{x \cdot \left(1 + -1 \cdot z\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg56.0%

        \[\leadsto x \cdot \left(1 + \color{blue}{\left(-z\right)}\right) \]
      2. unsub-neg56.0%

        \[\leadsto x \cdot \color{blue}{\left(1 - z\right)} \]
    6. Simplified56.0%

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

    if 4.00000000000000029e191 < y

    1. Initial program 65.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 100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 1.1 \cdot 10^{+42}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 4 \cdot 10^{+191}:\\ \;\;\;\;x \cdot \left(1 - z\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(t - x\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 69.0% accurate, 17.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 30000:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \left(t - x\right)\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (<= y 30000.0) x (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
	double tmp;
	if (y <= 30000.0) {
		tmp = x;
	} else {
		tmp = x + (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 (y <= 30000.0d0) then
        tmp = x
    else
        tmp = x + (z * (t - x))
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (y <= 30000.0) {
		tmp = x;
	} else {
		tmp = x + (z * (t - x));
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if y <= 30000.0:
		tmp = x
	else:
		tmp = x + (z * (t - x))
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if (y <= 30000.0)
		tmp = x;
	else
		tmp = Float64(x + Float64(z * Float64(t - x)));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (y <= 30000.0)
		tmp = x;
	else
		tmp = x + (z * (t - x));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[LessEqual[y, 30000.0], x, N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq 30000:\\
\;\;\;\;x\\

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


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

    1. Initial program 95.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 x around inf 64.1%

      \[\leadsto \color{blue}{x} \]

    if 3e4 < y

    1. Initial program 86.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 71.2%

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

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

Alternative 10: 64.0% accurate, 21.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 4.3 \cdot 10^{+37}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - z\right)\\ \end{array} \end{array} \]
(FPCore (x y z t) :precision binary64 (if (<= y 4.3e+37) x (* x (- 1.0 z))))
double code(double x, double y, double z, double t) {
	double tmp;
	if (y <= 4.3e+37) {
		tmp = x;
	} else {
		tmp = x * (1.0 - z);
	}
	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 (y <= 4.3d+37) then
        tmp = x
    else
        tmp = x * (1.0d0 - z)
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (y <= 4.3e+37) {
		tmp = x;
	} else {
		tmp = x * (1.0 - z);
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if y <= 4.3e+37:
		tmp = x
	else:
		tmp = x * (1.0 - z)
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if (y <= 4.3e+37)
		tmp = x;
	else
		tmp = Float64(x * Float64(1.0 - z));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (y <= 4.3e+37)
		tmp = x;
	else
		tmp = x * (1.0 - z);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[LessEqual[y, 4.3e+37], x, N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.3 \cdot 10^{+37}:\\
\;\;\;\;x\\

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


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

    1. Initial program 95.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 x around inf 63.0%

      \[\leadsto \color{blue}{x} \]

    if 4.2999999999999997e37 < y

    1. Initial program 85.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 75.6%

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

      \[\leadsto \color{blue}{x \cdot \left(1 + -1 \cdot z\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg58.5%

        \[\leadsto x \cdot \left(1 + \color{blue}{\left(-z\right)}\right) \]
      2. unsub-neg58.5%

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

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

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

Alternative 11: 65.2% accurate, 21.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 15000:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot t\\ \end{array} \end{array} \]
(FPCore (x y z t) :precision binary64 (if (<= y 15000.0) x (+ x (* z t))))
double code(double x, double y, double z, double t) {
	double tmp;
	if (y <= 15000.0) {
		tmp = x;
	} else {
		tmp = x + (z * t);
	}
	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 (y <= 15000.0d0) then
        tmp = x
    else
        tmp = x + (z * t)
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (y <= 15000.0) {
		tmp = x;
	} else {
		tmp = x + (z * t);
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if y <= 15000.0:
		tmp = x
	else:
		tmp = x + (z * t)
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if (y <= 15000.0)
		tmp = x;
	else
		tmp = Float64(x + Float64(z * t));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (y <= 15000.0)
		tmp = x;
	else
		tmp = x + (z * t);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[LessEqual[y, 15000.0], x, N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq 15000:\\
\;\;\;\;x\\

\mathbf{else}:\\
\;\;\;\;x + z \cdot t\\


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

    1. Initial program 95.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 x around inf 64.1%

      \[\leadsto \color{blue}{x} \]

    if 15000 < y

    1. Initial program 86.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 29.8%

      \[\leadsto x + \color{blue}{y \cdot \left(z \cdot \left(\frac{e^{\frac{t}{y}}}{e^{\frac{t}{y}} + \frac{1}{e^{\frac{t}{y}}}} - \frac{1}{e^{\frac{t}{y}} \cdot \left(e^{\frac{t}{y}} + \frac{1}{e^{\frac{t}{y}}}\right)}\right)\right)} \]
    4. Step-by-step derivation
      1. associate-/r*29.8%

        \[\leadsto x + y \cdot \left(z \cdot \left(\frac{e^{\frac{t}{y}}}{e^{\frac{t}{y}} + \frac{1}{e^{\frac{t}{y}}}} - \color{blue}{\frac{\frac{1}{e^{\frac{t}{y}}}}{e^{\frac{t}{y}} + \frac{1}{e^{\frac{t}{y}}}}}\right)\right) \]
      2. rec-exp29.8%

        \[\leadsto x + y \cdot \left(z \cdot \left(\frac{e^{\frac{t}{y}}}{e^{\frac{t}{y}} + \frac{1}{e^{\frac{t}{y}}}} - \frac{\color{blue}{e^{-\frac{t}{y}}}}{e^{\frac{t}{y}} + \frac{1}{e^{\frac{t}{y}}}}\right)\right) \]
      3. div-sub29.8%

        \[\leadsto x + y \cdot \left(z \cdot \color{blue}{\frac{e^{\frac{t}{y}} - e^{-\frac{t}{y}}}{e^{\frac{t}{y}} + \frac{1}{e^{\frac{t}{y}}}}}\right) \]
      4. rec-exp29.8%

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

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

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

      \[\leadsto \color{blue}{x + t \cdot z} \]
    7. Step-by-step derivation
      1. +-commutative57.3%

        \[\leadsto \color{blue}{t \cdot z + x} \]
      2. *-commutative57.3%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 15000:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot t\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 60.4% accurate, 213.0× speedup?

\[\begin{array}{l} \\ x \end{array} \]
(FPCore (x y z t) :precision binary64 x)
double code(double x, double y, double z, double t) {
	return 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 = x
end function
public static double code(double x, double y, double z, double t) {
	return x;
}
def code(x, y, z, t):
	return x
function code(x, y, z, t)
	return x
end
function tmp = code(x, y, z, t)
	tmp = x;
end
code[x_, y_, z_, t_] := x
\begin{array}{l}

\\
x
\end{array}
Derivation
  1. Initial program 93.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 x around inf 59.1%

    \[\leadsto \color{blue}{x} \]
  4. Final simplification59.1%

    \[\leadsto x \]
  5. Add Preprocessing

Developer target: 96.7% 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 2024095 
(FPCore (x y z t)
  :name "SynthBasics:moogVCF from YampaSynth-0.2"
  :precision binary64

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

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