SynthBasics:moogVCF from YampaSynth-0.2

Percentage Accurate: 93.7% → 96.9%
Time: 14.3s
Alternatives: 9
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 9 alternatives:

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

Initial Program: 93.7% accurate, 1.0× speedup?

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

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

Alternative 1: 96.9% accurate, 1.0× speedup?

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

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


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

    1. Initial program 97.7%

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

    if 5.0000000000000002e136 < y

    1. Initial program 88.6%

      \[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. +-commutative88.6%

        \[\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. *-commutative88.6%

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

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

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

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{-1 \cdot x + y \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)}, z, x\right) \]
    5. Step-by-step derivation
      1. +-commutative64.7%

        \[\leadsto \mathsf{fma}\left(\color{blue}{y \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) + -1 \cdot x}, z, x\right) \]
      2. mul-1-neg64.7%

        \[\leadsto \mathsf{fma}\left(y \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) + \color{blue}{\left(-x\right)}, z, x\right) \]
      3. unsub-neg64.7%

        \[\leadsto \mathsf{fma}\left(\color{blue}{y \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}, z, x\right) \]
    6. Simplified96.9%

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

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

Alternative 2: 97.9% accurate, 0.7× speedup?

\[\begin{array}{l} y = |y|\\ \\ \mathsf{fma}\left(y \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), z, x\right) \end{array} \]
NOTE: y should be positive before calling this function
(FPCore (x y z t)
 :precision binary64
 (fma (* y (- (tanh (/ t y)) (tanh (/ x y)))) z x))
y = abs(y);
double code(double x, double y, double z, double t) {
	return fma((y * (tanh((t / y)) - tanh((x / y)))), z, x);
}
y = abs(y)
function code(x, y, z, t)
	return fma(Float64(y * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))), z, x)
end
NOTE: y should be positive before calling this function
code[x_, y_, z_, t_] := N[(N[(y * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * z + x), $MachinePrecision]
\begin{array}{l}
y = |y|\\
\\
\mathsf{fma}\left(y \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), z, x\right)
\end{array}
Derivation
  1. Initial program 96.2%

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

      \[\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. *-commutative96.2%

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

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

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

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

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

Alternative 3: 87.4% accurate, 1.0× speedup?

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

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


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

    1. Initial program 97.6%

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

      \[\leadsto x + \color{blue}{y \cdot \left(\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) \cdot z\right)} \]
    3. Step-by-step derivation
      1. *-commutative22.0%

        \[\leadsto x + y \cdot \color{blue}{\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)} \]
      2. associate-/r*22.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) \]
      3. div-sub22.0%

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

        \[\leadsto x + y \cdot \left(z \cdot \frac{e^{\frac{t}{y}} - \color{blue}{e^{-\frac{t}{y}}}}{e^{\frac{t}{y}} + \frac{1}{e^{\frac{t}{y}}}}\right) \]
      5. rec-exp22.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) \]
      6. tanh-def-a79.7%

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

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

    if 2.59999999999999973e61 < y

    1. Initial program 90.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. +-commutative90.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. *-commutative90.8%

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

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

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

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{-1 \cdot x + y \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)}, z, x\right) \]
    5. Step-by-step derivation
      1. +-commutative58.3%

        \[\leadsto \mathsf{fma}\left(\color{blue}{y \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) + -1 \cdot x}, z, x\right) \]
      2. mul-1-neg58.3%

        \[\leadsto \mathsf{fma}\left(y \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) + \color{blue}{\left(-x\right)}, z, x\right) \]
      3. unsub-neg58.3%

        \[\leadsto \mathsf{fma}\left(\color{blue}{y \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}, z, x\right) \]
    6. Simplified95.9%

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

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

Alternative 4: 84.8% accurate, 1.9× speedup?

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

    1. Initial program 97.8%

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

      \[\leadsto x + \color{blue}{y \cdot \left(\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) \cdot z\right)} \]
    3. Step-by-step derivation
      1. *-commutative23.3%

        \[\leadsto x + y \cdot \color{blue}{\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)} \]
      2. associate-/r*23.3%

        \[\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) \]
      3. div-sub23.3%

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

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

        \[\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) \]
      6. tanh-def-a80.6%

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

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

    if 5.0000000000000001e172 < y

    1. Initial program 85.5%

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

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

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

Alternative 5: 67.9% accurate, 19.0× speedup?

\[\begin{array}{l} y = |y|\\ \\ \begin{array}{l} \mathbf{if}\;y \leq 1.12 \cdot 10^{+35}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 7.6 \cdot 10^{+133} \lor \neg \left(y \leq 1.35 \cdot 10^{+281}\right):\\ \;\;\;\;x + t \cdot z\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - z\right)\\ \end{array} \end{array} \]
NOTE: y should be positive before calling this function
(FPCore (x y z t)
 :precision binary64
 (if (<= y 1.12e+35)
   x
   (if (or (<= y 7.6e+133) (not (<= y 1.35e+281)))
     (+ x (* t z))
     (* x (- 1.0 z)))))
y = abs(y);
double code(double x, double y, double z, double t) {
	double tmp;
	if (y <= 1.12e+35) {
		tmp = x;
	} else if ((y <= 7.6e+133) || !(y <= 1.35e+281)) {
		tmp = x + (t * z);
	} else {
		tmp = x * (1.0 - z);
	}
	return tmp;
}
NOTE: y should be positive before calling this function
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.12d+35) then
        tmp = x
    else if ((y <= 7.6d+133) .or. (.not. (y <= 1.35d+281))) then
        tmp = x + (t * z)
    else
        tmp = x * (1.0d0 - z)
    end if
    code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (y <= 1.12e+35) {
		tmp = x;
	} else if ((y <= 7.6e+133) || !(y <= 1.35e+281)) {
		tmp = x + (t * z);
	} else {
		tmp = x * (1.0 - z);
	}
	return tmp;
}
y = abs(y)
def code(x, y, z, t):
	tmp = 0
	if y <= 1.12e+35:
		tmp = x
	elif (y <= 7.6e+133) or not (y <= 1.35e+281):
		tmp = x + (t * z)
	else:
		tmp = x * (1.0 - z)
	return tmp
y = abs(y)
function code(x, y, z, t)
	tmp = 0.0
	if (y <= 1.12e+35)
		tmp = x;
	elseif ((y <= 7.6e+133) || !(y <= 1.35e+281))
		tmp = Float64(x + Float64(t * z));
	else
		tmp = Float64(x * Float64(1.0 - z));
	end
	return tmp
end
y = abs(y)
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (y <= 1.12e+35)
		tmp = x;
	elseif ((y <= 7.6e+133) || ~((y <= 1.35e+281)))
		tmp = x + (t * z);
	else
		tmp = x * (1.0 - z);
	end
	tmp_2 = tmp;
end
NOTE: y should be positive before calling this function
code[x_, y_, z_, t_] := If[LessEqual[y, 1.12e+35], x, If[Or[LessEqual[y, 7.6e+133], N[Not[LessEqual[y, 1.35e+281]], $MachinePrecision]], N[(x + N[(t * z), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.12 \cdot 10^{+35}:\\
\;\;\;\;x\\

\mathbf{elif}\;y \leq 7.6 \cdot 10^{+133} \lor \neg \left(y \leq 1.35 \cdot 10^{+281}\right):\\
\;\;\;\;x + t \cdot z\\

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


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

    1. Initial program 97.5%

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

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

    if 1.12000000000000003e35 < y < 7.6000000000000004e133 or 1.35000000000000004e281 < y

    1. Initial program 95.5%

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

      \[\leadsto x + \color{blue}{y \cdot \left(\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) \cdot z\right)} \]
    3. Step-by-step derivation
      1. *-commutative33.9%

        \[\leadsto x + y \cdot \color{blue}{\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)} \]
      2. associate-/r*34.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) \]
      3. div-sub34.0%

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

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

        \[\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) \]
      6. tanh-def-a91.0%

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

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

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

    if 7.6000000000000004e133 < y < 1.35000000000000004e281

    1. Initial program 89.6%

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

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

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

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

        \[\leadsto x \cdot \color{blue}{\left(1 + -1 \cdot z\right)} \]
      3. distribute-lft-in69.3%

        \[\leadsto \color{blue}{x \cdot 1 + x \cdot \left(-1 \cdot z\right)} \]
      4. metadata-eval69.3%

        \[\leadsto x \cdot \color{blue}{\left(--1\right)} + x \cdot \left(-1 \cdot z\right) \]
      5. distribute-rgt-neg-in69.3%

        \[\leadsto \color{blue}{\left(-x \cdot -1\right)} + x \cdot \left(-1 \cdot z\right) \]
      6. *-commutative69.3%

        \[\leadsto \left(-\color{blue}{-1 \cdot x}\right) + x \cdot \left(-1 \cdot z\right) \]
      7. mul-1-neg69.3%

        \[\leadsto \left(-\color{blue}{\left(-x\right)}\right) + x \cdot \left(-1 \cdot z\right) \]
      8. remove-double-neg69.3%

        \[\leadsto \color{blue}{x} + x \cdot \left(-1 \cdot z\right) \]
      9. mul-1-neg69.3%

        \[\leadsto x + x \cdot \color{blue}{\left(-z\right)} \]
      10. distribute-rgt-neg-in69.3%

        \[\leadsto x + \color{blue}{\left(-x \cdot z\right)} \]
      11. *-commutative69.3%

        \[\leadsto x + \left(-\color{blue}{z \cdot x}\right) \]
      12. unsub-neg69.3%

        \[\leadsto \color{blue}{x - z \cdot x} \]
      13. *-commutative69.3%

        \[\leadsto x - \color{blue}{x \cdot z} \]
    5. Simplified69.3%

      \[\leadsto \color{blue}{x - x \cdot z} \]
    6. Taylor expanded in x around 0 69.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 1.12 \cdot 10^{+35}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 7.6 \cdot 10^{+133} \lor \neg \left(y \leq 1.35 \cdot 10^{+281}\right):\\ \;\;\;\;x + t \cdot z\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - z\right)\\ \end{array} \]

Alternative 6: 77.1% accurate, 23.5× speedup?

\[\begin{array}{l} y = |y|\\ \\ \begin{array}{l} \mathbf{if}\;y \leq 8.5 \cdot 10^{-40}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \left(t - x\right)\\ \end{array} \end{array} \]
NOTE: y should be positive before calling this function
(FPCore (x y z t)
 :precision binary64
 (if (<= y 8.5e-40) x (+ x (* z (- t x)))))
y = abs(y);
double code(double x, double y, double z, double t) {
	double tmp;
	if (y <= 8.5e-40) {
		tmp = x;
	} else {
		tmp = x + (z * (t - x));
	}
	return tmp;
}
NOTE: y should be positive before calling this function
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 <= 8.5d-40) then
        tmp = x
    else
        tmp = x + (z * (t - x))
    end if
    code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (y <= 8.5e-40) {
		tmp = x;
	} else {
		tmp = x + (z * (t - x));
	}
	return tmp;
}
y = abs(y)
def code(x, y, z, t):
	tmp = 0
	if y <= 8.5e-40:
		tmp = x
	else:
		tmp = x + (z * (t - x))
	return tmp
y = abs(y)
function code(x, y, z, t)
	tmp = 0.0
	if (y <= 8.5e-40)
		tmp = x;
	else
		tmp = Float64(x + Float64(z * Float64(t - x)));
	end
	return tmp
end
y = abs(y)
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (y <= 8.5e-40)
		tmp = x;
	else
		tmp = x + (z * (t - x));
	end
	tmp_2 = tmp;
end
NOTE: y should be positive before calling this function
code[x_, y_, z_, t_] := If[LessEqual[y, 8.5e-40], x, N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 8.5 \cdot 10^{-40}:\\
\;\;\;\;x\\

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


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

    1. Initial program 97.4%

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

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

    if 8.4999999999999998e-40 < y

    1. Initial program 93.1%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 8.5 \cdot 10^{-40}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \left(t - x\right)\\ \end{array} \]

Alternative 7: 59.5% accurate, 29.9× speedup?

\[\begin{array}{l} y = |y|\\ \\ \begin{array}{l} \mathbf{if}\;x \leq -7.2 \cdot 10^{-121}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.05 \cdot 10^{-179}:\\ \;\;\;\;t \cdot z\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
NOTE: y should be positive before calling this function
(FPCore (x y z t)
 :precision binary64
 (if (<= x -7.2e-121) x (if (<= x 1.05e-179) (* t z) x)))
y = abs(y);
double code(double x, double y, double z, double t) {
	double tmp;
	if (x <= -7.2e-121) {
		tmp = x;
	} else if (x <= 1.05e-179) {
		tmp = t * z;
	} else {
		tmp = x;
	}
	return tmp;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if (x <= (-7.2d-121)) then
        tmp = x
    else if (x <= 1.05d-179) then
        tmp = t * z
    else
        tmp = x
    end if
    code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (x <= -7.2e-121) {
		tmp = x;
	} else if (x <= 1.05e-179) {
		tmp = t * z;
	} else {
		tmp = x;
	}
	return tmp;
}
y = abs(y)
def code(x, y, z, t):
	tmp = 0
	if x <= -7.2e-121:
		tmp = x
	elif x <= 1.05e-179:
		tmp = t * z
	else:
		tmp = x
	return tmp
y = abs(y)
function code(x, y, z, t)
	tmp = 0.0
	if (x <= -7.2e-121)
		tmp = x;
	elseif (x <= 1.05e-179)
		tmp = Float64(t * z);
	else
		tmp = x;
	end
	return tmp
end
y = abs(y)
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (x <= -7.2e-121)
		tmp = x;
	elseif (x <= 1.05e-179)
		tmp = t * z;
	else
		tmp = x;
	end
	tmp_2 = tmp;
end
NOTE: y should be positive before calling this function
code[x_, y_, z_, t_] := If[LessEqual[x, -7.2e-121], x, If[LessEqual[x, 1.05e-179], N[(t * z), $MachinePrecision], x]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7.2 \cdot 10^{-121}:\\
\;\;\;\;x\\

\mathbf{elif}\;x \leq 1.05 \cdot 10^{-179}:\\
\;\;\;\;t \cdot z\\

\mathbf{else}:\\
\;\;\;\;x\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -7.19999999999999967e-121 or 1.0499999999999999e-179 < x

    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. Taylor expanded in x around inf 71.2%

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

    if -7.19999999999999967e-121 < x < 1.0499999999999999e-179

    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. Taylor expanded in y around inf 54.1%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -7.2 \cdot 10^{-121}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.05 \cdot 10^{-179}:\\ \;\;\;\;t \cdot z\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]

Alternative 8: 66.5% accurate, 30.2× speedup?

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

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


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

    1. Initial program 97.6%

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

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

    if 8.2e60 < y

    1. Initial program 90.8%

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

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

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

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

        \[\leadsto x \cdot \color{blue}{\left(1 + -1 \cdot z\right)} \]
      3. distribute-lft-in69.0%

        \[\leadsto \color{blue}{x \cdot 1 + x \cdot \left(-1 \cdot z\right)} \]
      4. metadata-eval69.0%

        \[\leadsto x \cdot \color{blue}{\left(--1\right)} + x \cdot \left(-1 \cdot z\right) \]
      5. distribute-rgt-neg-in69.0%

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

        \[\leadsto \left(-\color{blue}{-1 \cdot x}\right) + x \cdot \left(-1 \cdot z\right) \]
      7. mul-1-neg69.0%

        \[\leadsto \left(-\color{blue}{\left(-x\right)}\right) + x \cdot \left(-1 \cdot z\right) \]
      8. remove-double-neg69.0%

        \[\leadsto \color{blue}{x} + x \cdot \left(-1 \cdot z\right) \]
      9. mul-1-neg69.0%

        \[\leadsto x + x \cdot \color{blue}{\left(-z\right)} \]
      10. distribute-rgt-neg-in69.0%

        \[\leadsto x + \color{blue}{\left(-x \cdot z\right)} \]
      11. *-commutative69.0%

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

        \[\leadsto \color{blue}{x - z \cdot x} \]
      13. *-commutative69.0%

        \[\leadsto x - \color{blue}{x \cdot z} \]
    5. Simplified69.0%

      \[\leadsto \color{blue}{x - x \cdot z} \]
    6. Taylor expanded in x around 0 69.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 8.2 \cdot 10^{+60}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - z\right)\\ \end{array} \]

Alternative 9: 59.5% accurate, 213.0× speedup?

\[\begin{array}{l} y = |y|\\ \\ x \end{array} \]
NOTE: y should be positive before calling this function
(FPCore (x y z t) :precision binary64 x)
y = abs(y);
double code(double x, double y, double z, double t) {
	return x;
}
NOTE: y should be positive before calling this function
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
y = Math.abs(y);
public static double code(double x, double y, double z, double t) {
	return x;
}
y = abs(y)
def code(x, y, z, t):
	return x
y = abs(y)
function code(x, y, z, t)
	return x
end
y = abs(y)
function tmp = code(x, y, z, t)
	tmp = x;
end
NOTE: y should be positive before calling this function
code[x_, y_, z_, t_] := x
\begin{array}{l}
y = |y|\\
\\
x
\end{array}
Derivation
  1. Initial program 96.2%

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

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

    \[\leadsto x \]

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

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

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