SynthBasics:moogVCF from YampaSynth-0.2

Percentage Accurate: 93.6% → 98.0%
Time: 6.0s
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))));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, y, z, t)
use fmin_fmax_functions
    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.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))
double code(double x, double y, double z, double t) {
	return x + ((y * z) * (tanh((t / y)) - tanh((x / y))));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, y, z, t)
use fmin_fmax_functions
    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.0% 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 \infty:\\ \;\;\;\;\mathsf{fma}\left(t\_1 \cdot z, y, x\right)\\ \mathbf{else}:\\ \;\;\;\;\left(t - x\right) \cdot z\\ \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)) INFINITY) (fma (* t_1 z) y x) (* (- t x) z))))
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)) <= ((double) INFINITY)) {
		tmp = fma((t_1 * z), y, x);
	} else {
		tmp = (t - x) * z;
	}
	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)) <= Inf)
		tmp = fma(Float64(t_1 * z), y, x);
	else
		tmp = Float64(Float64(t - x) * z);
	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], Infinity], N[(N[(t$95$1 * z), $MachinePrecision] * y + x), $MachinePrecision], N[(N[(t - x), $MachinePrecision] * z), $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 \infty:\\
\;\;\;\;\mathsf{fma}\left(t\_1 \cdot z, y, x\right)\\

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


\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))))) < +inf.0

    1. Initial program 93.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. 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. 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 \]
      5. associate-*l*N/A

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

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

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

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

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

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

    if +inf.0 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y)))))

    1. Initial program 0.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 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. *-commutativeN/A

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

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

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

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

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

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

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

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

      Alternative 2: 77.6% accurate, 1.5× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -4.3 \cdot 10^{+114} \lor \neg \left(x \leq 20000\right):\\ \;\;\;\;\mathsf{fma}\left(-0.5 \cdot \frac{\left(-t\right) - t}{y} - \tanh \left(\frac{x}{y}\right), z \cdot y, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\left(\tanh \left(\frac{t}{y}\right) - \frac{x}{y}\right) \cdot z, y, x\right)\\ \end{array} \end{array} \]
      (FPCore (x y z t)
       :precision binary64
       (if (or (<= x -4.3e+114) (not (<= x 20000.0)))
         (fma (- (* -0.5 (/ (- (- t) t) y)) (tanh (/ x y))) (* z y) x)
         (fma (* (- (tanh (/ t y)) (/ x y)) z) y x)))
      double code(double x, double y, double z, double t) {
      	double tmp;
      	if ((x <= -4.3e+114) || !(x <= 20000.0)) {
      		tmp = fma(((-0.5 * ((-t - t) / y)) - tanh((x / y))), (z * y), x);
      	} else {
      		tmp = fma(((tanh((t / y)) - (x / y)) * z), y, x);
      	}
      	return tmp;
      }
      
      function code(x, y, z, t)
      	tmp = 0.0
      	if ((x <= -4.3e+114) || !(x <= 20000.0))
      		tmp = fma(Float64(Float64(-0.5 * Float64(Float64(Float64(-t) - t) / y)) - tanh(Float64(x / y))), Float64(z * y), x);
      	else
      		tmp = fma(Float64(Float64(tanh(Float64(t / y)) - Float64(x / y)) * z), y, x);
      	end
      	return tmp
      end
      
      code[x_, y_, z_, t_] := If[Or[LessEqual[x, -4.3e+114], N[Not[LessEqual[x, 20000.0]], $MachinePrecision]], N[(N[(N[(-0.5 * N[(N[((-t) - t), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(z * y), $MachinePrecision] + x), $MachinePrecision], N[(N[(N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[(x / y), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision] * y + x), $MachinePrecision]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;x \leq -4.3 \cdot 10^{+114} \lor \neg \left(x \leq 20000\right):\\
      \;\;\;\;\mathsf{fma}\left(-0.5 \cdot \frac{\left(-t\right) - t}{y} - \tanh \left(\frac{x}{y}\right), z \cdot y, x\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;\mathsf{fma}\left(\left(\tanh \left(\frac{t}{y}\right) - \frac{x}{y}\right) \cdot z, y, x\right)\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if x < -4.3000000000000001e114 or 2e4 < x

        1. Initial program 98.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-tanh.f64N/A

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

            \[\leadsto x + \left(y \cdot z\right) \cdot \left(\color{blue}{\frac{e^{\frac{t}{y}} - e^{\mathsf{neg}\left(\frac{t}{y}\right)}}{e^{\frac{t}{y}} + e^{\mathsf{neg}\left(\frac{t}{y}\right)}}} - \tanh \left(\frac{x}{y}\right)\right) \]
          3. sinh-undefN/A

            \[\leadsto x + \left(y \cdot z\right) \cdot \left(\frac{\color{blue}{2 \cdot \sinh \left(\frac{t}{y}\right)}}{e^{\frac{t}{y}} + e^{\mathsf{neg}\left(\frac{t}{y}\right)}} - \tanh \left(\frac{x}{y}\right)\right) \]
          4. cosh-undefN/A

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

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

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

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

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

            \[\leadsto x + \left(y \cdot z\right) \cdot \left(1 \cdot \frac{\color{blue}{\sinh \left(\frac{t}{y}\right)}}{\cosh \left(\frac{t}{y}\right)} - \tanh \left(\frac{x}{y}\right)\right) \]
          10. lower-cosh.f6452.7

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

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

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

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

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

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

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

            \[\leadsto x + \left(y \cdot z\right) \cdot \left(\frac{\color{blue}{\left(\mathsf{neg}\left(t\right)\right)} - t}{y} \cdot \frac{-1}{2} - \tanh \left(\frac{x}{y}\right)\right) \]
          6. lower-neg.f6476.5

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

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

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

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

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

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

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

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

        if -4.3000000000000001e114 < x < 2e4

        1. Initial program 88.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. 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 \]
          5. associate-*l*N/A

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

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

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

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

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

          \[\leadsto \color{blue}{\mathsf{fma}\left(\left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot z, y, 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 z, y, x\right) \]
        6. Step-by-step derivation
          1. lower-/.f6482.8

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

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

        \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4.3 \cdot 10^{+114} \lor \neg \left(x \leq 20000\right):\\ \;\;\;\;\mathsf{fma}\left(-0.5 \cdot \frac{\left(-t\right) - t}{y} - \tanh \left(\frac{x}{y}\right), z \cdot y, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\left(\tanh \left(\frac{t}{y}\right) - \frac{x}{y}\right) \cdot z, y, x\right)\\ \end{array} \]
      5. Add Preprocessing

      Alternative 3: 77.3% accurate, 1.5× speedup?

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

        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. Step-by-step derivation
          1. lift-tanh.f64N/A

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

            \[\leadsto x + \left(y \cdot z\right) \cdot \left(\color{blue}{\frac{e^{\frac{t}{y}} - e^{\mathsf{neg}\left(\frac{t}{y}\right)}}{e^{\frac{t}{y}} + e^{\mathsf{neg}\left(\frac{t}{y}\right)}}} - \tanh \left(\frac{x}{y}\right)\right) \]
          3. sinh-undefN/A

            \[\leadsto x + \left(y \cdot z\right) \cdot \left(\frac{\color{blue}{2 \cdot \sinh \left(\frac{t}{y}\right)}}{e^{\frac{t}{y}} + e^{\mathsf{neg}\left(\frac{t}{y}\right)}} - \tanh \left(\frac{x}{y}\right)\right) \]
          4. cosh-undefN/A

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

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

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

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

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

            \[\leadsto x + \left(y \cdot z\right) \cdot \left(1 \cdot \frac{\color{blue}{\sinh \left(\frac{t}{y}\right)}}{\cosh \left(\frac{t}{y}\right)} - \tanh \left(\frac{x}{y}\right)\right) \]
          10. lower-cosh.f6448.6

            \[\leadsto x + \left(y \cdot z\right) \cdot \left(1 \cdot \frac{\sinh \left(\frac{t}{y}\right)}{\color{blue}{\cosh \left(\frac{t}{y}\right)}} - \tanh \left(\frac{x}{y}\right)\right) \]
        4. Applied rewrites48.6%

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

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

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

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

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

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

            \[\leadsto x + \left(y \cdot z\right) \cdot \left(\frac{\color{blue}{\left(\mathsf{neg}\left(t\right)\right)} - t}{y} \cdot \frac{-1}{2} - \tanh \left(\frac{x}{y}\right)\right) \]
          6. lower-neg.f6475.8

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

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

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

          if -3.49999999999999997e116 < x < 2e4

          1. Initial program 88.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. 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 \]
            5. associate-*l*N/A

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

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

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

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

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

            \[\leadsto \color{blue}{\mathsf{fma}\left(\left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot z, y, 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 z, y, x\right) \]
          6. Step-by-step derivation
            1. lower-/.f6482.8

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

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

          if 2e4 < x

          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. Add Preprocessing
          3. Step-by-step derivation
            1. lift-tanh.f64N/A

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

              \[\leadsto x + \left(y \cdot z\right) \cdot \left(\color{blue}{\frac{e^{\frac{t}{y}} - e^{\mathsf{neg}\left(\frac{t}{y}\right)}}{e^{\frac{t}{y}} + e^{\mathsf{neg}\left(\frac{t}{y}\right)}}} - \tanh \left(\frac{x}{y}\right)\right) \]
            3. sinh-undefN/A

              \[\leadsto x + \left(y \cdot z\right) \cdot \left(\frac{\color{blue}{2 \cdot \sinh \left(\frac{t}{y}\right)}}{e^{\frac{t}{y}} + e^{\mathsf{neg}\left(\frac{t}{y}\right)}} - \tanh \left(\frac{x}{y}\right)\right) \]
            4. cosh-undefN/A

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

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

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

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

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

              \[\leadsto x + \left(y \cdot z\right) \cdot \left(1 \cdot \frac{\color{blue}{\sinh \left(\frac{t}{y}\right)}}{\cosh \left(\frac{t}{y}\right)} - \tanh \left(\frac{x}{y}\right)\right) \]
            10. lower-cosh.f6455.1

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

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

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

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

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

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

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

              \[\leadsto x + \left(y \cdot z\right) \cdot \left(\frac{\color{blue}{\left(\mathsf{neg}\left(t\right)\right)} - t}{y} \cdot \frac{-1}{2} - \tanh \left(\frac{x}{y}\right)\right) \]
            6. lower-neg.f6476.9

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

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

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

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

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

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

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

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

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

        Alternative 4: 73.2% accurate, 1.6× speedup?

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

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

            \[\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. *-commutativeN/A

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

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

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

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

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

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

            if -1.65e37 < x < 1.3e39

            1. Initial program 89.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. 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. 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 \]
              5. associate-*l*N/A

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

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

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

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

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

              \[\leadsto \color{blue}{\mathsf{fma}\left(\left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot z, y, 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 z, y, x\right) \]
            6. Step-by-step derivation
              1. lower-/.f6483.2

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

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

            if 1.3e39 < 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. 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. *-commutativeN/A

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

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

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

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

          Alternative 5: 63.7% accurate, 10.8× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -4 \cdot 10^{-102} \lor \neg \left(y \leq 7 \cdot 10^{+48}\right):\\ \;\;\;\;\mathsf{fma}\left(t - x, z, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-x, z, x\right)\\ \end{array} \end{array} \]
          (FPCore (x y z t)
           :precision binary64
           (if (or (<= y -4e-102) (not (<= y 7e+48))) (fma (- t x) z x) (fma (- x) z x)))
          double code(double x, double y, double z, double t) {
          	double tmp;
          	if ((y <= -4e-102) || !(y <= 7e+48)) {
          		tmp = fma((t - x), z, x);
          	} else {
          		tmp = fma(-x, z, x);
          	}
          	return tmp;
          }
          
          function code(x, y, z, t)
          	tmp = 0.0
          	if ((y <= -4e-102) || !(y <= 7e+48))
          		tmp = fma(Float64(t - x), z, x);
          	else
          		tmp = fma(Float64(-x), z, x);
          	end
          	return tmp
          end
          
          code[x_, y_, z_, t_] := If[Or[LessEqual[y, -4e-102], N[Not[LessEqual[y, 7e+48]], $MachinePrecision]], N[(N[(t - x), $MachinePrecision] * z + x), $MachinePrecision], N[((-x) * z + x), $MachinePrecision]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;y \leq -4 \cdot 10^{-102} \lor \neg \left(y \leq 7 \cdot 10^{+48}\right):\\
          \;\;\;\;\mathsf{fma}\left(t - x, z, x\right)\\
          
          \mathbf{else}:\\
          \;\;\;\;\mathsf{fma}\left(-x, z, x\right)\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if y < -3.99999999999999973e-102 or 6.9999999999999995e48 < y

            1. Initial program 84.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. *-commutativeN/A

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

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

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

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

            if -3.99999999999999973e-102 < y < 6.9999999999999995e48

            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 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. *-commutativeN/A

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

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

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

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

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

                \[\leadsto \mathsf{fma}\left(-x, \color{blue}{z}, x\right) \]
            8. Recombined 2 regimes into one program.
            9. Final simplification71.0%

              \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -4 \cdot 10^{-102} \lor \neg \left(y \leq 7 \cdot 10^{+48}\right):\\ \;\;\;\;\mathsf{fma}\left(t - x, z, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-x, z, x\right)\\ \end{array} \]
            10. Add Preprocessing

            Alternative 6: 61.8% accurate, 11.4× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -1900 \lor \neg \left(z \leq 440000000000\right):\\ \;\;\;\;\left(t - x\right) \cdot z\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-x, z, x\right)\\ \end{array} \end{array} \]
            (FPCore (x y z t)
             :precision binary64
             (if (or (<= z -1900.0) (not (<= z 440000000000.0)))
               (* (- t x) z)
               (fma (- x) z x)))
            double code(double x, double y, double z, double t) {
            	double tmp;
            	if ((z <= -1900.0) || !(z <= 440000000000.0)) {
            		tmp = (t - x) * z;
            	} else {
            		tmp = fma(-x, z, x);
            	}
            	return tmp;
            }
            
            function code(x, y, z, t)
            	tmp = 0.0
            	if ((z <= -1900.0) || !(z <= 440000000000.0))
            		tmp = Float64(Float64(t - x) * z);
            	else
            		tmp = fma(Float64(-x), z, x);
            	end
            	return tmp
            end
            
            code[x_, y_, z_, t_] := If[Or[LessEqual[z, -1900.0], N[Not[LessEqual[z, 440000000000.0]], $MachinePrecision]], N[(N[(t - x), $MachinePrecision] * z), $MachinePrecision], N[((-x) * z + x), $MachinePrecision]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            \mathbf{if}\;z \leq -1900 \lor \neg \left(z \leq 440000000000\right):\\
            \;\;\;\;\left(t - x\right) \cdot z\\
            
            \mathbf{else}:\\
            \;\;\;\;\mathsf{fma}\left(-x, z, x\right)\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 2 regimes
            2. if z < -1900 or 4.4e11 < z

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

                \[\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. *-commutativeN/A

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

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

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

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

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

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

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

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

                  if -1900 < z < 4.4e11

                  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 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. *-commutativeN/A

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

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

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

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

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

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

                    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1900 \lor \neg \left(z \leq 440000000000\right):\\ \;\;\;\;\left(t - x\right) \cdot z\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-x, z, x\right)\\ \end{array} \]
                  10. Add Preprocessing

                  Alternative 7: 20.2% accurate, 11.9× speedup?

                  \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -51000000000 \lor \neg \left(x \leq 2.5 \cdot 10^{+83}\right):\\ \;\;\;\;\left(-x\right) \cdot z\\ \mathbf{else}:\\ \;\;\;\;z \cdot t\\ \end{array} \end{array} \]
                  (FPCore (x y z t)
                   :precision binary64
                   (if (or (<= x -51000000000.0) (not (<= x 2.5e+83))) (* (- x) z) (* z t)))
                  double code(double x, double y, double z, double t) {
                  	double tmp;
                  	if ((x <= -51000000000.0) || !(x <= 2.5e+83)) {
                  		tmp = -x * z;
                  	} else {
                  		tmp = z * t;
                  	}
                  	return tmp;
                  }
                  
                  module fmin_fmax_functions
                      implicit none
                      private
                      public fmax
                      public fmin
                  
                      interface fmax
                          module procedure fmax88
                          module procedure fmax44
                          module procedure fmax84
                          module procedure fmax48
                      end interface
                      interface fmin
                          module procedure fmin88
                          module procedure fmin44
                          module procedure fmin84
                          module procedure fmin48
                      end interface
                  contains
                      real(8) function fmax88(x, y) result (res)
                          real(8), intent (in) :: x
                          real(8), intent (in) :: y
                          res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                      end function
                      real(4) function fmax44(x, y) result (res)
                          real(4), intent (in) :: x
                          real(4), intent (in) :: y
                          res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                      end function
                      real(8) function fmax84(x, y) result(res)
                          real(8), intent (in) :: x
                          real(4), intent (in) :: y
                          res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                      end function
                      real(8) function fmax48(x, y) result(res)
                          real(4), intent (in) :: x
                          real(8), intent (in) :: y
                          res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                      end function
                      real(8) function fmin88(x, y) result (res)
                          real(8), intent (in) :: x
                          real(8), intent (in) :: y
                          res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                      end function
                      real(4) function fmin44(x, y) result (res)
                          real(4), intent (in) :: x
                          real(4), intent (in) :: y
                          res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                      end function
                      real(8) function fmin84(x, y) result(res)
                          real(8), intent (in) :: x
                          real(4), intent (in) :: y
                          res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                      end function
                      real(8) function fmin48(x, y) result(res)
                          real(4), intent (in) :: x
                          real(8), intent (in) :: y
                          res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                      end function
                  end module
                  
                  real(8) function code(x, y, z, t)
                  use fmin_fmax_functions
                      real(8), intent (in) :: x
                      real(8), intent (in) :: y
                      real(8), intent (in) :: z
                      real(8), intent (in) :: t
                      real(8) :: tmp
                      if ((x <= (-51000000000.0d0)) .or. (.not. (x <= 2.5d+83))) then
                          tmp = -x * z
                      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 ((x <= -51000000000.0) || !(x <= 2.5e+83)) {
                  		tmp = -x * z;
                  	} else {
                  		tmp = z * t;
                  	}
                  	return tmp;
                  }
                  
                  def code(x, y, z, t):
                  	tmp = 0
                  	if (x <= -51000000000.0) or not (x <= 2.5e+83):
                  		tmp = -x * z
                  	else:
                  		tmp = z * t
                  	return tmp
                  
                  function code(x, y, z, t)
                  	tmp = 0.0
                  	if ((x <= -51000000000.0) || !(x <= 2.5e+83))
                  		tmp = Float64(Float64(-x) * z);
                  	else
                  		tmp = Float64(z * t);
                  	end
                  	return tmp
                  end
                  
                  function tmp_2 = code(x, y, z, t)
                  	tmp = 0.0;
                  	if ((x <= -51000000000.0) || ~((x <= 2.5e+83)))
                  		tmp = -x * z;
                  	else
                  		tmp = z * t;
                  	end
                  	tmp_2 = tmp;
                  end
                  
                  code[x_, y_, z_, t_] := If[Or[LessEqual[x, -51000000000.0], N[Not[LessEqual[x, 2.5e+83]], $MachinePrecision]], N[((-x) * z), $MachinePrecision], N[(z * t), $MachinePrecision]]
                  
                  \begin{array}{l}
                  
                  \\
                  \begin{array}{l}
                  \mathbf{if}\;x \leq -51000000000 \lor \neg \left(x \leq 2.5 \cdot 10^{+83}\right):\\
                  \;\;\;\;\left(-x\right) \cdot z\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;z \cdot t\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 2 regimes
                  2. if x < -5.1e10 or 2.50000000000000014e83 < x

                    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
                    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. *-commutativeN/A

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

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

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

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

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

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

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

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

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

                            \[\leadsto \left(-x\right) \cdot z \]

                          if -5.1e10 < x < 2.50000000000000014e83

                          1. Initial program 89.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 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. *-commutativeN/A

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

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

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

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

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

                              \[\leadsto z \cdot \color{blue}{t} \]
                          8. Recombined 2 regimes into one program.
                          9. Final simplification23.2%

                            \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -51000000000 \lor \neg \left(x \leq 2.5 \cdot 10^{+83}\right):\\ \;\;\;\;\left(-x\right) \cdot z\\ \mathbf{else}:\\ \;\;\;\;z \cdot t\\ \end{array} \]
                          10. Add Preprocessing

                          Alternative 8: 26.2% accurate, 26.6× speedup?

                          \[\begin{array}{l} \\ \left(t - x\right) \cdot z \end{array} \]
                          (FPCore (x y z t) :precision binary64 (* (- t x) z))
                          double code(double x, double y, double z, double t) {
                          	return (t - x) * z;
                          }
                          
                          module fmin_fmax_functions
                              implicit none
                              private
                              public fmax
                              public fmin
                          
                              interface fmax
                                  module procedure fmax88
                                  module procedure fmax44
                                  module procedure fmax84
                                  module procedure fmax48
                              end interface
                              interface fmin
                                  module procedure fmin88
                                  module procedure fmin44
                                  module procedure fmin84
                                  module procedure fmin48
                              end interface
                          contains
                              real(8) function fmax88(x, y) result (res)
                                  real(8), intent (in) :: x
                                  real(8), intent (in) :: y
                                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                              end function
                              real(4) function fmax44(x, y) result (res)
                                  real(4), intent (in) :: x
                                  real(4), intent (in) :: y
                                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                              end function
                              real(8) function fmax84(x, y) result(res)
                                  real(8), intent (in) :: x
                                  real(4), intent (in) :: y
                                  res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                              end function
                              real(8) function fmax48(x, y) result(res)
                                  real(4), intent (in) :: x
                                  real(8), intent (in) :: y
                                  res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                              end function
                              real(8) function fmin88(x, y) result (res)
                                  real(8), intent (in) :: x
                                  real(8), intent (in) :: y
                                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                              end function
                              real(4) function fmin44(x, y) result (res)
                                  real(4), intent (in) :: x
                                  real(4), intent (in) :: y
                                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                              end function
                              real(8) function fmin84(x, y) result(res)
                                  real(8), intent (in) :: x
                                  real(4), intent (in) :: y
                                  res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                              end function
                              real(8) function fmin48(x, y) result(res)
                                  real(4), intent (in) :: x
                                  real(8), intent (in) :: y
                                  res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                              end function
                          end module
                          
                          real(8) function code(x, y, z, t)
                          use fmin_fmax_functions
                              real(8), intent (in) :: x
                              real(8), intent (in) :: y
                              real(8), intent (in) :: z
                              real(8), intent (in) :: t
                              code = (t - x) * z
                          end function
                          
                          public static double code(double x, double y, double z, double t) {
                          	return (t - x) * z;
                          }
                          
                          def code(x, y, z, t):
                          	return (t - x) * z
                          
                          function code(x, y, z, t)
                          	return Float64(Float64(t - x) * z)
                          end
                          
                          function tmp = code(x, y, z, t)
                          	tmp = (t - x) * z;
                          end
                          
                          code[x_, y_, z_, t_] := N[(N[(t - x), $MachinePrecision] * z), $MachinePrecision]
                          
                          \begin{array}{l}
                          
                          \\
                          \left(t - x\right) \cdot z
                          \end{array}
                          
                          Derivation
                          1. Initial program 92.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. *-commutativeN/A

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

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

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

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

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

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

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

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

                              Alternative 9: 16.9% 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;
                              }
                              
                              module fmin_fmax_functions
                                  implicit none
                                  private
                                  public fmax
                                  public fmin
                              
                                  interface fmax
                                      module procedure fmax88
                                      module procedure fmax44
                                      module procedure fmax84
                                      module procedure fmax48
                                  end interface
                                  interface fmin
                                      module procedure fmin88
                                      module procedure fmin44
                                      module procedure fmin84
                                      module procedure fmin48
                                  end interface
                              contains
                                  real(8) function fmax88(x, y) result (res)
                                      real(8), intent (in) :: x
                                      real(8), intent (in) :: y
                                      res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                  end function
                                  real(4) function fmax44(x, y) result (res)
                                      real(4), intent (in) :: x
                                      real(4), intent (in) :: y
                                      res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                  end function
                                  real(8) function fmax84(x, y) result(res)
                                      real(8), intent (in) :: x
                                      real(4), intent (in) :: y
                                      res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                  end function
                                  real(8) function fmax48(x, y) result(res)
                                      real(4), intent (in) :: x
                                      real(8), intent (in) :: y
                                      res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                  end function
                                  real(8) function fmin88(x, y) result (res)
                                      real(8), intent (in) :: x
                                      real(8), intent (in) :: y
                                      res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                  end function
                                  real(4) function fmin44(x, y) result (res)
                                      real(4), intent (in) :: x
                                      real(4), intent (in) :: y
                                      res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                  end function
                                  real(8) function fmin84(x, y) result(res)
                                      real(8), intent (in) :: x
                                      real(4), intent (in) :: y
                                      res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                  end function
                                  real(8) function fmin48(x, y) result(res)
                                      real(4), intent (in) :: x
                                      real(8), intent (in) :: y
                                      res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                  end function
                              end module
                              
                              real(8) function code(x, y, z, t)
                              use fmin_fmax_functions
                                  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 92.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. *-commutativeN/A

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

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

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

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

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

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

                                Developer Target 1: 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)))));
                                }
                                
                                module fmin_fmax_functions
                                    implicit none
                                    private
                                    public fmax
                                    public fmin
                                
                                    interface fmax
                                        module procedure fmax88
                                        module procedure fmax44
                                        module procedure fmax84
                                        module procedure fmax48
                                    end interface
                                    interface fmin
                                        module procedure fmin88
                                        module procedure fmin44
                                        module procedure fmin84
                                        module procedure fmin48
                                    end interface
                                contains
                                    real(8) function fmax88(x, y) result (res)
                                        real(8), intent (in) :: x
                                        real(8), intent (in) :: y
                                        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                    end function
                                    real(4) function fmax44(x, y) result (res)
                                        real(4), intent (in) :: x
                                        real(4), intent (in) :: y
                                        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                    end function
                                    real(8) function fmax84(x, y) result(res)
                                        real(8), intent (in) :: x
                                        real(4), intent (in) :: y
                                        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                    end function
                                    real(8) function fmax48(x, y) result(res)
                                        real(4), intent (in) :: x
                                        real(8), intent (in) :: y
                                        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                    end function
                                    real(8) function fmin88(x, y) result (res)
                                        real(8), intent (in) :: x
                                        real(8), intent (in) :: y
                                        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                    end function
                                    real(4) function fmin44(x, y) result (res)
                                        real(4), intent (in) :: x
                                        real(4), intent (in) :: y
                                        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                    end function
                                    real(8) function fmin84(x, y) result(res)
                                        real(8), intent (in) :: x
                                        real(4), intent (in) :: y
                                        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                    end function
                                    real(8) function fmin48(x, y) result(res)
                                        real(4), intent (in) :: x
                                        real(8), intent (in) :: y
                                        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                    end function
                                end module
                                
                                real(8) function code(x, y, z, t)
                                use fmin_fmax_functions
                                    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 2025017 
                                (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))))))