SynthBasics:moogVCF from YampaSynth-0.2

Percentage Accurate: 93.6% → 97.1%
Time: 13.1s
Alternatives: 8
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 8 alternatives:

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

Initial Program: 93.6% 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: 97.1% accurate, 0.7× speedup?

\[\begin{array}{l} y = |y|\\ \\ \begin{array}{l} t_1 := \tanh \left(\frac{t}{y}\right)\\ \mathbf{if}\;y \leq 1.45 \cdot 10^{+138}:\\ \;\;\;\;\mathsf{fma}\left(y \cdot z, t_1 - \tanh \left(\frac{x}{y}\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \left(y \cdot t_1 - 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 1.45e+138)
     (fma (* y z) (- t_1 (tanh (/ x y))) x)
     (+ x (* z (- (* y t_1) x))))))
y = abs(y);
double code(double x, double y, double z, double t) {
	double t_1 = tanh((t / y));
	double tmp;
	if (y <= 1.45e+138) {
		tmp = fma((y * z), (t_1 - tanh((x / y))), x);
	} else {
		tmp = x + (z * ((y * t_1) - x));
	}
	return tmp;
}
y = abs(y)
function code(x, y, z, t)
	t_1 = tanh(Float64(t / y))
	tmp = 0.0
	if (y <= 1.45e+138)
		tmp = fma(Float64(y * z), Float64(t_1 - tanh(Float64(x / y))), x);
	else
		tmp = Float64(x + Float64(z * Float64(Float64(y * t_1) - 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, 1.45e+138], N[(N[(y * z), $MachinePrecision] * N[(t$95$1 - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[(x + N[(z * N[(N[(y * t$95$1), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
t_1 := \tanh \left(\frac{t}{y}\right)\\
\mathbf{if}\;y \leq 1.45 \cdot 10^{+138}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot z, t_1 - \tanh \left(\frac{x}{y}\right), x\right)\\

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


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

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

        \[\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. fma-def95.5%

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

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

    if 1.45000000000000005e138 < y

    1. Initial program 80.9%

      \[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 55.5%

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

        \[\leadsto x + \color{blue}{\left(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) + -1 \cdot \left(x \cdot z\right)\right)} \]
    4. Simplified96.2%

      \[\leadsto x + \color{blue}{z \cdot \left(\tanh \left(\frac{t}{y}\right) \cdot y + \left(-x\right)\right)} \]
    5. Step-by-step derivation
      1. add-sqr-sqrt56.2%

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

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

        \[\leadsto x + z \cdot \left(\sqrt{\color{blue}{{\tanh \left(\frac{t}{y}\right)}^{2}}} \cdot y + \left(-x\right)\right) \]
    6. Applied egg-rr79.2%

      \[\leadsto x + z \cdot \left(\color{blue}{\sqrt{{\tanh \left(\frac{t}{y}\right)}^{2}}} \cdot y + \left(-x\right)\right) \]
    7. Step-by-step derivation
      1. unpow279.2%

        \[\leadsto x + z \cdot \left(\sqrt{\color{blue}{\tanh \left(\frac{t}{y}\right) \cdot \tanh \left(\frac{t}{y}\right)}} \cdot y + \left(-x\right)\right) \]
      2. rem-sqrt-square78.9%

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

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

      \[\leadsto x + \color{blue}{z \cdot \left(y \cdot \left|\tanh \left(\frac{t}{y}\right)\right| - x\right)} \]
    10. Step-by-step derivation
      1. expm1-log1p-u77.3%

        \[\leadsto x + z \cdot \left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(y \cdot \left|\tanh \left(\frac{t}{y}\right)\right|\right)\right)} - x\right) \]
      2. expm1-udef77.4%

        \[\leadsto x + z \cdot \left(\color{blue}{\left(e^{\mathsf{log1p}\left(y \cdot \left|\tanh \left(\frac{t}{y}\right)\right|\right)} - 1\right)} - x\right) \]
      3. add-sqr-sqrt54.6%

        \[\leadsto x + z \cdot \left(\left(e^{\mathsf{log1p}\left(y \cdot \left|\color{blue}{\sqrt{\tanh \left(\frac{t}{y}\right)} \cdot \sqrt{\tanh \left(\frac{t}{y}\right)}}\right|\right)} - 1\right) - x\right) \]
      4. fabs-sqr54.6%

        \[\leadsto x + z \cdot \left(\left(e^{\mathsf{log1p}\left(y \cdot \color{blue}{\left(\sqrt{\tanh \left(\frac{t}{y}\right)} \cdot \sqrt{\tanh \left(\frac{t}{y}\right)}\right)}\right)} - 1\right) - x\right) \]
      5. add-sqr-sqrt61.3%

        \[\leadsto x + z \cdot \left(\left(e^{\mathsf{log1p}\left(y \cdot \color{blue}{\tanh \left(\frac{t}{y}\right)}\right)} - 1\right) - x\right) \]
    11. Applied egg-rr61.3%

      \[\leadsto x + z \cdot \left(\color{blue}{\left(e^{\mathsf{log1p}\left(y \cdot \tanh \left(\frac{t}{y}\right)\right)} - 1\right)} - x\right) \]
    12. Step-by-step derivation
      1. expm1-def66.6%

        \[\leadsto x + z \cdot \left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(y \cdot \tanh \left(\frac{t}{y}\right)\right)\right)} - x\right) \]
      2. expm1-log1p96.2%

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

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

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

Alternative 2: 97.1% accurate, 1.0× speedup?

\[\begin{array}{l} y = |y|\\ \\ \begin{array}{l} t_1 := \tanh \left(\frac{t}{y}\right)\\ \mathbf{if}\;y \leq 4 \cdot 10^{+138}:\\ \;\;\;\;x + \left(y \cdot z\right) \cdot \left(t_1 - \tanh \left(\frac{x}{y}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \left(y \cdot t_1 - 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 4e+138)
     (+ x (* (* y z) (- t_1 (tanh (/ x y)))))
     (+ x (* z (- (* y t_1) x))))))
y = abs(y);
double code(double x, double y, double z, double t) {
	double t_1 = tanh((t / y));
	double tmp;
	if (y <= 4e+138) {
		tmp = x + ((y * z) * (t_1 - tanh((x / y))));
	} else {
		tmp = x + (z * ((y * t_1) - 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) :: t_1
    real(8) :: tmp
    t_1 = tanh((t / y))
    if (y <= 4d+138) then
        tmp = x + ((y * z) * (t_1 - tanh((x / y))))
    else
        tmp = x + (z * ((y * t_1) - x))
    end if
    code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z, double t) {
	double t_1 = Math.tanh((t / y));
	double tmp;
	if (y <= 4e+138) {
		tmp = x + ((y * z) * (t_1 - Math.tanh((x / y))));
	} else {
		tmp = x + (z * ((y * t_1) - x));
	}
	return tmp;
}
y = abs(y)
def code(x, y, z, t):
	t_1 = math.tanh((t / y))
	tmp = 0
	if y <= 4e+138:
		tmp = x + ((y * z) * (t_1 - math.tanh((x / y))))
	else:
		tmp = x + (z * ((y * t_1) - x))
	return tmp
y = abs(y)
function code(x, y, z, t)
	t_1 = tanh(Float64(t / y))
	tmp = 0.0
	if (y <= 4e+138)
		tmp = Float64(x + Float64(Float64(y * z) * Float64(t_1 - tanh(Float64(x / y)))));
	else
		tmp = Float64(x + Float64(z * Float64(Float64(y * t_1) - x)));
	end
	return tmp
end
y = abs(y)
function tmp_2 = code(x, y, z, t)
	t_1 = tanh((t / y));
	tmp = 0.0;
	if (y <= 4e+138)
		tmp = x + ((y * z) * (t_1 - tanh((x / y))));
	else
		tmp = x + (z * ((y * t_1) - x));
	end
	tmp_2 = 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, 4e+138], N[(x + N[(N[(y * z), $MachinePrecision] * N[(t$95$1 - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(N[(y * t$95$1), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
t_1 := \tanh \left(\frac{t}{y}\right)\\
\mathbf{if}\;y \leq 4 \cdot 10^{+138}:\\
\;\;\;\;x + \left(y \cdot z\right) \cdot \left(t_1 - \tanh \left(\frac{x}{y}\right)\right)\\

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


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

    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) \]

    if 4.0000000000000001e138 < y

    1. Initial program 80.9%

      \[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 55.5%

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

        \[\leadsto x + \color{blue}{\left(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) + -1 \cdot \left(x \cdot z\right)\right)} \]
    4. Simplified96.2%

      \[\leadsto x + \color{blue}{z \cdot \left(\tanh \left(\frac{t}{y}\right) \cdot y + \left(-x\right)\right)} \]
    5. Step-by-step derivation
      1. add-sqr-sqrt56.2%

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

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

        \[\leadsto x + z \cdot \left(\sqrt{\color{blue}{{\tanh \left(\frac{t}{y}\right)}^{2}}} \cdot y + \left(-x\right)\right) \]
    6. Applied egg-rr79.2%

      \[\leadsto x + z \cdot \left(\color{blue}{\sqrt{{\tanh \left(\frac{t}{y}\right)}^{2}}} \cdot y + \left(-x\right)\right) \]
    7. Step-by-step derivation
      1. unpow279.2%

        \[\leadsto x + z \cdot \left(\sqrt{\color{blue}{\tanh \left(\frac{t}{y}\right) \cdot \tanh \left(\frac{t}{y}\right)}} \cdot y + \left(-x\right)\right) \]
      2. rem-sqrt-square78.9%

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

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

      \[\leadsto x + \color{blue}{z \cdot \left(y \cdot \left|\tanh \left(\frac{t}{y}\right)\right| - x\right)} \]
    10. Step-by-step derivation
      1. expm1-log1p-u77.3%

        \[\leadsto x + z \cdot \left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(y \cdot \left|\tanh \left(\frac{t}{y}\right)\right|\right)\right)} - x\right) \]
      2. expm1-udef77.4%

        \[\leadsto x + z \cdot \left(\color{blue}{\left(e^{\mathsf{log1p}\left(y \cdot \left|\tanh \left(\frac{t}{y}\right)\right|\right)} - 1\right)} - x\right) \]
      3. add-sqr-sqrt54.6%

        \[\leadsto x + z \cdot \left(\left(e^{\mathsf{log1p}\left(y \cdot \left|\color{blue}{\sqrt{\tanh \left(\frac{t}{y}\right)} \cdot \sqrt{\tanh \left(\frac{t}{y}\right)}}\right|\right)} - 1\right) - x\right) \]
      4. fabs-sqr54.6%

        \[\leadsto x + z \cdot \left(\left(e^{\mathsf{log1p}\left(y \cdot \color{blue}{\left(\sqrt{\tanh \left(\frac{t}{y}\right)} \cdot \sqrt{\tanh \left(\frac{t}{y}\right)}\right)}\right)} - 1\right) - x\right) \]
      5. add-sqr-sqrt61.3%

        \[\leadsto x + z \cdot \left(\left(e^{\mathsf{log1p}\left(y \cdot \color{blue}{\tanh \left(\frac{t}{y}\right)}\right)} - 1\right) - x\right) \]
    11. Applied egg-rr61.3%

      \[\leadsto x + z \cdot \left(\color{blue}{\left(e^{\mathsf{log1p}\left(y \cdot \tanh \left(\frac{t}{y}\right)\right)} - 1\right)} - x\right) \]
    12. Step-by-step derivation
      1. expm1-def66.6%

        \[\leadsto x + z \cdot \left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(y \cdot \tanh \left(\frac{t}{y}\right)\right)\right)} - x\right) \]
      2. expm1-log1p96.2%

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

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

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

Alternative 3: 87.1% accurate, 1.9× speedup?

\[\begin{array}{l} y = |y|\\ \\ \begin{array}{l} t_1 := \tanh \left(\frac{t}{y}\right)\\ \mathbf{if}\;y \leq 6.4 \cdot 10^{+16}:\\ \;\;\;\;x + y \cdot \left(z \cdot t_1\right)\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \left(y \cdot t_1 - 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 6.4e+16) (+ x (* y (* z t_1))) (+ x (* z (- (* y t_1) x))))))
y = abs(y);
double code(double x, double y, double z, double t) {
	double t_1 = tanh((t / y));
	double tmp;
	if (y <= 6.4e+16) {
		tmp = x + (y * (z * t_1));
	} else {
		tmp = x + (z * ((y * t_1) - 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) :: t_1
    real(8) :: tmp
    t_1 = tanh((t / y))
    if (y <= 6.4d+16) then
        tmp = x + (y * (z * t_1))
    else
        tmp = x + (z * ((y * t_1) - x))
    end if
    code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z, double t) {
	double t_1 = Math.tanh((t / y));
	double tmp;
	if (y <= 6.4e+16) {
		tmp = x + (y * (z * t_1));
	} else {
		tmp = x + (z * ((y * t_1) - x));
	}
	return tmp;
}
y = abs(y)
def code(x, y, z, t):
	t_1 = math.tanh((t / y))
	tmp = 0
	if y <= 6.4e+16:
		tmp = x + (y * (z * t_1))
	else:
		tmp = x + (z * ((y * t_1) - x))
	return tmp
y = abs(y)
function code(x, y, z, t)
	t_1 = tanh(Float64(t / y))
	tmp = 0.0
	if (y <= 6.4e+16)
		tmp = Float64(x + Float64(y * Float64(z * t_1)));
	else
		tmp = Float64(x + Float64(z * Float64(Float64(y * t_1) - x)));
	end
	return tmp
end
y = abs(y)
function tmp_2 = code(x, y, z, t)
	t_1 = tanh((t / y));
	tmp = 0.0;
	if (y <= 6.4e+16)
		tmp = x + (y * (z * t_1));
	else
		tmp = x + (z * ((y * t_1) - x));
	end
	tmp_2 = 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, 6.4e+16], N[(x + N[(y * N[(z * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(N[(y * t$95$1), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
t_1 := \tanh \left(\frac{t}{y}\right)\\
\mathbf{if}\;y \leq 6.4 \cdot 10^{+16}:\\
\;\;\;\;x + y \cdot \left(z \cdot t_1\right)\\

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


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

    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. 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)} \]
    3. 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. div-sub26.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) \]
      3. rec-exp26.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) \]
      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-a81.1%

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

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

    if 6.4e16 < y

    1. Initial program 89.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 0 47.5%

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

        \[\leadsto x + \color{blue}{\left(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) + -1 \cdot \left(x \cdot z\right)\right)} \]
    4. Simplified84.6%

      \[\leadsto x + \color{blue}{z \cdot \left(\tanh \left(\frac{t}{y}\right) \cdot y + \left(-x\right)\right)} \]
    5. Step-by-step derivation
      1. add-sqr-sqrt53.4%

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

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

        \[\leadsto x + z \cdot \left(\sqrt{\color{blue}{{\tanh \left(\frac{t}{y}\right)}^{2}}} \cdot y + \left(-x\right)\right) \]
    6. Applied egg-rr73.3%

      \[\leadsto x + z \cdot \left(\color{blue}{\sqrt{{\tanh \left(\frac{t}{y}\right)}^{2}}} \cdot y + \left(-x\right)\right) \]
    7. Step-by-step derivation
      1. unpow273.3%

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

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

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

      \[\leadsto x + \color{blue}{z \cdot \left(y \cdot \left|\tanh \left(\frac{t}{y}\right)\right| - x\right)} \]
    10. Step-by-step derivation
      1. expm1-log1p-u72.1%

        \[\leadsto x + z \cdot \left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(y \cdot \left|\tanh \left(\frac{t}{y}\right)\right|\right)\right)} - x\right) \]
      2. expm1-udef72.1%

        \[\leadsto x + z \cdot \left(\color{blue}{\left(e^{\mathsf{log1p}\left(y \cdot \left|\tanh \left(\frac{t}{y}\right)\right|\right)} - 1\right)} - x\right) \]
      3. add-sqr-sqrt52.4%

        \[\leadsto x + z \cdot \left(\left(e^{\mathsf{log1p}\left(y \cdot \left|\color{blue}{\sqrt{\tanh \left(\frac{t}{y}\right)} \cdot \sqrt{\tanh \left(\frac{t}{y}\right)}}\right|\right)} - 1\right) - x\right) \]
      4. fabs-sqr52.4%

        \[\leadsto x + z \cdot \left(\left(e^{\mathsf{log1p}\left(y \cdot \color{blue}{\left(\sqrt{\tanh \left(\frac{t}{y}\right)} \cdot \sqrt{\tanh \left(\frac{t}{y}\right)}\right)}\right)} - 1\right) - x\right) \]
      5. add-sqr-sqrt59.2%

        \[\leadsto x + z \cdot \left(\left(e^{\mathsf{log1p}\left(y \cdot \color{blue}{\tanh \left(\frac{t}{y}\right)}\right)} - 1\right) - x\right) \]
    11. Applied egg-rr59.2%

      \[\leadsto x + z \cdot \left(\color{blue}{\left(e^{\mathsf{log1p}\left(y \cdot \tanh \left(\frac{t}{y}\right)\right)} - 1\right)} - x\right) \]
    12. Step-by-step derivation
      1. expm1-def61.6%

        \[\leadsto x + z \cdot \left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(y \cdot \tanh \left(\frac{t}{y}\right)\right)\right)} - x\right) \]
      2. expm1-log1p84.6%

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

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

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

Alternative 4: 85.5% accurate, 1.9× speedup?

\[\begin{array}{l} y = |y|\\ \\ \begin{array}{l} \mathbf{if}\;y \leq 5.2 \cdot 10^{+145}:\\ \;\;\;\;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} \]
NOTE: y should be positive before calling this function
(FPCore (x y z t)
 :precision binary64
 (if (<= y 5.2e+145) (+ x (* y (* z (tanh (/ t y))))) (+ x (* z (- t x)))))
y = abs(y);
double code(double x, double y, double z, double t) {
	double tmp;
	if (y <= 5.2e+145) {
		tmp = x + (y * (z * tanh((t / y))));
	} 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 <= 5.2d+145) then
        tmp = x + (y * (z * tanh((t / y))))
    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 <= 5.2e+145) {
		tmp = x + (y * (z * Math.tanh((t / y))));
	} else {
		tmp = x + (z * (t - x));
	}
	return tmp;
}
y = abs(y)
def code(x, y, z, t):
	tmp = 0
	if y <= 5.2e+145:
		tmp = x + (y * (z * math.tanh((t / y))))
	else:
		tmp = x + (z * (t - x))
	return tmp
y = abs(y)
function code(x, y, z, t)
	tmp = 0.0
	if (y <= 5.2e+145)
		tmp = Float64(x + Float64(y * Float64(z * tanh(Float64(t / y)))));
	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 <= 5.2e+145)
		tmp = x + (y * (z * tanh((t / y))));
	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, 5.2e+145], 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}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.2 \cdot 10^{+145}:\\
\;\;\;\;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 < 5.20000000000000005e145

    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 26.5%

      \[\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)} \]
    3. Step-by-step derivation
      1. associate-/r*26.5%

        \[\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. div-sub26.5%

        \[\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) \]
      3. rec-exp26.5%

        \[\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) \]
      4. rec-exp26.5%

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

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

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

    if 5.20000000000000005e145 < y

    1. Initial program 79.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 y around inf 87.8%

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

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

Alternative 5: 69.5% accurate, 19.0× speedup?

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

\mathbf{elif}\;y \leq 3.55 \cdot 10^{+189} \lor \neg \left(y \leq 4.1 \cdot 10^{+301}\right):\\
\;\;\;\;x - z \cdot x\\

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


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

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

        \[\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. fma-def95.3%

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

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

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

    if 2.65e17 < y < 3.55e189 or 4.0999999999999998e301 < y

    1. Initial program 95.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 0 48.1%

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

        \[\leadsto x + \color{blue}{\left(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) + -1 \cdot \left(x \cdot z\right)\right)} \]
    4. Simplified81.2%

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

      \[\leadsto \color{blue}{x \cdot \left(1 + -1 \cdot z\right)} \]
    6. Step-by-step derivation
      1. distribute-lft-in64.3%

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

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

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

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

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

        \[\leadsto x - \color{blue}{z \cdot x} \]
    7. Simplified64.3%

      \[\leadsto \color{blue}{x - z \cdot x} \]

    if 3.55e189 < y < 4.0999999999999998e301

    1. Initial program 74.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 28.3%

      \[\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)} \]
    3. Step-by-step derivation
      1. associate-/r*28.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) \]
      2. div-sub28.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) \]
      3. rec-exp28.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) \]
      4. rec-exp28.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) \]
      5. tanh-def-a61.5%

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

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

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

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

        \[\leadsto \color{blue}{z \cdot t} + x \]
    7. Simplified74.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 2.65 \cdot 10^{+17}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 3.55 \cdot 10^{+189} \lor \neg \left(y \leq 4.1 \cdot 10^{+301}\right):\\ \;\;\;\;x - z \cdot x\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot t\\ \end{array} \]

Alternative 6: 78.5% accurate, 23.5× speedup?

\[\begin{array}{l} y = |y|\\ \\ \begin{array}{l} \mathbf{if}\;y \leq 6.6 \cdot 10^{+15}:\\ \;\;\;\;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 6.6e+15) x (+ x (* z (- t x)))))
y = abs(y);
double code(double x, double y, double z, double t) {
	double tmp;
	if (y <= 6.6e+15) {
		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 <= 6.6d+15) 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 <= 6.6e+15) {
		tmp = x;
	} else {
		tmp = x + (z * (t - x));
	}
	return tmp;
}
y = abs(y)
def code(x, y, z, t):
	tmp = 0
	if y <= 6.6e+15:
		tmp = x
	else:
		tmp = x + (z * (t - x))
	return tmp
y = abs(y)
function code(x, y, z, t)
	tmp = 0.0
	if (y <= 6.6e+15)
		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 <= 6.6e+15)
		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, 6.6e+15], x, N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 6.6 \cdot 10^{+15}:\\
\;\;\;\;x\\

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


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

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

        \[\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. fma-def95.3%

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

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

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

    if 6.6e15 < y

    1. Initial program 89.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 y around inf 71.9%

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

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

Alternative 7: 70.8% accurate, 30.2× speedup?

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

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


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

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

        \[\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. fma-def95.3%

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

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

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

    if 4.19999999999999961e90 < 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. Taylor expanded in x around 0 38.6%

      \[\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)} \]
    3. Step-by-step derivation
      1. associate-/r*38.6%

        \[\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. div-sub38.6%

        \[\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) \]
      3. rec-exp38.6%

        \[\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) \]
      4. rec-exp38.6%

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

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

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

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

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

        \[\leadsto \color{blue}{z \cdot t} + x \]
    7. Simplified66.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 4.2 \cdot 10^{+90}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot t\\ \end{array} \]

Alternative 8: 61.0% 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 94.0%

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

      \[\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. fma-def94.1%

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

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

    \[\leadsto \color{blue}{x} \]
  5. Final simplification62.1%

    \[\leadsto x \]

Developer target: 97.2% 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 2023287 
(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))))))