SynthBasics:moogVCF from YampaSynth-0.2

Percentage Accurate: 93.3% → 98.1%
Time: 10.6s
Alternatives: 9
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 9 alternatives:

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

Initial Program: 93.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.1% accurate, 0.7× speedup?

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

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

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


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

    1. Initial program 97.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. +-commutative97.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. associate-*l*99.1%

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

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

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

    if 4.9999999999999999e178 < 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. Add Preprocessing
    3. Taylor expanded in y around inf 98.8%

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

Alternative 2: 96.5% accurate, 1.0× speedup?

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

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

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


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

    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. Add Preprocessing

    if 3.9999999999999998e197 < y

    1. Initial program 76.5%

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

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

Alternative 3: 81.0% accurate, 1.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 1.25 \cdot 10^{-49}:\\
\;\;\;\;x\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < 1.25e-49

    1. Initial program 96.8%

      \[x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \]
    2. Step-by-step derivation
      1. +-commutative96.8%

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

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

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

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

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

    if 1.25e-49 < y < 4.2e95

    1. Initial program 99.8%

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

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

    if 4.2e95 < y

    1. Initial program 84.8%

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

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

Alternative 4: 82.9% accurate, 1.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 1.35 \cdot 10^{-49}:\\
\;\;\;\;x\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < 1.35e-49

    1. Initial program 96.8%

      \[x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \]
    2. Step-by-step derivation
      1. +-commutative96.8%

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

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

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

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

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

    if 1.35e-49 < y < 1.89999999999999999e178

    1. Initial program 97.9%

      \[x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. sub-neg97.9%

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

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

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

      \[\leadsto x + \left(\left(y \cdot z\right) \cdot \tanh \left(\frac{t}{y}\right) + \color{blue}{-1 \cdot \left(x \cdot z\right)}\right) \]
    6. Step-by-step derivation
      1. associate-+r+78.3%

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

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

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

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

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

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

    if 1.89999999999999999e178 < 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. Add Preprocessing
    3. Taylor expanded in y around inf 98.8%

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

Alternative 5: 61.8% accurate, 8.5× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -4.4 \cdot 10^{-173}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -2.5 \cdot 10^{-204}:\\ \;\;\;\;t \cdot z\\ \mathbf{elif}\;x \leq -2.1 \cdot 10^{-244}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 2.1 \cdot 10^{-136}:\\ \;\;\;\;z \cdot \left(t - x\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z t)
 :precision binary64
 (if (<= x -4.4e-173)
   x
   (if (<= x -2.5e-204)
     (* t z)
     (if (<= x -2.1e-244) x (if (<= x 2.1e-136) (* z (- t x)) x)))))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
	double tmp;
	if (x <= -4.4e-173) {
		tmp = x;
	} else if (x <= -2.5e-204) {
		tmp = t * z;
	} else if (x <= -2.1e-244) {
		tmp = x;
	} else if (x <= 2.1e-136) {
		tmp = z * (t - x);
	} else {
		tmp = x;
	}
	return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if (x <= (-4.4d-173)) then
        tmp = x
    else if (x <= (-2.5d-204)) then
        tmp = t * z
    else if (x <= (-2.1d-244)) then
        tmp = x
    else if (x <= 2.1d-136) then
        tmp = z * (t - x)
    else
        tmp = x
    end if
    code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z, double t) {
	double tmp;
	if (x <= -4.4e-173) {
		tmp = x;
	} else if (x <= -2.5e-204) {
		tmp = t * z;
	} else if (x <= -2.1e-244) {
		tmp = x;
	} else if (x <= 2.1e-136) {
		tmp = z * (t - x);
	} else {
		tmp = x;
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z, t):
	tmp = 0
	if x <= -4.4e-173:
		tmp = x
	elif x <= -2.5e-204:
		tmp = t * z
	elif x <= -2.1e-244:
		tmp = x
	elif x <= 2.1e-136:
		tmp = z * (t - x)
	else:
		tmp = x
	return tmp
y_m = abs(y)
function code(x, y_m, z, t)
	tmp = 0.0
	if (x <= -4.4e-173)
		tmp = x;
	elseif (x <= -2.5e-204)
		tmp = Float64(t * z);
	elseif (x <= -2.1e-244)
		tmp = x;
	elseif (x <= 2.1e-136)
		tmp = Float64(z * Float64(t - x));
	else
		tmp = x;
	end
	return tmp
end
y_m = abs(y);
function tmp_2 = code(x, y_m, z, t)
	tmp = 0.0;
	if (x <= -4.4e-173)
		tmp = x;
	elseif (x <= -2.5e-204)
		tmp = t * z;
	elseif (x <= -2.1e-244)
		tmp = x;
	elseif (x <= 2.1e-136)
		tmp = z * (t - x);
	else
		tmp = x;
	end
	tmp_2 = tmp;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_, t_] := If[LessEqual[x, -4.4e-173], x, If[LessEqual[x, -2.5e-204], N[(t * z), $MachinePrecision], If[LessEqual[x, -2.1e-244], x, If[LessEqual[x, 2.1e-136], N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision], x]]]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.4 \cdot 10^{-173}:\\
\;\;\;\;x\\

\mathbf{elif}\;x \leq -2.5 \cdot 10^{-204}:\\
\;\;\;\;t \cdot z\\

\mathbf{elif}\;x \leq -2.1 \cdot 10^{-244}:\\
\;\;\;\;x\\

\mathbf{elif}\;x \leq 2.1 \cdot 10^{-136}:\\
\;\;\;\;z \cdot \left(t - x\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -4.3999999999999999e-173 or -2.5000000000000001e-204 < x < -2.10000000000000002e-244 or 2.0999999999999999e-136 < x

    1. Initial program 96.5%

      \[x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \]
    2. Step-by-step derivation
      1. +-commutative96.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. associate-*l*99.2%

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

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

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

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

    if -4.3999999999999999e-173 < x < -2.5000000000000001e-204

    1. Initial program 99.4%

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

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

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

    if -2.10000000000000002e-244 < x < 2.0999999999999999e-136

    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. Add Preprocessing
    3. Taylor expanded in y around inf 54.0%

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

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

Alternative 6: 60.8% accurate, 9.2× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -4 \cdot 10^{-177}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -1.9 \cdot 10^{-204}:\\ \;\;\;\;t \cdot z\\ \mathbf{elif}\;x \leq -1.4 \cdot 10^{-244}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 3.2 \cdot 10^{-136}:\\ \;\;\;\;t \cdot z\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z t)
 :precision binary64
 (if (<= x -4e-177)
   x
   (if (<= x -1.9e-204)
     (* t z)
     (if (<= x -1.4e-244) x (if (<= x 3.2e-136) (* t z) x)))))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
	double tmp;
	if (x <= -4e-177) {
		tmp = x;
	} else if (x <= -1.9e-204) {
		tmp = t * z;
	} else if (x <= -1.4e-244) {
		tmp = x;
	} else if (x <= 3.2e-136) {
		tmp = t * z;
	} else {
		tmp = x;
	}
	return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if (x <= (-4d-177)) then
        tmp = x
    else if (x <= (-1.9d-204)) then
        tmp = t * z
    else if (x <= (-1.4d-244)) then
        tmp = x
    else if (x <= 3.2d-136) then
        tmp = t * z
    else
        tmp = x
    end if
    code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z, double t) {
	double tmp;
	if (x <= -4e-177) {
		tmp = x;
	} else if (x <= -1.9e-204) {
		tmp = t * z;
	} else if (x <= -1.4e-244) {
		tmp = x;
	} else if (x <= 3.2e-136) {
		tmp = t * z;
	} else {
		tmp = x;
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z, t):
	tmp = 0
	if x <= -4e-177:
		tmp = x
	elif x <= -1.9e-204:
		tmp = t * z
	elif x <= -1.4e-244:
		tmp = x
	elif x <= 3.2e-136:
		tmp = t * z
	else:
		tmp = x
	return tmp
y_m = abs(y)
function code(x, y_m, z, t)
	tmp = 0.0
	if (x <= -4e-177)
		tmp = x;
	elseif (x <= -1.9e-204)
		tmp = Float64(t * z);
	elseif (x <= -1.4e-244)
		tmp = x;
	elseif (x <= 3.2e-136)
		tmp = Float64(t * z);
	else
		tmp = x;
	end
	return tmp
end
y_m = abs(y);
function tmp_2 = code(x, y_m, z, t)
	tmp = 0.0;
	if (x <= -4e-177)
		tmp = x;
	elseif (x <= -1.9e-204)
		tmp = t * z;
	elseif (x <= -1.4e-244)
		tmp = x;
	elseif (x <= 3.2e-136)
		tmp = t * z;
	else
		tmp = x;
	end
	tmp_2 = tmp;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_, t_] := If[LessEqual[x, -4e-177], x, If[LessEqual[x, -1.9e-204], N[(t * z), $MachinePrecision], If[LessEqual[x, -1.4e-244], x, If[LessEqual[x, 3.2e-136], N[(t * z), $MachinePrecision], x]]]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
\mathbf{if}\;x \leq -4 \cdot 10^{-177}:\\
\;\;\;\;x\\

\mathbf{elif}\;x \leq -1.9 \cdot 10^{-204}:\\
\;\;\;\;t \cdot z\\

\mathbf{elif}\;x \leq -1.4 \cdot 10^{-244}:\\
\;\;\;\;x\\

\mathbf{elif}\;x \leq 3.2 \cdot 10^{-136}:\\
\;\;\;\;t \cdot z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -3.99999999999999981e-177 or -1.89999999999999991e-204 < x < -1.40000000000000007e-244 or 3.19999999999999993e-136 < x

    1. Initial program 96.5%

      \[x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \]
    2. Step-by-step derivation
      1. +-commutative96.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. associate-*l*99.2%

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

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

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

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

    if -3.99999999999999981e-177 < x < -1.89999999999999991e-204 or -1.40000000000000007e-244 < x < 3.19999999999999993e-136

    1. Initial program 86.9%

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

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

      \[\leadsto \color{blue}{t \cdot z} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 7: 77.4% accurate, 17.7× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;y\_m \leq 620000000000:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \left(t - x\right)\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z t)
 :precision binary64
 (if (<= y_m 620000000000.0) x (+ x (* z (- t x)))))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
	double tmp;
	if (y_m <= 620000000000.0) {
		tmp = x;
	} else {
		tmp = x + (z * (t - x));
	}
	return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if (y_m <= 620000000000.0d0) then
        tmp = x
    else
        tmp = x + (z * (t - x))
    end if
    code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z, double t) {
	double tmp;
	if (y_m <= 620000000000.0) {
		tmp = x;
	} else {
		tmp = x + (z * (t - x));
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z, t):
	tmp = 0
	if y_m <= 620000000000.0:
		tmp = x
	else:
		tmp = x + (z * (t - x))
	return tmp
y_m = abs(y)
function code(x, y_m, z, t)
	tmp = 0.0
	if (y_m <= 620000000000.0)
		tmp = x;
	else
		tmp = Float64(x + Float64(z * Float64(t - x)));
	end
	return tmp
end
y_m = abs(y);
function tmp_2 = code(x, y_m, z, t)
	tmp = 0.0;
	if (y_m <= 620000000000.0)
		tmp = x;
	else
		tmp = x + (z * (t - x));
	end
	tmp_2 = tmp;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_, t_] := If[LessEqual[y$95$m, 620000000000.0], x, N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 620000000000:\\
\;\;\;\;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.2e11

    1. Initial program 96.9%

      \[x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \]
    2. Step-by-step derivation
      1. +-commutative96.9%

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

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

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

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

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

    if 6.2e11 < y

    1. Initial program 88.4%

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

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

Alternative 8: 70.9% accurate, 21.3× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;y\_m \leq 155000000:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x + t \cdot z\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z t)
 :precision binary64
 (if (<= y_m 155000000.0) x (+ x (* t z))))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
	double tmp;
	if (y_m <= 155000000.0) {
		tmp = x;
	} else {
		tmp = x + (t * z);
	}
	return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if (y_m <= 155000000.0d0) then
        tmp = x
    else
        tmp = x + (t * z)
    end if
    code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z, double t) {
	double tmp;
	if (y_m <= 155000000.0) {
		tmp = x;
	} else {
		tmp = x + (t * z);
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z, t):
	tmp = 0
	if y_m <= 155000000.0:
		tmp = x
	else:
		tmp = x + (t * z)
	return tmp
y_m = abs(y)
function code(x, y_m, z, t)
	tmp = 0.0
	if (y_m <= 155000000.0)
		tmp = x;
	else
		tmp = Float64(x + Float64(t * z));
	end
	return tmp
end
y_m = abs(y);
function tmp_2 = code(x, y_m, z, t)
	tmp = 0.0;
	if (y_m <= 155000000.0)
		tmp = x;
	else
		tmp = x + (t * z);
	end
	tmp_2 = tmp;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_, t_] := If[LessEqual[y$95$m, 155000000.0], x, N[(x + N[(t * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|

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

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


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

    1. Initial program 96.9%

      \[x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \]
    2. Step-by-step derivation
      1. +-commutative96.9%

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

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

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

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

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

    if 1.55e8 < y

    1. Initial program 88.5%

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

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

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

Alternative 9: 60.5% accurate, 213.0× speedup?

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

\\
x
\end{array}
Derivation
  1. Initial program 94.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. +-commutative94.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. associate-*l*97.1%

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

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

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

    \[\leadsto \color{blue}{x} \]
  6. Add Preprocessing

Developer target: 97.1% accurate, 1.0× speedup?

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

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

Reproduce

?
herbie shell --seed 2024076 -o generate:simplify
(FPCore (x y z t)
  :name "SynthBasics:moogVCF from YampaSynth-0.2"
  :precision binary64

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

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