SynthBasics:moogVCF from YampaSynth-0.2

Percentage Accurate: 93.9% → 98.9%
Time: 12.3s
Alternatives: 9
Speedup: 0.5×

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.9% 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.9% accurate, 0.5× 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^{+302}:\\ \;\;\;\;\mathsf{fma}\left(y \cdot t\_1, z, x\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(t - x\right)\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (- (tanh (/ t y)) (tanh (/ x y)))))
   (if (<= (+ x (* (* y z) t_1)) 5e+302) (fma (* y t_1) z 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+302) {
		tmp = fma((y * t_1), z, x);
	} else {
		tmp = z * (t - x);
	}
	return tmp;
}
function code(x, y, z, t)
	t_1 = Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))
	tmp = 0.0
	if (Float64(x + Float64(Float64(y * z) * t_1)) <= 5e+302)
		tmp = fma(Float64(y * t_1), z, x);
	else
		tmp = Float64(z * Float64(t - x));
	end
	return tmp
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x + N[(N[(y * z), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision], 5e+302], N[(N[(y * t$95$1), $MachinePrecision] * z + x), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

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


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

    1. Initial program 98.3%

      \[x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-+.f64N/A

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

        \[\leadsto \color{blue}{\left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) + x} \]
      3. lift-*.f64N/A

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

        \[\leadsto \color{blue}{\left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot \left(y \cdot z\right)} + x \]
      5. lift-*.f64N/A

        \[\leadsto \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot \color{blue}{\left(y \cdot z\right)} + x \]
      6. associate-*r*N/A

        \[\leadsto \color{blue}{\left(\left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot y\right) \cdot z} + x \]
      7. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot y, z, x\right)} \]
      8. lower-*.f6499.6

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

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

    if 5e302 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y)))))

    1. Initial program 46.7%

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

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

        \[\leadsto \color{blue}{z \cdot \left(t - x\right) + x} \]
      2. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(z, t - x, x\right)} \]
      3. lower--.f64100.0

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(z, t - x, x\right)} \]
    6. Taylor expanded in z around inf

      \[\leadsto z \cdot \color{blue}{\left(t - x\right)} \]
    7. Step-by-step derivation
      1. Applied rewrites100.0%

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

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

    Alternative 2: 78.4% accurate, 1.6× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_1 := \mathsf{fma}\left(\frac{t}{y} - \tanh \left(\frac{x}{y}\right), y \cdot z, x\right)\\ \mathbf{if}\;x \leq -3.4 \cdot 10^{-37}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq 6.5 \cdot 10^{+49}:\\ \;\;\;\;\mathsf{fma}\left(y \cdot \left(\tanh \left(\frac{t}{y}\right) - \frac{x}{y}\right), z, x\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
    (FPCore (x y z t)
     :precision binary64
     (let* ((t_1 (fma (- (/ t y) (tanh (/ x y))) (* y z) x)))
       (if (<= x -3.4e-37)
         t_1
         (if (<= x 6.5e+49) (fma (* y (- (tanh (/ t y)) (/ x y))) z x) t_1))))
    double code(double x, double y, double z, double t) {
    	double t_1 = fma(((t / y) - tanh((x / y))), (y * z), x);
    	double tmp;
    	if (x <= -3.4e-37) {
    		tmp = t_1;
    	} else if (x <= 6.5e+49) {
    		tmp = fma((y * (tanh((t / y)) - (x / y))), z, x);
    	} else {
    		tmp = t_1;
    	}
    	return tmp;
    }
    
    function code(x, y, z, t)
    	t_1 = fma(Float64(Float64(t / y) - tanh(Float64(x / y))), Float64(y * z), x)
    	tmp = 0.0
    	if (x <= -3.4e-37)
    		tmp = t_1;
    	elseif (x <= 6.5e+49)
    		tmp = fma(Float64(y * Float64(tanh(Float64(t / y)) - Float64(x / y))), z, x);
    	else
    		tmp = t_1;
    	end
    	return tmp
    end
    
    code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(N[(t / y), $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(y * z), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[x, -3.4e-37], t$95$1, If[LessEqual[x, 6.5e+49], N[(N[(y * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * z + x), $MachinePrecision], t$95$1]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_1 := \mathsf{fma}\left(\frac{t}{y} - \tanh \left(\frac{x}{y}\right), y \cdot z, x\right)\\
    \mathbf{if}\;x \leq -3.4 \cdot 10^{-37}:\\
    \;\;\;\;t\_1\\
    
    \mathbf{elif}\;x \leq 6.5 \cdot 10^{+49}:\\
    \;\;\;\;\mathsf{fma}\left(y \cdot \left(\tanh \left(\frac{t}{y}\right) - \frac{x}{y}\right), z, x\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_1\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if x < -3.40000000000000018e-37 or 6.5000000000000005e49 < x

      1. Initial program 100.0%

        \[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 t around 0

        \[\leadsto x + \left(y \cdot z\right) \cdot \left(\color{blue}{\frac{t}{y}} - \tanh \left(\frac{x}{y}\right)\right) \]
      4. Step-by-step derivation
        1. lower-/.f6474.9

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

        \[\leadsto x + \left(y \cdot z\right) \cdot \left(\color{blue}{\frac{t}{y}} - \tanh \left(\frac{x}{y}\right)\right) \]
      6. Step-by-step derivation
        1. lift-+.f64N/A

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

          \[\leadsto \color{blue}{\left(y \cdot z\right) \cdot \left(\frac{t}{y} - \tanh \left(\frac{x}{y}\right)\right) + x} \]
        3. lift-*.f64N/A

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

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

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

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

      if -3.40000000000000018e-37 < x < 6.5000000000000005e49

      1. Initial program 88.1%

        \[x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \]
      2. Add Preprocessing
      3. Step-by-step derivation
        1. lift-+.f64N/A

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

          \[\leadsto \color{blue}{\left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) + x} \]
        3. lift-*.f64N/A

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

          \[\leadsto \color{blue}{\left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot \left(y \cdot z\right)} + x \]
        5. lift-*.f64N/A

          \[\leadsto \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot \color{blue}{\left(y \cdot z\right)} + x \]
        6. associate-*r*N/A

          \[\leadsto \color{blue}{\left(\left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot y\right) \cdot z} + x \]
        7. lower-fma.f64N/A

          \[\leadsto \color{blue}{\mathsf{fma}\left(\left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot y, z, x\right)} \]
        8. lower-*.f6494.2

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

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

        \[\leadsto \mathsf{fma}\left(\left(\tanh \left(\frac{t}{y}\right) - \color{blue}{\frac{x}{y}}\right) \cdot y, z, x\right) \]
      6. Step-by-step derivation
        1. lower-/.f6483.3

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

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

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

    Alternative 3: 61.7% accurate, 1.6× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 24500:\\ \;\;\;\;t \cdot \frac{x}{t}\\ \mathbf{elif}\;y \leq 1.8 \cdot 10^{+203}:\\ \;\;\;\;\mathsf{fma}\left(y \cdot \left(\tanh \left(\frac{t}{y}\right) - \frac{x}{y}\right), z, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\ \end{array} \end{array} \]
    (FPCore (x y z t)
     :precision binary64
     (if (<= y 24500.0)
       (* t (/ x t))
       (if (<= y 1.8e+203)
         (fma (* y (- (tanh (/ t y)) (/ x y))) z x)
         (fma z (- t x) x))))
    double code(double x, double y, double z, double t) {
    	double tmp;
    	if (y <= 24500.0) {
    		tmp = t * (x / t);
    	} else if (y <= 1.8e+203) {
    		tmp = fma((y * (tanh((t / y)) - (x / y))), z, x);
    	} else {
    		tmp = fma(z, (t - x), x);
    	}
    	return tmp;
    }
    
    function code(x, y, z, t)
    	tmp = 0.0
    	if (y <= 24500.0)
    		tmp = Float64(t * Float64(x / t));
    	elseif (y <= 1.8e+203)
    		tmp = fma(Float64(y * Float64(tanh(Float64(t / y)) - Float64(x / y))), z, x);
    	else
    		tmp = fma(z, Float64(t - x), x);
    	end
    	return tmp
    end
    
    code[x_, y_, z_, t_] := If[LessEqual[y, 24500.0], N[(t * N[(x / t), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.8e+203], N[(N[(y * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * z + x), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;y \leq 24500:\\
    \;\;\;\;t \cdot \frac{x}{t}\\
    
    \mathbf{elif}\;y \leq 1.8 \cdot 10^{+203}:\\
    \;\;\;\;\mathsf{fma}\left(y \cdot \left(\tanh \left(\frac{t}{y}\right) - \frac{x}{y}\right), z, x\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if y < 24500

      1. Initial program 96.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

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

          \[\leadsto \color{blue}{z \cdot \left(t - x\right) + x} \]
        2. lower-fma.f64N/A

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(z, t - x, x\right)} \]
      6. Taylor expanded in t around inf

        \[\leadsto t \cdot \color{blue}{z} \]
      7. Step-by-step derivation
        1. Applied rewrites11.1%

          \[\leadsto z \cdot \color{blue}{t} \]
        2. Taylor expanded in t around inf

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

            \[\leadsto t \cdot \color{blue}{\mathsf{fma}\left(-x, \frac{z}{t}, \frac{x}{t} + z\right)} \]
          2. Taylor expanded in z around 0

            \[\leadsto t \cdot \frac{x}{t} \]
          3. Step-by-step derivation
            1. Applied rewrites56.6%

              \[\leadsto t \cdot \frac{x}{t} \]

            if 24500 < y < 1.79999999999999991e203

            1. Initial program 97.5%

              \[x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \]
            2. Add Preprocessing
            3. Step-by-step derivation
              1. lift-+.f64N/A

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

                \[\leadsto \color{blue}{\left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) + x} \]
              3. lift-*.f64N/A

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

                \[\leadsto \color{blue}{\left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot \left(y \cdot z\right)} + x \]
              5. lift-*.f64N/A

                \[\leadsto \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot \color{blue}{\left(y \cdot z\right)} + x \]
              6. associate-*r*N/A

                \[\leadsto \color{blue}{\left(\left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot y\right) \cdot z} + x \]
              7. lower-fma.f64N/A

                \[\leadsto \color{blue}{\mathsf{fma}\left(\left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot y, z, x\right)} \]
              8. lower-*.f64100.0

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

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

              \[\leadsto \mathsf{fma}\left(\left(\tanh \left(\frac{t}{y}\right) - \color{blue}{\frac{x}{y}}\right) \cdot y, z, x\right) \]
            6. Step-by-step derivation
              1. lower-/.f6484.3

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

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

            if 1.79999999999999991e203 < y

            1. Initial program 61.7%

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

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

                \[\leadsto \color{blue}{z \cdot \left(t - x\right) + x} \]
              2. lower-fma.f64N/A

                \[\leadsto \color{blue}{\mathsf{fma}\left(z, t - x, x\right)} \]
              3. lower--.f64100.0

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

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

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

          Alternative 4: 59.4% accurate, 10.4× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 5.6 \cdot 10^{+20}:\\ \;\;\;\;t \cdot \frac{x}{t}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\ \end{array} \end{array} \]
          (FPCore (x y z t)
           :precision binary64
           (if (<= y 5.6e+20) (* t (/ x t)) (fma z (- t x) x)))
          double code(double x, double y, double z, double t) {
          	double tmp;
          	if (y <= 5.6e+20) {
          		tmp = t * (x / t);
          	} else {
          		tmp = fma(z, (t - x), x);
          	}
          	return tmp;
          }
          
          function code(x, y, z, t)
          	tmp = 0.0
          	if (y <= 5.6e+20)
          		tmp = Float64(t * Float64(x / t));
          	else
          		tmp = fma(z, Float64(t - x), x);
          	end
          	return tmp
          end
          
          code[x_, y_, z_, t_] := If[LessEqual[y, 5.6e+20], N[(t * N[(x / t), $MachinePrecision]), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;y \leq 5.6 \cdot 10^{+20}:\\
          \;\;\;\;t \cdot \frac{x}{t}\\
          
          \mathbf{else}:\\
          \;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if y < 5.6e20

            1. Initial program 96.7%

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

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

                \[\leadsto \color{blue}{z \cdot \left(t - x\right) + x} \]
              2. lower-fma.f64N/A

                \[\leadsto \color{blue}{\mathsf{fma}\left(z, t - x, x\right)} \]
              3. lower--.f6448.0

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

              \[\leadsto \color{blue}{\mathsf{fma}\left(z, t - x, x\right)} \]
            6. Taylor expanded in t around inf

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

                \[\leadsto z \cdot \color{blue}{t} \]
              2. Taylor expanded in t around inf

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

                  \[\leadsto t \cdot \color{blue}{\mathsf{fma}\left(-x, \frac{z}{t}, \frac{x}{t} + z\right)} \]
                2. Taylor expanded in z around 0

                  \[\leadsto t \cdot \frac{x}{t} \]
                3. Step-by-step derivation
                  1. Applied rewrites56.2%

                    \[\leadsto t \cdot \frac{x}{t} \]

                  if 5.6e20 < y

                  1. Initial program 83.1%

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

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

                      \[\leadsto \color{blue}{z \cdot \left(t - x\right) + x} \]
                    2. lower-fma.f64N/A

                      \[\leadsto \color{blue}{\mathsf{fma}\left(z, t - x, x\right)} \]
                    3. lower--.f6483.2

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

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

                Alternative 5: 63.2% accurate, 11.4× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} t_1 := z \cdot \left(t - x\right)\\ \mathbf{if}\;z \leq -112000:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq 12.5:\\ \;\;\;\;\mathsf{fma}\left(z, -x, x\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
                (FPCore (x y z t)
                 :precision binary64
                 (let* ((t_1 (* z (- t x))))
                   (if (<= z -112000.0) t_1 (if (<= z 12.5) (fma z (- x) x) t_1))))
                double code(double x, double y, double z, double t) {
                	double t_1 = z * (t - x);
                	double tmp;
                	if (z <= -112000.0) {
                		tmp = t_1;
                	} else if (z <= 12.5) {
                		tmp = fma(z, -x, x);
                	} else {
                		tmp = t_1;
                	}
                	return tmp;
                }
                
                function code(x, y, z, t)
                	t_1 = Float64(z * Float64(t - x))
                	tmp = 0.0
                	if (z <= -112000.0)
                		tmp = t_1;
                	elseif (z <= 12.5)
                		tmp = fma(z, Float64(-x), x);
                	else
                		tmp = t_1;
                	end
                	return tmp
                end
                
                code[x_, y_, z_, t_] := Block[{t$95$1 = N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -112000.0], t$95$1, If[LessEqual[z, 12.5], N[(z * (-x) + x), $MachinePrecision], t$95$1]]]
                
                \begin{array}{l}
                
                \\
                \begin{array}{l}
                t_1 := z \cdot \left(t - x\right)\\
                \mathbf{if}\;z \leq -112000:\\
                \;\;\;\;t\_1\\
                
                \mathbf{elif}\;z \leq 12.5:\\
                \;\;\;\;\mathsf{fma}\left(z, -x, x\right)\\
                
                \mathbf{else}:\\
                \;\;\;\;t\_1\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 2 regimes
                2. if z < -112000 or 12.5 < z

                  1. Initial program 89.3%

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

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

                      \[\leadsto \color{blue}{z \cdot \left(t - x\right) + x} \]
                    2. lower-fma.f64N/A

                      \[\leadsto \color{blue}{\mathsf{fma}\left(z, t - x, x\right)} \]
                    3. lower--.f6438.4

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

                    \[\leadsto \color{blue}{\mathsf{fma}\left(z, t - x, x\right)} \]
                  6. Taylor expanded in z around inf

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

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

                    if -112000 < z < 12.5

                    1. Initial program 99.7%

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

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

                        \[\leadsto \color{blue}{z \cdot \left(t - x\right) + x} \]
                      2. lower-fma.f64N/A

                        \[\leadsto \color{blue}{\mathsf{fma}\left(z, t - x, x\right)} \]
                      3. lower--.f6471.8

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

                      \[\leadsto \color{blue}{\mathsf{fma}\left(z, t - x, x\right)} \]
                    6. Taylor expanded in t around 0

                      \[\leadsto \mathsf{fma}\left(z, -1 \cdot \color{blue}{x}, x\right) \]
                    7. Step-by-step derivation
                      1. Applied rewrites87.4%

                        \[\leadsto \mathsf{fma}\left(z, -x, x\right) \]
                    8. Recombined 2 regimes into one program.
                    9. Add Preprocessing

                    Alternative 6: 21.2% accurate, 11.9× speedup?

                    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;t \leq -2.4 \cdot 10^{-102}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;t \leq 9 \cdot 10^{-91}:\\ \;\;\;\;z \cdot \left(-x\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot t\\ \end{array} \end{array} \]
                    (FPCore (x y z t)
                     :precision binary64
                     (if (<= t -2.4e-102) (* z t) (if (<= t 9e-91) (* z (- x)) (* z t))))
                    double code(double x, double y, double z, double t) {
                    	double tmp;
                    	if (t <= -2.4e-102) {
                    		tmp = z * t;
                    	} else if (t <= 9e-91) {
                    		tmp = z * -x;
                    	} else {
                    		tmp = 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 (t <= (-2.4d-102)) then
                            tmp = z * t
                        else if (t <= 9d-91) then
                            tmp = z * -x
                        else
                            tmp = z * t
                        end if
                        code = tmp
                    end function
                    
                    public static double code(double x, double y, double z, double t) {
                    	double tmp;
                    	if (t <= -2.4e-102) {
                    		tmp = z * t;
                    	} else if (t <= 9e-91) {
                    		tmp = z * -x;
                    	} else {
                    		tmp = z * t;
                    	}
                    	return tmp;
                    }
                    
                    def code(x, y, z, t):
                    	tmp = 0
                    	if t <= -2.4e-102:
                    		tmp = z * t
                    	elif t <= 9e-91:
                    		tmp = z * -x
                    	else:
                    		tmp = z * t
                    	return tmp
                    
                    function code(x, y, z, t)
                    	tmp = 0.0
                    	if (t <= -2.4e-102)
                    		tmp = Float64(z * t);
                    	elseif (t <= 9e-91)
                    		tmp = Float64(z * Float64(-x));
                    	else
                    		tmp = Float64(z * t);
                    	end
                    	return tmp
                    end
                    
                    function tmp_2 = code(x, y, z, t)
                    	tmp = 0.0;
                    	if (t <= -2.4e-102)
                    		tmp = z * t;
                    	elseif (t <= 9e-91)
                    		tmp = z * -x;
                    	else
                    		tmp = z * t;
                    	end
                    	tmp_2 = tmp;
                    end
                    
                    code[x_, y_, z_, t_] := If[LessEqual[t, -2.4e-102], N[(z * t), $MachinePrecision], If[LessEqual[t, 9e-91], N[(z * (-x)), $MachinePrecision], N[(z * t), $MachinePrecision]]]
                    
                    \begin{array}{l}
                    
                    \\
                    \begin{array}{l}
                    \mathbf{if}\;t \leq -2.4 \cdot 10^{-102}:\\
                    \;\;\;\;z \cdot t\\
                    
                    \mathbf{elif}\;t \leq 9 \cdot 10^{-91}:\\
                    \;\;\;\;z \cdot \left(-x\right)\\
                    
                    \mathbf{else}:\\
                    \;\;\;\;z \cdot t\\
                    
                    
                    \end{array}
                    \end{array}
                    
                    Derivation
                    1. Split input into 2 regimes
                    2. if t < -2.4e-102 or 8.99999999999999952e-91 < t

                      1. Initial program 96.7%

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

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

                          \[\leadsto \color{blue}{z \cdot \left(t - x\right) + x} \]
                        2. lower-fma.f64N/A

                          \[\leadsto \color{blue}{\mathsf{fma}\left(z, t - x, x\right)} \]
                        3. lower--.f6447.2

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

                        \[\leadsto \color{blue}{\mathsf{fma}\left(z, t - x, x\right)} \]
                      6. Taylor expanded in t around inf

                        \[\leadsto t \cdot \color{blue}{z} \]
                      7. Step-by-step derivation
                        1. Applied rewrites18.9%

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

                        if -2.4e-102 < t < 8.99999999999999952e-91

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

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

                            \[\leadsto \color{blue}{z \cdot \left(t - x\right) + x} \]
                          2. lower-fma.f64N/A

                            \[\leadsto \color{blue}{\mathsf{fma}\left(z, t - x, x\right)} \]
                          3. lower--.f6469.0

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

                          \[\leadsto \color{blue}{\mathsf{fma}\left(z, t - x, x\right)} \]
                        6. Taylor expanded in z around inf

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

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

                            \[\leadsto z \cdot \left(-1 \cdot x\right) \]
                          3. Step-by-step derivation
                            1. Applied rewrites22.0%

                              \[\leadsto z \cdot \left(-x\right) \]
                          4. Recombined 2 regimes into one program.
                          5. Add Preprocessing

                          Alternative 7: 59.8% accurate, 14.9× speedup?

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

                            1. Initial program 96.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

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

                                \[\leadsto \color{blue}{z \cdot \left(t - x\right) + x} \]
                              2. lower-fma.f64N/A

                                \[\leadsto \color{blue}{\mathsf{fma}\left(z, t - x, x\right)} \]
                              3. lower--.f6448.2

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

                              \[\leadsto \color{blue}{\mathsf{fma}\left(z, t - x, x\right)} \]
                            6. Taylor expanded in t around 0

                              \[\leadsto \mathsf{fma}\left(z, -1 \cdot \color{blue}{x}, x\right) \]
                            7. Step-by-step derivation
                              1. Applied rewrites51.6%

                                \[\leadsto \mathsf{fma}\left(z, -x, x\right) \]

                              if 640 < y

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

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

                                  \[\leadsto \color{blue}{z \cdot \left(t - x\right) + x} \]
                                2. lower-fma.f64N/A

                                  \[\leadsto \color{blue}{\mathsf{fma}\left(z, t - x, x\right)} \]
                                3. lower--.f6477.0

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

                                \[\leadsto \color{blue}{\mathsf{fma}\left(z, t - x, x\right)} \]
                            8. Recombined 2 regimes into one program.
                            9. Add Preprocessing

                            Alternative 8: 26.7% accurate, 26.6× speedup?

                            \[\begin{array}{l} \\ z \cdot \left(t - x\right) \end{array} \]
                            (FPCore (x y z t) :precision binary64 (* z (- t x)))
                            double code(double x, double y, double z, double t) {
                            	return z * (t - 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 = z * (t - x)
                            end function
                            
                            public static double code(double x, double y, double z, double t) {
                            	return z * (t - x);
                            }
                            
                            def code(x, y, z, t):
                            	return z * (t - x)
                            
                            function code(x, y, z, t)
                            	return Float64(z * Float64(t - x))
                            end
                            
                            function tmp = code(x, y, z, t)
                            	tmp = z * (t - x);
                            end
                            
                            code[x_, y_, z_, t_] := N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]
                            
                            \begin{array}{l}
                            
                            \\
                            z \cdot \left(t - x\right)
                            \end{array}
                            
                            Derivation
                            1. Initial program 94.3%

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

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

                                \[\leadsto \color{blue}{z \cdot \left(t - x\right) + x} \]
                              2. lower-fma.f64N/A

                                \[\leadsto \color{blue}{\mathsf{fma}\left(z, t - x, x\right)} \]
                              3. lower--.f6454.3

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

                              \[\leadsto \color{blue}{\mathsf{fma}\left(z, t - x, x\right)} \]
                            6. Taylor expanded in z around inf

                              \[\leadsto z \cdot \color{blue}{\left(t - x\right)} \]
                            7. Step-by-step derivation
                              1. Applied rewrites23.6%

                                \[\leadsto z \cdot \color{blue}{\left(t - x\right)} \]
                              2. Add Preprocessing

                              Alternative 9: 17.2% accurate, 39.8× speedup?

                              \[\begin{array}{l} \\ z \cdot t \end{array} \]
                              (FPCore (x y z t) :precision binary64 (* z t))
                              double code(double x, double y, double z, double t) {
                              	return z * t;
                              }
                              
                              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 = z * t
                              end function
                              
                              public static double code(double x, double y, double z, double t) {
                              	return z * t;
                              }
                              
                              def code(x, y, z, t):
                              	return z * t
                              
                              function code(x, y, z, t)
                              	return Float64(z * t)
                              end
                              
                              function tmp = code(x, y, z, t)
                              	tmp = z * t;
                              end
                              
                              code[x_, y_, z_, t_] := N[(z * t), $MachinePrecision]
                              
                              \begin{array}{l}
                              
                              \\
                              z \cdot t
                              \end{array}
                              
                              Derivation
                              1. Initial program 94.3%

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

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

                                  \[\leadsto \color{blue}{z \cdot \left(t - x\right) + x} \]
                                2. lower-fma.f64N/A

                                  \[\leadsto \color{blue}{\mathsf{fma}\left(z, t - x, x\right)} \]
                                3. lower--.f6454.3

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

                                \[\leadsto \color{blue}{\mathsf{fma}\left(z, t - x, x\right)} \]
                              6. Taylor expanded in t around inf

                                \[\leadsto t \cdot \color{blue}{z} \]
                              7. Step-by-step derivation
                                1. Applied rewrites15.7%

                                  \[\leadsto z \cdot \color{blue}{t} \]
                                2. Add Preprocessing

                                Developer Target 1: 97.3% 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 2024232 
                                (FPCore (x y z t)
                                  :name "SynthBasics:moogVCF from YampaSynth-0.2"
                                  :precision binary64
                                
                                  :alt
                                  (! :herbie-platform default (+ x (* y (* z (- (tanh (/ t y)) (tanh (/ x y)))))))
                                
                                  (+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))