SynthBasics:moogVCF from YampaSynth-0.2

Percentage Accurate: 93.3% → 98.4%
Time: 13.1s
Alternatives: 13
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 13 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.3% accurate, 1.0× speedup?

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

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

Alternative 1: 98.4% accurate, 0.4× speedup?

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

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

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


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

    1. Initial program 97.1%

      \[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. +-commutative97.1%

        \[\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. *-commutative97.1%

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

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

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

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

    if 4.9999999999999998e297 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y)))))

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

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

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

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

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

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

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

Alternative 2: 97.5% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 94.1%

      \[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. associate-*l*96.2%

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

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

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

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

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

    if 2.4000000000000003e195 < y

    1. Initial program 87.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. associate-*l*94.1%

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

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

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

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

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

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

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

Alternative 3: 97.5% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 94.1%

      \[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. associate-*l*96.2%

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

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

    if 1.1e195 < y

    1. Initial program 87.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. associate-*l*94.1%

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

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

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

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

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

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

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

Alternative 4: 83.7% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 94.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. +-commutative94.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. *-commutative94.2%

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

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

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

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

      \[\leadsto \mathsf{fma}\left(z, \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\right) \]
    5. Step-by-step derivation
      1. associate-/r*21.7%

        \[\leadsto \mathsf{fma}\left(z, y \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), x\right) \]
      2. div-sub21.7%

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

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

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

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

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

    if 3.6999999999999999e48 < y

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(z, \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)}, x\right) \]
    5. Step-by-step derivation
      1. neg-mul-170.7%

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

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

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

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

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

Alternative 5: 83.7% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 94.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. +-commutative94.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. *-commutative94.2%

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

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

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

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

      \[\leadsto \mathsf{fma}\left(z, \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\right) \]
    5. Step-by-step derivation
      1. associate-/r*21.7%

        \[\leadsto \mathsf{fma}\left(z, y \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), x\right) \]
      2. div-sub21.7%

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

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

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

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

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

    if 2.50000000000000011e47 < y

    1. Initial program 90.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 86.6%

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

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

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

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

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

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

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

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

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

Alternative 6: 83.7% accurate, 1.9× speedup?

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

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

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


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

    1. Initial program 94.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. +-commutative94.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. *-commutative94.2%

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

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

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

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

      \[\leadsto \mathsf{fma}\left(z, \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\right) \]
    5. Step-by-step derivation
      1. associate-/r*21.7%

        \[\leadsto \mathsf{fma}\left(z, y \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), x\right) \]
      2. div-sub21.7%

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

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

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

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

      \[\leadsto \mathsf{fma}\left(z, \color{blue}{y \cdot \tanh \left(\frac{t}{y}\right)}, x\right) \]
    7. Step-by-step derivation
      1. fma-udef81.0%

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

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

    if 6.49999999999999988e47 < y

    1. Initial program 90.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 86.6%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 6.5 \cdot 10^{+47}:\\ \;\;\;\;x + z \cdot \left(y \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 7: 81.8% accurate, 1.9× speedup?

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

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

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


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

    1. Initial program 94.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. associate-*l*95.7%

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

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

      \[\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)} \]
    5. Step-by-step derivation
      1. *-commutative21.7%

        \[\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*21.6%

        \[\leadsto x + \color{blue}{\left(y \cdot z\right) \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)} \]
      3. associate-/r*21.6%

        \[\leadsto x + \left(y \cdot z\right) \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) \]
      4. div-sub21.6%

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

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

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

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

    if 7.8000000000000002e48 < y

    1. Initial program 90.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. associate-*l*97.3%

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

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

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

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

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

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

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

Alternative 8: 82.3% accurate, 1.9× speedup?

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

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

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


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

    1. Initial program 94.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. +-commutative94.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. *-commutative94.2%

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

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

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

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

      \[\leadsto \mathsf{fma}\left(z, \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\right) \]
    5. Step-by-step derivation
      1. associate-/r*21.7%

        \[\leadsto \mathsf{fma}\left(z, y \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), x\right) \]
      2. div-sub21.7%

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

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

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

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

      \[\leadsto \mathsf{fma}\left(z, \color{blue}{y \cdot \tanh \left(\frac{t}{y}\right)}, x\right) \]
    7. Step-by-step derivation
      1. fma-udef81.0%

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

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

    if 1.26000000000000001e48 < y

    1. Initial program 90.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. associate-*l*97.3%

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

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

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

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

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

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

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

Alternative 9: 68.4% accurate, 2.0× speedup?

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

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

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


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

    1. Initial program 94.1%

      \[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. associate-*l*95.6%

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

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

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

    if 2.45000000000000013e35 < y

    1. Initial program 91.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. associate-*l*97.4%

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

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

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

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

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

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

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

Alternative 10: 64.3% accurate, 19.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 1.45 \cdot 10^{+35}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.04 \cdot 10^{+226} \lor \neg \left(y \leq 1.02 \cdot 10^{+257}\right):\\ \;\;\;\;x + z \cdot t\\ \mathbf{else}:\\ \;\;\;\;x - x \cdot z\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (<= y 1.45e+35)
   x
   (if (or (<= y 1.04e+226) (not (<= y 1.02e+257)))
     (+ x (* z t))
     (- x (* x z)))))
double code(double x, double y, double z, double t) {
	double tmp;
	if (y <= 1.45e+35) {
		tmp = x;
	} else if ((y <= 1.04e+226) || !(y <= 1.02e+257)) {
		tmp = x + (z * t);
	} else {
		tmp = x - (x * z);
	}
	return tmp;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if (y <= 1.45d+35) then
        tmp = x
    else if ((y <= 1.04d+226) .or. (.not. (y <= 1.02d+257))) then
        tmp = x + (z * t)
    else
        tmp = x - (x * z)
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (y <= 1.45e+35) {
		tmp = x;
	} else if ((y <= 1.04e+226) || !(y <= 1.02e+257)) {
		tmp = x + (z * t);
	} else {
		tmp = x - (x * z);
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if y <= 1.45e+35:
		tmp = x
	elif (y <= 1.04e+226) or not (y <= 1.02e+257):
		tmp = x + (z * t)
	else:
		tmp = x - (x * z)
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if (y <= 1.45e+35)
		tmp = x;
	elseif ((y <= 1.04e+226) || !(y <= 1.02e+257))
		tmp = Float64(x + Float64(z * t));
	else
		tmp = Float64(x - Float64(x * z));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (y <= 1.45e+35)
		tmp = x;
	elseif ((y <= 1.04e+226) || ~((y <= 1.02e+257)))
		tmp = x + (z * t);
	else
		tmp = x - (x * z);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.45e+35], x, If[Or[LessEqual[y, 1.04e+226], N[Not[LessEqual[y, 1.02e+257]], $MachinePrecision]], N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision], N[(x - N[(x * z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq 1.04 \cdot 10^{+226} \lor \neg \left(y \leq 1.02 \cdot 10^{+257}\right):\\
\;\;\;\;x + z \cdot t\\

\mathbf{else}:\\
\;\;\;\;x - x \cdot z\\


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

    1. Initial program 94.1%

      \[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. associate-*l*95.6%

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

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

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

    if 1.44999999999999997e35 < y < 1.04000000000000002e226 or 1.02e257 < y

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

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

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

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

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

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

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

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

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

    if 1.04000000000000002e226 < y < 1.02e257

    1. Initial program 84.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. +-commutative84.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. *-commutative84.6%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{x - z \cdot x} \]
    7. Simplified100.0%

      \[\leadsto \color{blue}{x - z \cdot x} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification69.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 1.45 \cdot 10^{+35}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.04 \cdot 10^{+226} \lor \neg \left(y \leq 1.02 \cdot 10^{+257}\right):\\ \;\;\;\;x + z \cdot t\\ \mathbf{else}:\\ \;\;\;\;x - x \cdot z\\ \end{array} \]

Alternative 11: 68.4% accurate, 23.5× speedup?

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

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

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


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

    1. Initial program 94.1%

      \[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. associate-*l*95.6%

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

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

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

    if 1.40000000000000004e34 < y

    1. Initial program 91.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. +-commutative91.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. *-commutative91.0%

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

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

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

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

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

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

Alternative 12: 64.6% accurate, 30.2× speedup?

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

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

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


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

    1. Initial program 94.1%

      \[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. associate-*l*95.6%

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

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

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

    if 8.4999999999999998e33 < y

    1. Initial program 91.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. +-commutative91.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. *-commutative91.0%

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

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

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

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

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

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

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

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

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

Alternative 13: 59.2% accurate, 213.0× speedup?

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

\\
x
\end{array}
Derivation
  1. Initial program 93.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. associate-*l*96.0%

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

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

    \[\leadsto \color{blue}{x} \]
  5. Final simplification64.2%

    \[\leadsto x \]

Developer target: 97.0% accurate, 1.0× speedup?

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

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

Reproduce

?
herbie shell --seed 2023224 
(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))))))