Linear.Quaternion:$ctan from linear-1.19.1.3

Percentage Accurate: 84.0% → 99.8%
Time: 4.9s
Alternatives: 11
Speedup: 0.5×

Specification

?
\[\begin{array}{l} \\ \frac{\cosh x \cdot \frac{y}{x}}{z} \end{array} \]
(FPCore (x y z) :precision binary64 (/ (* (cosh x) (/ y x)) z))
double code(double x, double y, double z) {
	return (cosh(x) * (y / 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)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = (cosh(x) * (y / x)) / z
end function
public static double code(double x, double y, double z) {
	return (Math.cosh(x) * (y / x)) / z;
}
def code(x, y, z):
	return (math.cosh(x) * (y / x)) / z
function code(x, y, z)
	return Float64(Float64(cosh(x) * Float64(y / x)) / z)
end
function tmp = code(x, y, z)
	tmp = (cosh(x) * (y / x)) / z;
end
code[x_, y_, z_] := N[(N[(N[Cosh[x], $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}

\\
\frac{\cosh x \cdot \frac{y}{x}}{z}
\end{array}

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 11 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: 84.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{\cosh x \cdot \frac{y}{x}}{z} \end{array} \]
(FPCore (x y z) :precision binary64 (/ (* (cosh x) (/ y x)) z))
double code(double x, double y, double z) {
	return (cosh(x) * (y / 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)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = (cosh(x) * (y / x)) / z
end function
public static double code(double x, double y, double z) {
	return (Math.cosh(x) * (y / x)) / z;
}
def code(x, y, z):
	return (math.cosh(x) * (y / x)) / z
function code(x, y, z)
	return Float64(Float64(cosh(x) * Float64(y / x)) / z)
end
function tmp = code(x, y, z)
	tmp = (cosh(x) * (y / x)) / z;
end
code[x_, y_, z_] := N[(N[(N[Cosh[x], $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}

\\
\frac{\cosh x \cdot \frac{y}{x}}{z}
\end{array}

Alternative 1: 99.8% accurate, 0.5× speedup?

\[\begin{array}{l} x\_m = \left|x\right| \\ x\_s = \mathsf{copysign}\left(1, x\right) \\ y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ z\_m = \left|z\right| \\ z\_s = \mathsf{copysign}\left(1, z\right) \\ z\_s \cdot \left(y\_s \cdot \left(x\_s \cdot \begin{array}{l} \mathbf{if}\;\frac{\cosh x\_m \cdot \frac{y\_m}{x\_m}}{z\_m} \leq 5 \cdot 10^{-16}:\\ \;\;\;\;y\_m \cdot \frac{\cosh x\_m}{z\_m \cdot x\_m}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y\_m \cdot \cosh x\_m}{z\_m}}{x\_m}\\ \end{array}\right)\right) \end{array} \]
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
z\_m = (fabs.f64 z)
z\_s = (copysign.f64 #s(literal 1 binary64) z)
(FPCore (z_s y_s x_s x_m y_m z_m)
 :precision binary64
 (*
  z_s
  (*
   y_s
   (*
    x_s
    (if (<= (/ (* (cosh x_m) (/ y_m x_m)) z_m) 5e-16)
      (* y_m (/ (cosh x_m) (* z_m x_m)))
      (/ (/ (* y_m (cosh x_m)) z_m) x_m))))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
z\_m = fabs(z);
z\_s = copysign(1.0, z);
double code(double z_s, double y_s, double x_s, double x_m, double y_m, double z_m) {
	double tmp;
	if (((cosh(x_m) * (y_m / x_m)) / z_m) <= 5e-16) {
		tmp = y_m * (cosh(x_m) / (z_m * x_m));
	} else {
		tmp = ((y_m * cosh(x_m)) / z_m) / x_m;
	}
	return z_s * (y_s * (x_s * tmp));
}
x\_m =     private
x\_s =     private
y\_m =     private
y\_s =     private
z\_m =     private
z\_s =     private
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(z_s, y_s, x_s, x_m, y_m, z_m)
use fmin_fmax_functions
    real(8), intent (in) :: z_s
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x_s
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z_m
    real(8) :: tmp
    if (((cosh(x_m) * (y_m / x_m)) / z_m) <= 5d-16) then
        tmp = y_m * (cosh(x_m) / (z_m * x_m))
    else
        tmp = ((y_m * cosh(x_m)) / z_m) / x_m
    end if
    code = z_s * (y_s * (x_s * tmp))
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
z\_m = Math.abs(z);
z\_s = Math.copySign(1.0, z);
public static double code(double z_s, double y_s, double x_s, double x_m, double y_m, double z_m) {
	double tmp;
	if (((Math.cosh(x_m) * (y_m / x_m)) / z_m) <= 5e-16) {
		tmp = y_m * (Math.cosh(x_m) / (z_m * x_m));
	} else {
		tmp = ((y_m * Math.cosh(x_m)) / z_m) / x_m;
	}
	return z_s * (y_s * (x_s * tmp));
}
x\_m = math.fabs(x)
x\_s = math.copysign(1.0, x)
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
z\_m = math.fabs(z)
z\_s = math.copysign(1.0, z)
def code(z_s, y_s, x_s, x_m, y_m, z_m):
	tmp = 0
	if ((math.cosh(x_m) * (y_m / x_m)) / z_m) <= 5e-16:
		tmp = y_m * (math.cosh(x_m) / (z_m * x_m))
	else:
		tmp = ((y_m * math.cosh(x_m)) / z_m) / x_m
	return z_s * (y_s * (x_s * tmp))
x\_m = abs(x)
x\_s = copysign(1.0, x)
y\_m = abs(y)
y\_s = copysign(1.0, y)
z\_m = abs(z)
z\_s = copysign(1.0, z)
function code(z_s, y_s, x_s, x_m, y_m, z_m)
	tmp = 0.0
	if (Float64(Float64(cosh(x_m) * Float64(y_m / x_m)) / z_m) <= 5e-16)
		tmp = Float64(y_m * Float64(cosh(x_m) / Float64(z_m * x_m)));
	else
		tmp = Float64(Float64(Float64(y_m * cosh(x_m)) / z_m) / x_m);
	end
	return Float64(z_s * Float64(y_s * Float64(x_s * tmp)))
end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
z\_m = abs(z);
z\_s = sign(z) * abs(1.0);
function tmp_2 = code(z_s, y_s, x_s, x_m, y_m, z_m)
	tmp = 0.0;
	if (((cosh(x_m) * (y_m / x_m)) / z_m) <= 5e-16)
		tmp = y_m * (cosh(x_m) / (z_m * x_m));
	else
		tmp = ((y_m * cosh(x_m)) / z_m) / x_m;
	end
	tmp_2 = z_s * (y_s * (x_s * tmp));
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
z\_m = N[Abs[z], $MachinePrecision]
z\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[z$95$s_, y$95$s_, x$95$s_, x$95$m_, y$95$m_, z$95$m_] := N[(z$95$s * N[(y$95$s * N[(x$95$s * If[LessEqual[N[(N[(N[Cosh[x$95$m], $MachinePrecision] * N[(y$95$m / x$95$m), $MachinePrecision]), $MachinePrecision] / z$95$m), $MachinePrecision], 5e-16], N[(y$95$m * N[(N[Cosh[x$95$m], $MachinePrecision] / N[(z$95$m * x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y$95$m * N[Cosh[x$95$m], $MachinePrecision]), $MachinePrecision] / z$95$m), $MachinePrecision] / x$95$m), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
z\_m = \left|z\right|
\\
z\_s = \mathsf{copysign}\left(1, z\right)

\\
z\_s \cdot \left(y\_s \cdot \left(x\_s \cdot \begin{array}{l}
\mathbf{if}\;\frac{\cosh x\_m \cdot \frac{y\_m}{x\_m}}{z\_m} \leq 5 \cdot 10^{-16}:\\
\;\;\;\;y\_m \cdot \frac{\cosh x\_m}{z\_m \cdot x\_m}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{y\_m \cdot \cosh x\_m}{z\_m}}{x\_m}\\


\end{array}\right)\right)
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z) < 5.0000000000000004e-16

    1. Initial program 84.0%

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\cosh x \cdot \frac{y}{x}}{z}} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{\cosh x \cdot \frac{y}{x}}}{z} \]
      3. lift-/.f64N/A

        \[\leadsto \frac{\cosh x \cdot \color{blue}{\frac{y}{x}}}{z} \]
      4. associate-*r/N/A

        \[\leadsto \frac{\color{blue}{\frac{\cosh x \cdot y}{x}}}{z} \]
      5. associate-/l/N/A

        \[\leadsto \color{blue}{\frac{\cosh x \cdot y}{x \cdot z}} \]
      6. *-commutativeN/A

        \[\leadsto \frac{\color{blue}{y \cdot \cosh x}}{x \cdot z} \]
      7. associate-/l*N/A

        \[\leadsto \color{blue}{y \cdot \frac{\cosh x}{x \cdot z}} \]
      8. lower-*.f64N/A

        \[\leadsto \color{blue}{y \cdot \frac{\cosh x}{x \cdot z}} \]
      9. lower-/.f64N/A

        \[\leadsto y \cdot \color{blue}{\frac{\cosh x}{x \cdot z}} \]
      10. *-commutativeN/A

        \[\leadsto y \cdot \frac{\cosh x}{\color{blue}{z \cdot x}} \]
      11. lower-*.f6482.7

        \[\leadsto y \cdot \frac{\cosh x}{\color{blue}{z \cdot x}} \]
    3. Applied rewrites82.7%

      \[\leadsto \color{blue}{y \cdot \frac{\cosh x}{z \cdot x}} \]

    if 5.0000000000000004e-16 < (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z)

    1. Initial program 84.0%

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\cosh x \cdot \frac{y}{x}}{z}} \]
      2. mult-flipN/A

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

        \[\leadsto \color{blue}{\left(\cosh x \cdot \frac{y}{x}\right)} \cdot \frac{1}{z} \]
      4. lift-/.f64N/A

        \[\leadsto \left(\cosh x \cdot \color{blue}{\frac{y}{x}}\right) \cdot \frac{1}{z} \]
      5. associate-*r/N/A

        \[\leadsto \color{blue}{\frac{\cosh x \cdot y}{x}} \cdot \frac{1}{z} \]
      6. associate-*l/N/A

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

        \[\leadsto \color{blue}{\frac{\left(\cosh x \cdot y\right) \cdot \frac{1}{z}}{x}} \]
      8. mult-flip-revN/A

        \[\leadsto \frac{\color{blue}{\frac{\cosh x \cdot y}{z}}}{x} \]
      9. lower-/.f64N/A

        \[\leadsto \frac{\color{blue}{\frac{\cosh x \cdot y}{z}}}{x} \]
      10. *-commutativeN/A

        \[\leadsto \frac{\frac{\color{blue}{y \cdot \cosh x}}{z}}{x} \]
      11. lower-*.f6496.0

        \[\leadsto \frac{\frac{\color{blue}{y \cdot \cosh x}}{z}}{x} \]
    3. Applied rewrites96.0%

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

Alternative 2: 91.9% accurate, 0.5× speedup?

\[\begin{array}{l} x\_m = \left|x\right| \\ x\_s = \mathsf{copysign}\left(1, x\right) \\ y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ z\_m = \left|z\right| \\ z\_s = \mathsf{copysign}\left(1, z\right) \\ \begin{array}{l} t_0 := \frac{\cosh x\_m \cdot \frac{y\_m}{x\_m}}{z\_m}\\ z\_s \cdot \left(y\_s \cdot \left(x\_s \cdot \begin{array}{l} \mathbf{if}\;t\_0 \leq \infty:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;y\_m \cdot \frac{\cosh x\_m}{z\_m \cdot x\_m}\\ \end{array}\right)\right) \end{array} \end{array} \]
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
z\_m = (fabs.f64 z)
z\_s = (copysign.f64 #s(literal 1 binary64) z)
(FPCore (z_s y_s x_s x_m y_m z_m)
 :precision binary64
 (let* ((t_0 (/ (* (cosh x_m) (/ y_m x_m)) z_m)))
   (*
    z_s
    (*
     y_s
     (* x_s (if (<= t_0 INFINITY) t_0 (* y_m (/ (cosh x_m) (* z_m x_m)))))))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
z\_m = fabs(z);
z\_s = copysign(1.0, z);
double code(double z_s, double y_s, double x_s, double x_m, double y_m, double z_m) {
	double t_0 = (cosh(x_m) * (y_m / x_m)) / z_m;
	double tmp;
	if (t_0 <= ((double) INFINITY)) {
		tmp = t_0;
	} else {
		tmp = y_m * (cosh(x_m) / (z_m * x_m));
	}
	return z_s * (y_s * (x_s * tmp));
}
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
z\_m = Math.abs(z);
z\_s = Math.copySign(1.0, z);
public static double code(double z_s, double y_s, double x_s, double x_m, double y_m, double z_m) {
	double t_0 = (Math.cosh(x_m) * (y_m / x_m)) / z_m;
	double tmp;
	if (t_0 <= Double.POSITIVE_INFINITY) {
		tmp = t_0;
	} else {
		tmp = y_m * (Math.cosh(x_m) / (z_m * x_m));
	}
	return z_s * (y_s * (x_s * tmp));
}
x\_m = math.fabs(x)
x\_s = math.copysign(1.0, x)
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
z\_m = math.fabs(z)
z\_s = math.copysign(1.0, z)
def code(z_s, y_s, x_s, x_m, y_m, z_m):
	t_0 = (math.cosh(x_m) * (y_m / x_m)) / z_m
	tmp = 0
	if t_0 <= math.inf:
		tmp = t_0
	else:
		tmp = y_m * (math.cosh(x_m) / (z_m * x_m))
	return z_s * (y_s * (x_s * tmp))
x\_m = abs(x)
x\_s = copysign(1.0, x)
y\_m = abs(y)
y\_s = copysign(1.0, y)
z\_m = abs(z)
z\_s = copysign(1.0, z)
function code(z_s, y_s, x_s, x_m, y_m, z_m)
	t_0 = Float64(Float64(cosh(x_m) * Float64(y_m / x_m)) / z_m)
	tmp = 0.0
	if (t_0 <= Inf)
		tmp = t_0;
	else
		tmp = Float64(y_m * Float64(cosh(x_m) / Float64(z_m * x_m)));
	end
	return Float64(z_s * Float64(y_s * Float64(x_s * tmp)))
end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
z\_m = abs(z);
z\_s = sign(z) * abs(1.0);
function tmp_2 = code(z_s, y_s, x_s, x_m, y_m, z_m)
	t_0 = (cosh(x_m) * (y_m / x_m)) / z_m;
	tmp = 0.0;
	if (t_0 <= Inf)
		tmp = t_0;
	else
		tmp = y_m * (cosh(x_m) / (z_m * x_m));
	end
	tmp_2 = z_s * (y_s * (x_s * tmp));
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
z\_m = N[Abs[z], $MachinePrecision]
z\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[z$95$s_, y$95$s_, x$95$s_, x$95$m_, y$95$m_, z$95$m_] := Block[{t$95$0 = N[(N[(N[Cosh[x$95$m], $MachinePrecision] * N[(y$95$m / x$95$m), $MachinePrecision]), $MachinePrecision] / z$95$m), $MachinePrecision]}, N[(z$95$s * N[(y$95$s * N[(x$95$s * If[LessEqual[t$95$0, Infinity], t$95$0, N[(y$95$m * N[(N[Cosh[x$95$m], $MachinePrecision] / N[(z$95$m * x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
z\_m = \left|z\right|
\\
z\_s = \mathsf{copysign}\left(1, z\right)

\\
\begin{array}{l}
t_0 := \frac{\cosh x\_m \cdot \frac{y\_m}{x\_m}}{z\_m}\\
z\_s \cdot \left(y\_s \cdot \left(x\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_0 \leq \infty:\\
\;\;\;\;t\_0\\

\mathbf{else}:\\
\;\;\;\;y\_m \cdot \frac{\cosh x\_m}{z\_m \cdot x\_m}\\


\end{array}\right)\right)
\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z) < +inf.0

    1. Initial program 84.0%

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]

    if +inf.0 < (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z)

    1. Initial program 84.0%

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\cosh x \cdot \frac{y}{x}}{z}} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{\cosh x \cdot \frac{y}{x}}}{z} \]
      3. lift-/.f64N/A

        \[\leadsto \frac{\cosh x \cdot \color{blue}{\frac{y}{x}}}{z} \]
      4. associate-*r/N/A

        \[\leadsto \frac{\color{blue}{\frac{\cosh x \cdot y}{x}}}{z} \]
      5. associate-/l/N/A

        \[\leadsto \color{blue}{\frac{\cosh x \cdot y}{x \cdot z}} \]
      6. *-commutativeN/A

        \[\leadsto \frac{\color{blue}{y \cdot \cosh x}}{x \cdot z} \]
      7. associate-/l*N/A

        \[\leadsto \color{blue}{y \cdot \frac{\cosh x}{x \cdot z}} \]
      8. lower-*.f64N/A

        \[\leadsto \color{blue}{y \cdot \frac{\cosh x}{x \cdot z}} \]
      9. lower-/.f64N/A

        \[\leadsto y \cdot \color{blue}{\frac{\cosh x}{x \cdot z}} \]
      10. *-commutativeN/A

        \[\leadsto y \cdot \frac{\cosh x}{\color{blue}{z \cdot x}} \]
      11. lower-*.f6482.7

        \[\leadsto y \cdot \frac{\cosh x}{\color{blue}{z \cdot x}} \]
    3. Applied rewrites82.7%

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

Alternative 3: 91.9% accurate, 0.5× speedup?

\[\begin{array}{l} x\_m = \left|x\right| \\ x\_s = \mathsf{copysign}\left(1, x\right) \\ y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ z\_m = \left|z\right| \\ z\_s = \mathsf{copysign}\left(1, z\right) \\ z\_s \cdot \left(y\_s \cdot \left(x\_s \cdot \begin{array}{l} \mathbf{if}\;\frac{\cosh x\_m \cdot \frac{y\_m}{x\_m}}{z\_m} \leq \infty:\\ \;\;\;\;\frac{\cosh x\_m}{z\_m} \cdot \frac{y\_m}{x\_m}\\ \mathbf{else}:\\ \;\;\;\;y\_m \cdot \frac{\cosh x\_m}{z\_m \cdot x\_m}\\ \end{array}\right)\right) \end{array} \]
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
z\_m = (fabs.f64 z)
z\_s = (copysign.f64 #s(literal 1 binary64) z)
(FPCore (z_s y_s x_s x_m y_m z_m)
 :precision binary64
 (*
  z_s
  (*
   y_s
   (*
    x_s
    (if (<= (/ (* (cosh x_m) (/ y_m x_m)) z_m) INFINITY)
      (* (/ (cosh x_m) z_m) (/ y_m x_m))
      (* y_m (/ (cosh x_m) (* z_m x_m))))))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
z\_m = fabs(z);
z\_s = copysign(1.0, z);
double code(double z_s, double y_s, double x_s, double x_m, double y_m, double z_m) {
	double tmp;
	if (((cosh(x_m) * (y_m / x_m)) / z_m) <= ((double) INFINITY)) {
		tmp = (cosh(x_m) / z_m) * (y_m / x_m);
	} else {
		tmp = y_m * (cosh(x_m) / (z_m * x_m));
	}
	return z_s * (y_s * (x_s * tmp));
}
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
z\_m = Math.abs(z);
z\_s = Math.copySign(1.0, z);
public static double code(double z_s, double y_s, double x_s, double x_m, double y_m, double z_m) {
	double tmp;
	if (((Math.cosh(x_m) * (y_m / x_m)) / z_m) <= Double.POSITIVE_INFINITY) {
		tmp = (Math.cosh(x_m) / z_m) * (y_m / x_m);
	} else {
		tmp = y_m * (Math.cosh(x_m) / (z_m * x_m));
	}
	return z_s * (y_s * (x_s * tmp));
}
x\_m = math.fabs(x)
x\_s = math.copysign(1.0, x)
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
z\_m = math.fabs(z)
z\_s = math.copysign(1.0, z)
def code(z_s, y_s, x_s, x_m, y_m, z_m):
	tmp = 0
	if ((math.cosh(x_m) * (y_m / x_m)) / z_m) <= math.inf:
		tmp = (math.cosh(x_m) / z_m) * (y_m / x_m)
	else:
		tmp = y_m * (math.cosh(x_m) / (z_m * x_m))
	return z_s * (y_s * (x_s * tmp))
x\_m = abs(x)
x\_s = copysign(1.0, x)
y\_m = abs(y)
y\_s = copysign(1.0, y)
z\_m = abs(z)
z\_s = copysign(1.0, z)
function code(z_s, y_s, x_s, x_m, y_m, z_m)
	tmp = 0.0
	if (Float64(Float64(cosh(x_m) * Float64(y_m / x_m)) / z_m) <= Inf)
		tmp = Float64(Float64(cosh(x_m) / z_m) * Float64(y_m / x_m));
	else
		tmp = Float64(y_m * Float64(cosh(x_m) / Float64(z_m * x_m)));
	end
	return Float64(z_s * Float64(y_s * Float64(x_s * tmp)))
end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
z\_m = abs(z);
z\_s = sign(z) * abs(1.0);
function tmp_2 = code(z_s, y_s, x_s, x_m, y_m, z_m)
	tmp = 0.0;
	if (((cosh(x_m) * (y_m / x_m)) / z_m) <= Inf)
		tmp = (cosh(x_m) / z_m) * (y_m / x_m);
	else
		tmp = y_m * (cosh(x_m) / (z_m * x_m));
	end
	tmp_2 = z_s * (y_s * (x_s * tmp));
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
z\_m = N[Abs[z], $MachinePrecision]
z\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[z$95$s_, y$95$s_, x$95$s_, x$95$m_, y$95$m_, z$95$m_] := N[(z$95$s * N[(y$95$s * N[(x$95$s * If[LessEqual[N[(N[(N[Cosh[x$95$m], $MachinePrecision] * N[(y$95$m / x$95$m), $MachinePrecision]), $MachinePrecision] / z$95$m), $MachinePrecision], Infinity], N[(N[(N[Cosh[x$95$m], $MachinePrecision] / z$95$m), $MachinePrecision] * N[(y$95$m / x$95$m), $MachinePrecision]), $MachinePrecision], N[(y$95$m * N[(N[Cosh[x$95$m], $MachinePrecision] / N[(z$95$m * x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
z\_m = \left|z\right|
\\
z\_s = \mathsf{copysign}\left(1, z\right)

\\
z\_s \cdot \left(y\_s \cdot \left(x\_s \cdot \begin{array}{l}
\mathbf{if}\;\frac{\cosh x\_m \cdot \frac{y\_m}{x\_m}}{z\_m} \leq \infty:\\
\;\;\;\;\frac{\cosh x\_m}{z\_m} \cdot \frac{y\_m}{x\_m}\\

\mathbf{else}:\\
\;\;\;\;y\_m \cdot \frac{\cosh x\_m}{z\_m \cdot x\_m}\\


\end{array}\right)\right)
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z) < +inf.0

    1. Initial program 84.0%

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\cosh x \cdot \frac{y}{x}}{z}} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{\cosh x \cdot \frac{y}{x}}}{z} \]
      3. *-commutativeN/A

        \[\leadsto \frac{\color{blue}{\frac{y}{x} \cdot \cosh x}}{z} \]
      4. associate-/l*N/A

        \[\leadsto \color{blue}{\frac{y}{x} \cdot \frac{\cosh x}{z}} \]
      5. *-commutativeN/A

        \[\leadsto \color{blue}{\frac{\cosh x}{z} \cdot \frac{y}{x}} \]
      6. lower-*.f64N/A

        \[\leadsto \color{blue}{\frac{\cosh x}{z} \cdot \frac{y}{x}} \]
      7. lower-/.f6484.0

        \[\leadsto \color{blue}{\frac{\cosh x}{z}} \cdot \frac{y}{x} \]
    3. Applied rewrites84.0%

      \[\leadsto \color{blue}{\frac{\cosh x}{z} \cdot \frac{y}{x}} \]

    if +inf.0 < (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z)

    1. Initial program 84.0%

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\cosh x \cdot \frac{y}{x}}{z}} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{\cosh x \cdot \frac{y}{x}}}{z} \]
      3. lift-/.f64N/A

        \[\leadsto \frac{\cosh x \cdot \color{blue}{\frac{y}{x}}}{z} \]
      4. associate-*r/N/A

        \[\leadsto \frac{\color{blue}{\frac{\cosh x \cdot y}{x}}}{z} \]
      5. associate-/l/N/A

        \[\leadsto \color{blue}{\frac{\cosh x \cdot y}{x \cdot z}} \]
      6. *-commutativeN/A

        \[\leadsto \frac{\color{blue}{y \cdot \cosh x}}{x \cdot z} \]
      7. associate-/l*N/A

        \[\leadsto \color{blue}{y \cdot \frac{\cosh x}{x \cdot z}} \]
      8. lower-*.f64N/A

        \[\leadsto \color{blue}{y \cdot \frac{\cosh x}{x \cdot z}} \]
      9. lower-/.f64N/A

        \[\leadsto y \cdot \color{blue}{\frac{\cosh x}{x \cdot z}} \]
      10. *-commutativeN/A

        \[\leadsto y \cdot \frac{\cosh x}{\color{blue}{z \cdot x}} \]
      11. lower-*.f6482.7

        \[\leadsto y \cdot \frac{\cosh x}{\color{blue}{z \cdot x}} \]
    3. Applied rewrites82.7%

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

Alternative 4: 85.7% accurate, 0.5× speedup?

\[\begin{array}{l} x\_m = \left|x\right| \\ x\_s = \mathsf{copysign}\left(1, x\right) \\ y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ z\_m = \left|z\right| \\ z\_s = \mathsf{copysign}\left(1, z\right) \\ z\_s \cdot \left(y\_s \cdot \left(x\_s \cdot \begin{array}{l} \mathbf{if}\;\cosh x\_m \cdot \frac{y\_m}{x\_m} \leq 10^{+145}:\\ \;\;\;\;\frac{1}{\frac{z\_m}{\frac{y\_m}{x\_m}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{y\_m \cdot \cosh x\_m}{z\_m \cdot x\_m}\\ \end{array}\right)\right) \end{array} \]
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
z\_m = (fabs.f64 z)
z\_s = (copysign.f64 #s(literal 1 binary64) z)
(FPCore (z_s y_s x_s x_m y_m z_m)
 :precision binary64
 (*
  z_s
  (*
   y_s
   (*
    x_s
    (if (<= (* (cosh x_m) (/ y_m x_m)) 1e+145)
      (/ 1.0 (/ z_m (/ y_m x_m)))
      (/ (* y_m (cosh x_m)) (* z_m x_m)))))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
z\_m = fabs(z);
z\_s = copysign(1.0, z);
double code(double z_s, double y_s, double x_s, double x_m, double y_m, double z_m) {
	double tmp;
	if ((cosh(x_m) * (y_m / x_m)) <= 1e+145) {
		tmp = 1.0 / (z_m / (y_m / x_m));
	} else {
		tmp = (y_m * cosh(x_m)) / (z_m * x_m);
	}
	return z_s * (y_s * (x_s * tmp));
}
x\_m =     private
x\_s =     private
y\_m =     private
y\_s =     private
z\_m =     private
z\_s =     private
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(z_s, y_s, x_s, x_m, y_m, z_m)
use fmin_fmax_functions
    real(8), intent (in) :: z_s
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x_s
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z_m
    real(8) :: tmp
    if ((cosh(x_m) * (y_m / x_m)) <= 1d+145) then
        tmp = 1.0d0 / (z_m / (y_m / x_m))
    else
        tmp = (y_m * cosh(x_m)) / (z_m * x_m)
    end if
    code = z_s * (y_s * (x_s * tmp))
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
z\_m = Math.abs(z);
z\_s = Math.copySign(1.0, z);
public static double code(double z_s, double y_s, double x_s, double x_m, double y_m, double z_m) {
	double tmp;
	if ((Math.cosh(x_m) * (y_m / x_m)) <= 1e+145) {
		tmp = 1.0 / (z_m / (y_m / x_m));
	} else {
		tmp = (y_m * Math.cosh(x_m)) / (z_m * x_m);
	}
	return z_s * (y_s * (x_s * tmp));
}
x\_m = math.fabs(x)
x\_s = math.copysign(1.0, x)
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
z\_m = math.fabs(z)
z\_s = math.copysign(1.0, z)
def code(z_s, y_s, x_s, x_m, y_m, z_m):
	tmp = 0
	if (math.cosh(x_m) * (y_m / x_m)) <= 1e+145:
		tmp = 1.0 / (z_m / (y_m / x_m))
	else:
		tmp = (y_m * math.cosh(x_m)) / (z_m * x_m)
	return z_s * (y_s * (x_s * tmp))
x\_m = abs(x)
x\_s = copysign(1.0, x)
y\_m = abs(y)
y\_s = copysign(1.0, y)
z\_m = abs(z)
z\_s = copysign(1.0, z)
function code(z_s, y_s, x_s, x_m, y_m, z_m)
	tmp = 0.0
	if (Float64(cosh(x_m) * Float64(y_m / x_m)) <= 1e+145)
		tmp = Float64(1.0 / Float64(z_m / Float64(y_m / x_m)));
	else
		tmp = Float64(Float64(y_m * cosh(x_m)) / Float64(z_m * x_m));
	end
	return Float64(z_s * Float64(y_s * Float64(x_s * tmp)))
end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
z\_m = abs(z);
z\_s = sign(z) * abs(1.0);
function tmp_2 = code(z_s, y_s, x_s, x_m, y_m, z_m)
	tmp = 0.0;
	if ((cosh(x_m) * (y_m / x_m)) <= 1e+145)
		tmp = 1.0 / (z_m / (y_m / x_m));
	else
		tmp = (y_m * cosh(x_m)) / (z_m * x_m);
	end
	tmp_2 = z_s * (y_s * (x_s * tmp));
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
z\_m = N[Abs[z], $MachinePrecision]
z\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[z$95$s_, y$95$s_, x$95$s_, x$95$m_, y$95$m_, z$95$m_] := N[(z$95$s * N[(y$95$s * N[(x$95$s * If[LessEqual[N[(N[Cosh[x$95$m], $MachinePrecision] * N[(y$95$m / x$95$m), $MachinePrecision]), $MachinePrecision], 1e+145], N[(1.0 / N[(z$95$m / N[(y$95$m / x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y$95$m * N[Cosh[x$95$m], $MachinePrecision]), $MachinePrecision] / N[(z$95$m * x$95$m), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
z\_m = \left|z\right|
\\
z\_s = \mathsf{copysign}\left(1, z\right)

\\
z\_s \cdot \left(y\_s \cdot \left(x\_s \cdot \begin{array}{l}
\mathbf{if}\;\cosh x\_m \cdot \frac{y\_m}{x\_m} \leq 10^{+145}:\\
\;\;\;\;\frac{1}{\frac{z\_m}{\frac{y\_m}{x\_m}}}\\

\mathbf{else}:\\
\;\;\;\;\frac{y\_m \cdot \cosh x\_m}{z\_m \cdot x\_m}\\


\end{array}\right)\right)
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (cosh.f64 x) (/.f64 y x)) < 9.9999999999999999e144

    1. Initial program 84.0%

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Taylor expanded in x around 0

      \[\leadsto \frac{\color{blue}{\frac{y}{x}}}{z} \]
    3. Step-by-step derivation
      1. lower-/.f6448.4

        \[\leadsto \frac{\frac{y}{\color{blue}{x}}}{z} \]
    4. Applied rewrites48.4%

      \[\leadsto \frac{\color{blue}{\frac{y}{x}}}{z} \]
    5. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\frac{y}{x}}{z}} \]
      2. div-flipN/A

        \[\leadsto \color{blue}{\frac{1}{\frac{z}{\frac{y}{x}}}} \]
      3. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{1}{\frac{z}{\frac{y}{x}}}} \]
      4. lower-/.f6448.2

        \[\leadsto \frac{1}{\color{blue}{\frac{z}{\frac{y}{x}}}} \]
    6. Applied rewrites48.2%

      \[\leadsto \color{blue}{\frac{1}{\frac{z}{\frac{y}{x}}}} \]

    if 9.9999999999999999e144 < (*.f64 (cosh.f64 x) (/.f64 y x))

    1. Initial program 84.0%

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\cosh x \cdot \frac{y}{x}}{z}} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{\cosh x \cdot \frac{y}{x}}}{z} \]
      3. lift-/.f64N/A

        \[\leadsto \frac{\cosh x \cdot \color{blue}{\frac{y}{x}}}{z} \]
      4. associate-*r/N/A

        \[\leadsto \frac{\color{blue}{\frac{\cosh x \cdot y}{x}}}{z} \]
      5. associate-/l/N/A

        \[\leadsto \color{blue}{\frac{\cosh x \cdot y}{x \cdot z}} \]
      6. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\cosh x \cdot y}{x \cdot z}} \]
      7. *-commutativeN/A

        \[\leadsto \frac{\color{blue}{y \cdot \cosh x}}{x \cdot z} \]
      8. lower-*.f64N/A

        \[\leadsto \frac{\color{blue}{y \cdot \cosh x}}{x \cdot z} \]
      9. *-commutativeN/A

        \[\leadsto \frac{y \cdot \cosh x}{\color{blue}{z \cdot x}} \]
      10. lower-*.f6483.0

        \[\leadsto \frac{y \cdot \cosh x}{\color{blue}{z \cdot x}} \]
    3. Applied rewrites83.0%

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

Alternative 5: 85.7% accurate, 0.5× speedup?

\[\begin{array}{l} x\_m = \left|x\right| \\ x\_s = \mathsf{copysign}\left(1, x\right) \\ y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ z\_m = \left|z\right| \\ z\_s = \mathsf{copysign}\left(1, z\right) \\ z\_s \cdot \left(y\_s \cdot \left(x\_s \cdot \begin{array}{l} \mathbf{if}\;\cosh x\_m \cdot \frac{y\_m}{x\_m} \leq 10^{+145}:\\ \;\;\;\;\frac{1}{\frac{z\_m}{\frac{y\_m}{x\_m}}}\\ \mathbf{else}:\\ \;\;\;\;y\_m \cdot \frac{\cosh x\_m}{z\_m \cdot x\_m}\\ \end{array}\right)\right) \end{array} \]
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
z\_m = (fabs.f64 z)
z\_s = (copysign.f64 #s(literal 1 binary64) z)
(FPCore (z_s y_s x_s x_m y_m z_m)
 :precision binary64
 (*
  z_s
  (*
   y_s
   (*
    x_s
    (if (<= (* (cosh x_m) (/ y_m x_m)) 1e+145)
      (/ 1.0 (/ z_m (/ y_m x_m)))
      (* y_m (/ (cosh x_m) (* z_m x_m))))))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
z\_m = fabs(z);
z\_s = copysign(1.0, z);
double code(double z_s, double y_s, double x_s, double x_m, double y_m, double z_m) {
	double tmp;
	if ((cosh(x_m) * (y_m / x_m)) <= 1e+145) {
		tmp = 1.0 / (z_m / (y_m / x_m));
	} else {
		tmp = y_m * (cosh(x_m) / (z_m * x_m));
	}
	return z_s * (y_s * (x_s * tmp));
}
x\_m =     private
x\_s =     private
y\_m =     private
y\_s =     private
z\_m =     private
z\_s =     private
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(z_s, y_s, x_s, x_m, y_m, z_m)
use fmin_fmax_functions
    real(8), intent (in) :: z_s
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x_s
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z_m
    real(8) :: tmp
    if ((cosh(x_m) * (y_m / x_m)) <= 1d+145) then
        tmp = 1.0d0 / (z_m / (y_m / x_m))
    else
        tmp = y_m * (cosh(x_m) / (z_m * x_m))
    end if
    code = z_s * (y_s * (x_s * tmp))
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
z\_m = Math.abs(z);
z\_s = Math.copySign(1.0, z);
public static double code(double z_s, double y_s, double x_s, double x_m, double y_m, double z_m) {
	double tmp;
	if ((Math.cosh(x_m) * (y_m / x_m)) <= 1e+145) {
		tmp = 1.0 / (z_m / (y_m / x_m));
	} else {
		tmp = y_m * (Math.cosh(x_m) / (z_m * x_m));
	}
	return z_s * (y_s * (x_s * tmp));
}
x\_m = math.fabs(x)
x\_s = math.copysign(1.0, x)
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
z\_m = math.fabs(z)
z\_s = math.copysign(1.0, z)
def code(z_s, y_s, x_s, x_m, y_m, z_m):
	tmp = 0
	if (math.cosh(x_m) * (y_m / x_m)) <= 1e+145:
		tmp = 1.0 / (z_m / (y_m / x_m))
	else:
		tmp = y_m * (math.cosh(x_m) / (z_m * x_m))
	return z_s * (y_s * (x_s * tmp))
x\_m = abs(x)
x\_s = copysign(1.0, x)
y\_m = abs(y)
y\_s = copysign(1.0, y)
z\_m = abs(z)
z\_s = copysign(1.0, z)
function code(z_s, y_s, x_s, x_m, y_m, z_m)
	tmp = 0.0
	if (Float64(cosh(x_m) * Float64(y_m / x_m)) <= 1e+145)
		tmp = Float64(1.0 / Float64(z_m / Float64(y_m / x_m)));
	else
		tmp = Float64(y_m * Float64(cosh(x_m) / Float64(z_m * x_m)));
	end
	return Float64(z_s * Float64(y_s * Float64(x_s * tmp)))
end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
z\_m = abs(z);
z\_s = sign(z) * abs(1.0);
function tmp_2 = code(z_s, y_s, x_s, x_m, y_m, z_m)
	tmp = 0.0;
	if ((cosh(x_m) * (y_m / x_m)) <= 1e+145)
		tmp = 1.0 / (z_m / (y_m / x_m));
	else
		tmp = y_m * (cosh(x_m) / (z_m * x_m));
	end
	tmp_2 = z_s * (y_s * (x_s * tmp));
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
z\_m = N[Abs[z], $MachinePrecision]
z\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[z$95$s_, y$95$s_, x$95$s_, x$95$m_, y$95$m_, z$95$m_] := N[(z$95$s * N[(y$95$s * N[(x$95$s * If[LessEqual[N[(N[Cosh[x$95$m], $MachinePrecision] * N[(y$95$m / x$95$m), $MachinePrecision]), $MachinePrecision], 1e+145], N[(1.0 / N[(z$95$m / N[(y$95$m / x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y$95$m * N[(N[Cosh[x$95$m], $MachinePrecision] / N[(z$95$m * x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
z\_m = \left|z\right|
\\
z\_s = \mathsf{copysign}\left(1, z\right)

\\
z\_s \cdot \left(y\_s \cdot \left(x\_s \cdot \begin{array}{l}
\mathbf{if}\;\cosh x\_m \cdot \frac{y\_m}{x\_m} \leq 10^{+145}:\\
\;\;\;\;\frac{1}{\frac{z\_m}{\frac{y\_m}{x\_m}}}\\

\mathbf{else}:\\
\;\;\;\;y\_m \cdot \frac{\cosh x\_m}{z\_m \cdot x\_m}\\


\end{array}\right)\right)
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (cosh.f64 x) (/.f64 y x)) < 9.9999999999999999e144

    1. Initial program 84.0%

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Taylor expanded in x around 0

      \[\leadsto \frac{\color{blue}{\frac{y}{x}}}{z} \]
    3. Step-by-step derivation
      1. lower-/.f6448.4

        \[\leadsto \frac{\frac{y}{\color{blue}{x}}}{z} \]
    4. Applied rewrites48.4%

      \[\leadsto \frac{\color{blue}{\frac{y}{x}}}{z} \]
    5. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\frac{y}{x}}{z}} \]
      2. div-flipN/A

        \[\leadsto \color{blue}{\frac{1}{\frac{z}{\frac{y}{x}}}} \]
      3. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{1}{\frac{z}{\frac{y}{x}}}} \]
      4. lower-/.f6448.2

        \[\leadsto \frac{1}{\color{blue}{\frac{z}{\frac{y}{x}}}} \]
    6. Applied rewrites48.2%

      \[\leadsto \color{blue}{\frac{1}{\frac{z}{\frac{y}{x}}}} \]

    if 9.9999999999999999e144 < (*.f64 (cosh.f64 x) (/.f64 y x))

    1. Initial program 84.0%

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\cosh x \cdot \frac{y}{x}}{z}} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{\cosh x \cdot \frac{y}{x}}}{z} \]
      3. lift-/.f64N/A

        \[\leadsto \frac{\cosh x \cdot \color{blue}{\frac{y}{x}}}{z} \]
      4. associate-*r/N/A

        \[\leadsto \frac{\color{blue}{\frac{\cosh x \cdot y}{x}}}{z} \]
      5. associate-/l/N/A

        \[\leadsto \color{blue}{\frac{\cosh x \cdot y}{x \cdot z}} \]
      6. *-commutativeN/A

        \[\leadsto \frac{\color{blue}{y \cdot \cosh x}}{x \cdot z} \]
      7. associate-/l*N/A

        \[\leadsto \color{blue}{y \cdot \frac{\cosh x}{x \cdot z}} \]
      8. lower-*.f64N/A

        \[\leadsto \color{blue}{y \cdot \frac{\cosh x}{x \cdot z}} \]
      9. lower-/.f64N/A

        \[\leadsto y \cdot \color{blue}{\frac{\cosh x}{x \cdot z}} \]
      10. *-commutativeN/A

        \[\leadsto y \cdot \frac{\cosh x}{\color{blue}{z \cdot x}} \]
      11. lower-*.f6482.7

        \[\leadsto y \cdot \frac{\cosh x}{\color{blue}{z \cdot x}} \]
    3. Applied rewrites82.7%

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

Alternative 6: 56.6% accurate, 0.6× speedup?

\[\begin{array}{l} x\_m = \left|x\right| \\ x\_s = \mathsf{copysign}\left(1, x\right) \\ y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ z\_m = \left|z\right| \\ z\_s = \mathsf{copysign}\left(1, z\right) \\ z\_s \cdot \left(y\_s \cdot \left(x\_s \cdot \begin{array}{l} \mathbf{if}\;\frac{\cosh x\_m \cdot \frac{y\_m}{x\_m}}{z\_m} \leq 4 \cdot 10^{+111}:\\ \;\;\;\;\frac{1}{\frac{z\_m}{\frac{y\_m}{x\_m}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y\_m}{z\_m}}{x\_m}\\ \end{array}\right)\right) \end{array} \]
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
z\_m = (fabs.f64 z)
z\_s = (copysign.f64 #s(literal 1 binary64) z)
(FPCore (z_s y_s x_s x_m y_m z_m)
 :precision binary64
 (*
  z_s
  (*
   y_s
   (*
    x_s
    (if (<= (/ (* (cosh x_m) (/ y_m x_m)) z_m) 4e+111)
      (/ 1.0 (/ z_m (/ y_m x_m)))
      (/ (/ y_m z_m) x_m))))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
z\_m = fabs(z);
z\_s = copysign(1.0, z);
double code(double z_s, double y_s, double x_s, double x_m, double y_m, double z_m) {
	double tmp;
	if (((cosh(x_m) * (y_m / x_m)) / z_m) <= 4e+111) {
		tmp = 1.0 / (z_m / (y_m / x_m));
	} else {
		tmp = (y_m / z_m) / x_m;
	}
	return z_s * (y_s * (x_s * tmp));
}
x\_m =     private
x\_s =     private
y\_m =     private
y\_s =     private
z\_m =     private
z\_s =     private
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(z_s, y_s, x_s, x_m, y_m, z_m)
use fmin_fmax_functions
    real(8), intent (in) :: z_s
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x_s
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z_m
    real(8) :: tmp
    if (((cosh(x_m) * (y_m / x_m)) / z_m) <= 4d+111) then
        tmp = 1.0d0 / (z_m / (y_m / x_m))
    else
        tmp = (y_m / z_m) / x_m
    end if
    code = z_s * (y_s * (x_s * tmp))
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
z\_m = Math.abs(z);
z\_s = Math.copySign(1.0, z);
public static double code(double z_s, double y_s, double x_s, double x_m, double y_m, double z_m) {
	double tmp;
	if (((Math.cosh(x_m) * (y_m / x_m)) / z_m) <= 4e+111) {
		tmp = 1.0 / (z_m / (y_m / x_m));
	} else {
		tmp = (y_m / z_m) / x_m;
	}
	return z_s * (y_s * (x_s * tmp));
}
x\_m = math.fabs(x)
x\_s = math.copysign(1.0, x)
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
z\_m = math.fabs(z)
z\_s = math.copysign(1.0, z)
def code(z_s, y_s, x_s, x_m, y_m, z_m):
	tmp = 0
	if ((math.cosh(x_m) * (y_m / x_m)) / z_m) <= 4e+111:
		tmp = 1.0 / (z_m / (y_m / x_m))
	else:
		tmp = (y_m / z_m) / x_m
	return z_s * (y_s * (x_s * tmp))
x\_m = abs(x)
x\_s = copysign(1.0, x)
y\_m = abs(y)
y\_s = copysign(1.0, y)
z\_m = abs(z)
z\_s = copysign(1.0, z)
function code(z_s, y_s, x_s, x_m, y_m, z_m)
	tmp = 0.0
	if (Float64(Float64(cosh(x_m) * Float64(y_m / x_m)) / z_m) <= 4e+111)
		tmp = Float64(1.0 / Float64(z_m / Float64(y_m / x_m)));
	else
		tmp = Float64(Float64(y_m / z_m) / x_m);
	end
	return Float64(z_s * Float64(y_s * Float64(x_s * tmp)))
end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
z\_m = abs(z);
z\_s = sign(z) * abs(1.0);
function tmp_2 = code(z_s, y_s, x_s, x_m, y_m, z_m)
	tmp = 0.0;
	if (((cosh(x_m) * (y_m / x_m)) / z_m) <= 4e+111)
		tmp = 1.0 / (z_m / (y_m / x_m));
	else
		tmp = (y_m / z_m) / x_m;
	end
	tmp_2 = z_s * (y_s * (x_s * tmp));
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
z\_m = N[Abs[z], $MachinePrecision]
z\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[z$95$s_, y$95$s_, x$95$s_, x$95$m_, y$95$m_, z$95$m_] := N[(z$95$s * N[(y$95$s * N[(x$95$s * If[LessEqual[N[(N[(N[Cosh[x$95$m], $MachinePrecision] * N[(y$95$m / x$95$m), $MachinePrecision]), $MachinePrecision] / z$95$m), $MachinePrecision], 4e+111], N[(1.0 / N[(z$95$m / N[(y$95$m / x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y$95$m / z$95$m), $MachinePrecision] / x$95$m), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
z\_m = \left|z\right|
\\
z\_s = \mathsf{copysign}\left(1, z\right)

\\
z\_s \cdot \left(y\_s \cdot \left(x\_s \cdot \begin{array}{l}
\mathbf{if}\;\frac{\cosh x\_m \cdot \frac{y\_m}{x\_m}}{z\_m} \leq 4 \cdot 10^{+111}:\\
\;\;\;\;\frac{1}{\frac{z\_m}{\frac{y\_m}{x\_m}}}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{y\_m}{z\_m}}{x\_m}\\


\end{array}\right)\right)
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z) < 3.99999999999999983e111

    1. Initial program 84.0%

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Taylor expanded in x around 0

      \[\leadsto \frac{\color{blue}{\frac{y}{x}}}{z} \]
    3. Step-by-step derivation
      1. lower-/.f6448.4

        \[\leadsto \frac{\frac{y}{\color{blue}{x}}}{z} \]
    4. Applied rewrites48.4%

      \[\leadsto \frac{\color{blue}{\frac{y}{x}}}{z} \]
    5. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\frac{y}{x}}{z}} \]
      2. div-flipN/A

        \[\leadsto \color{blue}{\frac{1}{\frac{z}{\frac{y}{x}}}} \]
      3. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{1}{\frac{z}{\frac{y}{x}}}} \]
      4. lower-/.f6448.2

        \[\leadsto \frac{1}{\color{blue}{\frac{z}{\frac{y}{x}}}} \]
    6. Applied rewrites48.2%

      \[\leadsto \color{blue}{\frac{1}{\frac{z}{\frac{y}{x}}}} \]

    if 3.99999999999999983e111 < (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z)

    1. Initial program 84.0%

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\cosh x \cdot \frac{y}{x}}{z}} \]
      2. mult-flipN/A

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

        \[\leadsto \color{blue}{\left(\cosh x \cdot \frac{y}{x}\right)} \cdot \frac{1}{z} \]
      4. lift-/.f64N/A

        \[\leadsto \left(\cosh x \cdot \color{blue}{\frac{y}{x}}\right) \cdot \frac{1}{z} \]
      5. associate-*r/N/A

        \[\leadsto \color{blue}{\frac{\cosh x \cdot y}{x}} \cdot \frac{1}{z} \]
      6. associate-*l/N/A

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

        \[\leadsto \color{blue}{\frac{\left(\cosh x \cdot y\right) \cdot \frac{1}{z}}{x}} \]
      8. mult-flip-revN/A

        \[\leadsto \frac{\color{blue}{\frac{\cosh x \cdot y}{z}}}{x} \]
      9. lower-/.f64N/A

        \[\leadsto \frac{\color{blue}{\frac{\cosh x \cdot y}{z}}}{x} \]
      10. *-commutativeN/A

        \[\leadsto \frac{\frac{\color{blue}{y \cdot \cosh x}}{z}}{x} \]
      11. lower-*.f6496.0

        \[\leadsto \frac{\frac{\color{blue}{y \cdot \cosh x}}{z}}{x} \]
    3. Applied rewrites96.0%

      \[\leadsto \color{blue}{\frac{\frac{y \cdot \cosh x}{z}}{x}} \]
    4. Taylor expanded in x around 0

      \[\leadsto \frac{\frac{\color{blue}{y}}{z}}{x} \]
    5. Step-by-step derivation
      1. Applied rewrites52.8%

        \[\leadsto \frac{\frac{\color{blue}{y}}{z}}{x} \]
    6. Recombined 2 regimes into one program.
    7. Add Preprocessing

    Alternative 7: 56.6% accurate, 0.6× speedup?

    \[\begin{array}{l} x\_m = \left|x\right| \\ x\_s = \mathsf{copysign}\left(1, x\right) \\ y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ z\_m = \left|z\right| \\ z\_s = \mathsf{copysign}\left(1, z\right) \\ z\_s \cdot \left(y\_s \cdot \left(x\_s \cdot \begin{array}{l} \mathbf{if}\;\frac{\cosh x\_m \cdot \frac{y\_m}{x\_m}}{z\_m} \leq 2 \cdot 10^{-132}:\\ \;\;\;\;\frac{1}{z\_m} \cdot \frac{y\_m}{x\_m}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y\_m}{z\_m}}{x\_m}\\ \end{array}\right)\right) \end{array} \]
    x\_m = (fabs.f64 x)
    x\_s = (copysign.f64 #s(literal 1 binary64) x)
    y\_m = (fabs.f64 y)
    y\_s = (copysign.f64 #s(literal 1 binary64) y)
    z\_m = (fabs.f64 z)
    z\_s = (copysign.f64 #s(literal 1 binary64) z)
    (FPCore (z_s y_s x_s x_m y_m z_m)
     :precision binary64
     (*
      z_s
      (*
       y_s
       (*
        x_s
        (if (<= (/ (* (cosh x_m) (/ y_m x_m)) z_m) 2e-132)
          (* (/ 1.0 z_m) (/ y_m x_m))
          (/ (/ y_m z_m) x_m))))))
    x\_m = fabs(x);
    x\_s = copysign(1.0, x);
    y\_m = fabs(y);
    y\_s = copysign(1.0, y);
    z\_m = fabs(z);
    z\_s = copysign(1.0, z);
    double code(double z_s, double y_s, double x_s, double x_m, double y_m, double z_m) {
    	double tmp;
    	if (((cosh(x_m) * (y_m / x_m)) / z_m) <= 2e-132) {
    		tmp = (1.0 / z_m) * (y_m / x_m);
    	} else {
    		tmp = (y_m / z_m) / x_m;
    	}
    	return z_s * (y_s * (x_s * tmp));
    }
    
    x\_m =     private
    x\_s =     private
    y\_m =     private
    y\_s =     private
    z\_m =     private
    z\_s =     private
    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(z_s, y_s, x_s, x_m, y_m, z_m)
    use fmin_fmax_functions
        real(8), intent (in) :: z_s
        real(8), intent (in) :: y_s
        real(8), intent (in) :: x_s
        real(8), intent (in) :: x_m
        real(8), intent (in) :: y_m
        real(8), intent (in) :: z_m
        real(8) :: tmp
        if (((cosh(x_m) * (y_m / x_m)) / z_m) <= 2d-132) then
            tmp = (1.0d0 / z_m) * (y_m / x_m)
        else
            tmp = (y_m / z_m) / x_m
        end if
        code = z_s * (y_s * (x_s * tmp))
    end function
    
    x\_m = Math.abs(x);
    x\_s = Math.copySign(1.0, x);
    y\_m = Math.abs(y);
    y\_s = Math.copySign(1.0, y);
    z\_m = Math.abs(z);
    z\_s = Math.copySign(1.0, z);
    public static double code(double z_s, double y_s, double x_s, double x_m, double y_m, double z_m) {
    	double tmp;
    	if (((Math.cosh(x_m) * (y_m / x_m)) / z_m) <= 2e-132) {
    		tmp = (1.0 / z_m) * (y_m / x_m);
    	} else {
    		tmp = (y_m / z_m) / x_m;
    	}
    	return z_s * (y_s * (x_s * tmp));
    }
    
    x\_m = math.fabs(x)
    x\_s = math.copysign(1.0, x)
    y\_m = math.fabs(y)
    y\_s = math.copysign(1.0, y)
    z\_m = math.fabs(z)
    z\_s = math.copysign(1.0, z)
    def code(z_s, y_s, x_s, x_m, y_m, z_m):
    	tmp = 0
    	if ((math.cosh(x_m) * (y_m / x_m)) / z_m) <= 2e-132:
    		tmp = (1.0 / z_m) * (y_m / x_m)
    	else:
    		tmp = (y_m / z_m) / x_m
    	return z_s * (y_s * (x_s * tmp))
    
    x\_m = abs(x)
    x\_s = copysign(1.0, x)
    y\_m = abs(y)
    y\_s = copysign(1.0, y)
    z\_m = abs(z)
    z\_s = copysign(1.0, z)
    function code(z_s, y_s, x_s, x_m, y_m, z_m)
    	tmp = 0.0
    	if (Float64(Float64(cosh(x_m) * Float64(y_m / x_m)) / z_m) <= 2e-132)
    		tmp = Float64(Float64(1.0 / z_m) * Float64(y_m / x_m));
    	else
    		tmp = Float64(Float64(y_m / z_m) / x_m);
    	end
    	return Float64(z_s * Float64(y_s * Float64(x_s * tmp)))
    end
    
    x\_m = abs(x);
    x\_s = sign(x) * abs(1.0);
    y\_m = abs(y);
    y\_s = sign(y) * abs(1.0);
    z\_m = abs(z);
    z\_s = sign(z) * abs(1.0);
    function tmp_2 = code(z_s, y_s, x_s, x_m, y_m, z_m)
    	tmp = 0.0;
    	if (((cosh(x_m) * (y_m / x_m)) / z_m) <= 2e-132)
    		tmp = (1.0 / z_m) * (y_m / x_m);
    	else
    		tmp = (y_m / z_m) / x_m;
    	end
    	tmp_2 = z_s * (y_s * (x_s * tmp));
    end
    
    x\_m = N[Abs[x], $MachinePrecision]
    x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
    y\_m = N[Abs[y], $MachinePrecision]
    y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
    z\_m = N[Abs[z], $MachinePrecision]
    z\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
    code[z$95$s_, y$95$s_, x$95$s_, x$95$m_, y$95$m_, z$95$m_] := N[(z$95$s * N[(y$95$s * N[(x$95$s * If[LessEqual[N[(N[(N[Cosh[x$95$m], $MachinePrecision] * N[(y$95$m / x$95$m), $MachinePrecision]), $MachinePrecision] / z$95$m), $MachinePrecision], 2e-132], N[(N[(1.0 / z$95$m), $MachinePrecision] * N[(y$95$m / x$95$m), $MachinePrecision]), $MachinePrecision], N[(N[(y$95$m / z$95$m), $MachinePrecision] / x$95$m), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
    
    \begin{array}{l}
    x\_m = \left|x\right|
    \\
    x\_s = \mathsf{copysign}\left(1, x\right)
    \\
    y\_m = \left|y\right|
    \\
    y\_s = \mathsf{copysign}\left(1, y\right)
    \\
    z\_m = \left|z\right|
    \\
    z\_s = \mathsf{copysign}\left(1, z\right)
    
    \\
    z\_s \cdot \left(y\_s \cdot \left(x\_s \cdot \begin{array}{l}
    \mathbf{if}\;\frac{\cosh x\_m \cdot \frac{y\_m}{x\_m}}{z\_m} \leq 2 \cdot 10^{-132}:\\
    \;\;\;\;\frac{1}{z\_m} \cdot \frac{y\_m}{x\_m}\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{\frac{y\_m}{z\_m}}{x\_m}\\
    
    
    \end{array}\right)\right)
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z) < 2e-132

      1. Initial program 84.0%

        \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
      2. Step-by-step derivation
        1. lift-/.f64N/A

          \[\leadsto \color{blue}{\frac{\cosh x \cdot \frac{y}{x}}{z}} \]
        2. lift-*.f64N/A

          \[\leadsto \frac{\color{blue}{\cosh x \cdot \frac{y}{x}}}{z} \]
        3. *-commutativeN/A

          \[\leadsto \frac{\color{blue}{\frac{y}{x} \cdot \cosh x}}{z} \]
        4. associate-/l*N/A

          \[\leadsto \color{blue}{\frac{y}{x} \cdot \frac{\cosh x}{z}} \]
        5. *-commutativeN/A

          \[\leadsto \color{blue}{\frac{\cosh x}{z} \cdot \frac{y}{x}} \]
        6. lower-*.f64N/A

          \[\leadsto \color{blue}{\frac{\cosh x}{z} \cdot \frac{y}{x}} \]
        7. lower-/.f6484.0

          \[\leadsto \color{blue}{\frac{\cosh x}{z}} \cdot \frac{y}{x} \]
      3. Applied rewrites84.0%

        \[\leadsto \color{blue}{\frac{\cosh x}{z} \cdot \frac{y}{x}} \]
      4. Taylor expanded in x around 0

        \[\leadsto \frac{\color{blue}{1}}{z} \cdot \frac{y}{x} \]
      5. Step-by-step derivation
        1. Applied rewrites48.4%

          \[\leadsto \frac{\color{blue}{1}}{z} \cdot \frac{y}{x} \]

        if 2e-132 < (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z)

        1. Initial program 84.0%

          \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
        2. Step-by-step derivation
          1. lift-/.f64N/A

            \[\leadsto \color{blue}{\frac{\cosh x \cdot \frac{y}{x}}{z}} \]
          2. mult-flipN/A

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

            \[\leadsto \color{blue}{\left(\cosh x \cdot \frac{y}{x}\right)} \cdot \frac{1}{z} \]
          4. lift-/.f64N/A

            \[\leadsto \left(\cosh x \cdot \color{blue}{\frac{y}{x}}\right) \cdot \frac{1}{z} \]
          5. associate-*r/N/A

            \[\leadsto \color{blue}{\frac{\cosh x \cdot y}{x}} \cdot \frac{1}{z} \]
          6. associate-*l/N/A

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

            \[\leadsto \color{blue}{\frac{\left(\cosh x \cdot y\right) \cdot \frac{1}{z}}{x}} \]
          8. mult-flip-revN/A

            \[\leadsto \frac{\color{blue}{\frac{\cosh x \cdot y}{z}}}{x} \]
          9. lower-/.f64N/A

            \[\leadsto \frac{\color{blue}{\frac{\cosh x \cdot y}{z}}}{x} \]
          10. *-commutativeN/A

            \[\leadsto \frac{\frac{\color{blue}{y \cdot \cosh x}}{z}}{x} \]
          11. lower-*.f6496.0

            \[\leadsto \frac{\frac{\color{blue}{y \cdot \cosh x}}{z}}{x} \]
        3. Applied rewrites96.0%

          \[\leadsto \color{blue}{\frac{\frac{y \cdot \cosh x}{z}}{x}} \]
        4. Taylor expanded in x around 0

          \[\leadsto \frac{\frac{\color{blue}{y}}{z}}{x} \]
        5. Step-by-step derivation
          1. Applied rewrites52.8%

            \[\leadsto \frac{\frac{\color{blue}{y}}{z}}{x} \]
        6. Recombined 2 regimes into one program.
        7. Add Preprocessing

        Alternative 8: 56.4% accurate, 0.7× speedup?

        \[\begin{array}{l} x\_m = \left|x\right| \\ x\_s = \mathsf{copysign}\left(1, x\right) \\ y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ z\_m = \left|z\right| \\ z\_s = \mathsf{copysign}\left(1, z\right) \\ z\_s \cdot \left(y\_s \cdot \left(x\_s \cdot \begin{array}{l} \mathbf{if}\;\frac{\cosh x\_m \cdot \frac{y\_m}{x\_m}}{z\_m} \leq 2 \cdot 10^{+66}:\\ \;\;\;\;\frac{\frac{y\_m}{x\_m}}{z\_m}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y\_m}{z\_m}}{x\_m}\\ \end{array}\right)\right) \end{array} \]
        x\_m = (fabs.f64 x)
        x\_s = (copysign.f64 #s(literal 1 binary64) x)
        y\_m = (fabs.f64 y)
        y\_s = (copysign.f64 #s(literal 1 binary64) y)
        z\_m = (fabs.f64 z)
        z\_s = (copysign.f64 #s(literal 1 binary64) z)
        (FPCore (z_s y_s x_s x_m y_m z_m)
         :precision binary64
         (*
          z_s
          (*
           y_s
           (*
            x_s
            (if (<= (/ (* (cosh x_m) (/ y_m x_m)) z_m) 2e+66)
              (/ (/ y_m x_m) z_m)
              (/ (/ y_m z_m) x_m))))))
        x\_m = fabs(x);
        x\_s = copysign(1.0, x);
        y\_m = fabs(y);
        y\_s = copysign(1.0, y);
        z\_m = fabs(z);
        z\_s = copysign(1.0, z);
        double code(double z_s, double y_s, double x_s, double x_m, double y_m, double z_m) {
        	double tmp;
        	if (((cosh(x_m) * (y_m / x_m)) / z_m) <= 2e+66) {
        		tmp = (y_m / x_m) / z_m;
        	} else {
        		tmp = (y_m / z_m) / x_m;
        	}
        	return z_s * (y_s * (x_s * tmp));
        }
        
        x\_m =     private
        x\_s =     private
        y\_m =     private
        y\_s =     private
        z\_m =     private
        z\_s =     private
        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(z_s, y_s, x_s, x_m, y_m, z_m)
        use fmin_fmax_functions
            real(8), intent (in) :: z_s
            real(8), intent (in) :: y_s
            real(8), intent (in) :: x_s
            real(8), intent (in) :: x_m
            real(8), intent (in) :: y_m
            real(8), intent (in) :: z_m
            real(8) :: tmp
            if (((cosh(x_m) * (y_m / x_m)) / z_m) <= 2d+66) then
                tmp = (y_m / x_m) / z_m
            else
                tmp = (y_m / z_m) / x_m
            end if
            code = z_s * (y_s * (x_s * tmp))
        end function
        
        x\_m = Math.abs(x);
        x\_s = Math.copySign(1.0, x);
        y\_m = Math.abs(y);
        y\_s = Math.copySign(1.0, y);
        z\_m = Math.abs(z);
        z\_s = Math.copySign(1.0, z);
        public static double code(double z_s, double y_s, double x_s, double x_m, double y_m, double z_m) {
        	double tmp;
        	if (((Math.cosh(x_m) * (y_m / x_m)) / z_m) <= 2e+66) {
        		tmp = (y_m / x_m) / z_m;
        	} else {
        		tmp = (y_m / z_m) / x_m;
        	}
        	return z_s * (y_s * (x_s * tmp));
        }
        
        x\_m = math.fabs(x)
        x\_s = math.copysign(1.0, x)
        y\_m = math.fabs(y)
        y\_s = math.copysign(1.0, y)
        z\_m = math.fabs(z)
        z\_s = math.copysign(1.0, z)
        def code(z_s, y_s, x_s, x_m, y_m, z_m):
        	tmp = 0
        	if ((math.cosh(x_m) * (y_m / x_m)) / z_m) <= 2e+66:
        		tmp = (y_m / x_m) / z_m
        	else:
        		tmp = (y_m / z_m) / x_m
        	return z_s * (y_s * (x_s * tmp))
        
        x\_m = abs(x)
        x\_s = copysign(1.0, x)
        y\_m = abs(y)
        y\_s = copysign(1.0, y)
        z\_m = abs(z)
        z\_s = copysign(1.0, z)
        function code(z_s, y_s, x_s, x_m, y_m, z_m)
        	tmp = 0.0
        	if (Float64(Float64(cosh(x_m) * Float64(y_m / x_m)) / z_m) <= 2e+66)
        		tmp = Float64(Float64(y_m / x_m) / z_m);
        	else
        		tmp = Float64(Float64(y_m / z_m) / x_m);
        	end
        	return Float64(z_s * Float64(y_s * Float64(x_s * tmp)))
        end
        
        x\_m = abs(x);
        x\_s = sign(x) * abs(1.0);
        y\_m = abs(y);
        y\_s = sign(y) * abs(1.0);
        z\_m = abs(z);
        z\_s = sign(z) * abs(1.0);
        function tmp_2 = code(z_s, y_s, x_s, x_m, y_m, z_m)
        	tmp = 0.0;
        	if (((cosh(x_m) * (y_m / x_m)) / z_m) <= 2e+66)
        		tmp = (y_m / x_m) / z_m;
        	else
        		tmp = (y_m / z_m) / x_m;
        	end
        	tmp_2 = z_s * (y_s * (x_s * tmp));
        end
        
        x\_m = N[Abs[x], $MachinePrecision]
        x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
        y\_m = N[Abs[y], $MachinePrecision]
        y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
        z\_m = N[Abs[z], $MachinePrecision]
        z\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
        code[z$95$s_, y$95$s_, x$95$s_, x$95$m_, y$95$m_, z$95$m_] := N[(z$95$s * N[(y$95$s * N[(x$95$s * If[LessEqual[N[(N[(N[Cosh[x$95$m], $MachinePrecision] * N[(y$95$m / x$95$m), $MachinePrecision]), $MachinePrecision] / z$95$m), $MachinePrecision], 2e+66], N[(N[(y$95$m / x$95$m), $MachinePrecision] / z$95$m), $MachinePrecision], N[(N[(y$95$m / z$95$m), $MachinePrecision] / x$95$m), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
        
        \begin{array}{l}
        x\_m = \left|x\right|
        \\
        x\_s = \mathsf{copysign}\left(1, x\right)
        \\
        y\_m = \left|y\right|
        \\
        y\_s = \mathsf{copysign}\left(1, y\right)
        \\
        z\_m = \left|z\right|
        \\
        z\_s = \mathsf{copysign}\left(1, z\right)
        
        \\
        z\_s \cdot \left(y\_s \cdot \left(x\_s \cdot \begin{array}{l}
        \mathbf{if}\;\frac{\cosh x\_m \cdot \frac{y\_m}{x\_m}}{z\_m} \leq 2 \cdot 10^{+66}:\\
        \;\;\;\;\frac{\frac{y\_m}{x\_m}}{z\_m}\\
        
        \mathbf{else}:\\
        \;\;\;\;\frac{\frac{y\_m}{z\_m}}{x\_m}\\
        
        
        \end{array}\right)\right)
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z) < 1.99999999999999989e66

          1. Initial program 84.0%

            \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
          2. Taylor expanded in x around 0

            \[\leadsto \frac{\color{blue}{\frac{y}{x}}}{z} \]
          3. Step-by-step derivation
            1. lower-/.f6448.4

              \[\leadsto \frac{\frac{y}{\color{blue}{x}}}{z} \]
          4. Applied rewrites48.4%

            \[\leadsto \frac{\color{blue}{\frac{y}{x}}}{z} \]

          if 1.99999999999999989e66 < (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z)

          1. Initial program 84.0%

            \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
          2. Step-by-step derivation
            1. lift-/.f64N/A

              \[\leadsto \color{blue}{\frac{\cosh x \cdot \frac{y}{x}}{z}} \]
            2. mult-flipN/A

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

              \[\leadsto \color{blue}{\left(\cosh x \cdot \frac{y}{x}\right)} \cdot \frac{1}{z} \]
            4. lift-/.f64N/A

              \[\leadsto \left(\cosh x \cdot \color{blue}{\frac{y}{x}}\right) \cdot \frac{1}{z} \]
            5. associate-*r/N/A

              \[\leadsto \color{blue}{\frac{\cosh x \cdot y}{x}} \cdot \frac{1}{z} \]
            6. associate-*l/N/A

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

              \[\leadsto \color{blue}{\frac{\left(\cosh x \cdot y\right) \cdot \frac{1}{z}}{x}} \]
            8. mult-flip-revN/A

              \[\leadsto \frac{\color{blue}{\frac{\cosh x \cdot y}{z}}}{x} \]
            9. lower-/.f64N/A

              \[\leadsto \frac{\color{blue}{\frac{\cosh x \cdot y}{z}}}{x} \]
            10. *-commutativeN/A

              \[\leadsto \frac{\frac{\color{blue}{y \cdot \cosh x}}{z}}{x} \]
            11. lower-*.f6496.0

              \[\leadsto \frac{\frac{\color{blue}{y \cdot \cosh x}}{z}}{x} \]
          3. Applied rewrites96.0%

            \[\leadsto \color{blue}{\frac{\frac{y \cdot \cosh x}{z}}{x}} \]
          4. Taylor expanded in x around 0

            \[\leadsto \frac{\frac{\color{blue}{y}}{z}}{x} \]
          5. Step-by-step derivation
            1. Applied rewrites52.8%

              \[\leadsto \frac{\frac{\color{blue}{y}}{z}}{x} \]
          6. Recombined 2 regimes into one program.
          7. Add Preprocessing

          Alternative 9: 55.8% accurate, 0.6× speedup?

          \[\begin{array}{l} x\_m = \left|x\right| \\ x\_s = \mathsf{copysign}\left(1, x\right) \\ y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ z\_m = \left|z\right| \\ z\_s = \mathsf{copysign}\left(1, z\right) \\ z\_s \cdot \left(y\_s \cdot \left(x\_s \cdot \begin{array}{l} \mathbf{if}\;\frac{\cosh x\_m \cdot \frac{y\_m}{x\_m}}{z\_m} \leq 5 \cdot 10^{-16}:\\ \;\;\;\;y\_m \cdot \frac{1}{z\_m \cdot x\_m}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y\_m}{z\_m}}{x\_m}\\ \end{array}\right)\right) \end{array} \]
          x\_m = (fabs.f64 x)
          x\_s = (copysign.f64 #s(literal 1 binary64) x)
          y\_m = (fabs.f64 y)
          y\_s = (copysign.f64 #s(literal 1 binary64) y)
          z\_m = (fabs.f64 z)
          z\_s = (copysign.f64 #s(literal 1 binary64) z)
          (FPCore (z_s y_s x_s x_m y_m z_m)
           :precision binary64
           (*
            z_s
            (*
             y_s
             (*
              x_s
              (if (<= (/ (* (cosh x_m) (/ y_m x_m)) z_m) 5e-16)
                (* y_m (/ 1.0 (* z_m x_m)))
                (/ (/ y_m z_m) x_m))))))
          x\_m = fabs(x);
          x\_s = copysign(1.0, x);
          y\_m = fabs(y);
          y\_s = copysign(1.0, y);
          z\_m = fabs(z);
          z\_s = copysign(1.0, z);
          double code(double z_s, double y_s, double x_s, double x_m, double y_m, double z_m) {
          	double tmp;
          	if (((cosh(x_m) * (y_m / x_m)) / z_m) <= 5e-16) {
          		tmp = y_m * (1.0 / (z_m * x_m));
          	} else {
          		tmp = (y_m / z_m) / x_m;
          	}
          	return z_s * (y_s * (x_s * tmp));
          }
          
          x\_m =     private
          x\_s =     private
          y\_m =     private
          y\_s =     private
          z\_m =     private
          z\_s =     private
          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(z_s, y_s, x_s, x_m, y_m, z_m)
          use fmin_fmax_functions
              real(8), intent (in) :: z_s
              real(8), intent (in) :: y_s
              real(8), intent (in) :: x_s
              real(8), intent (in) :: x_m
              real(8), intent (in) :: y_m
              real(8), intent (in) :: z_m
              real(8) :: tmp
              if (((cosh(x_m) * (y_m / x_m)) / z_m) <= 5d-16) then
                  tmp = y_m * (1.0d0 / (z_m * x_m))
              else
                  tmp = (y_m / z_m) / x_m
              end if
              code = z_s * (y_s * (x_s * tmp))
          end function
          
          x\_m = Math.abs(x);
          x\_s = Math.copySign(1.0, x);
          y\_m = Math.abs(y);
          y\_s = Math.copySign(1.0, y);
          z\_m = Math.abs(z);
          z\_s = Math.copySign(1.0, z);
          public static double code(double z_s, double y_s, double x_s, double x_m, double y_m, double z_m) {
          	double tmp;
          	if (((Math.cosh(x_m) * (y_m / x_m)) / z_m) <= 5e-16) {
          		tmp = y_m * (1.0 / (z_m * x_m));
          	} else {
          		tmp = (y_m / z_m) / x_m;
          	}
          	return z_s * (y_s * (x_s * tmp));
          }
          
          x\_m = math.fabs(x)
          x\_s = math.copysign(1.0, x)
          y\_m = math.fabs(y)
          y\_s = math.copysign(1.0, y)
          z\_m = math.fabs(z)
          z\_s = math.copysign(1.0, z)
          def code(z_s, y_s, x_s, x_m, y_m, z_m):
          	tmp = 0
          	if ((math.cosh(x_m) * (y_m / x_m)) / z_m) <= 5e-16:
          		tmp = y_m * (1.0 / (z_m * x_m))
          	else:
          		tmp = (y_m / z_m) / x_m
          	return z_s * (y_s * (x_s * tmp))
          
          x\_m = abs(x)
          x\_s = copysign(1.0, x)
          y\_m = abs(y)
          y\_s = copysign(1.0, y)
          z\_m = abs(z)
          z\_s = copysign(1.0, z)
          function code(z_s, y_s, x_s, x_m, y_m, z_m)
          	tmp = 0.0
          	if (Float64(Float64(cosh(x_m) * Float64(y_m / x_m)) / z_m) <= 5e-16)
          		tmp = Float64(y_m * Float64(1.0 / Float64(z_m * x_m)));
          	else
          		tmp = Float64(Float64(y_m / z_m) / x_m);
          	end
          	return Float64(z_s * Float64(y_s * Float64(x_s * tmp)))
          end
          
          x\_m = abs(x);
          x\_s = sign(x) * abs(1.0);
          y\_m = abs(y);
          y\_s = sign(y) * abs(1.0);
          z\_m = abs(z);
          z\_s = sign(z) * abs(1.0);
          function tmp_2 = code(z_s, y_s, x_s, x_m, y_m, z_m)
          	tmp = 0.0;
          	if (((cosh(x_m) * (y_m / x_m)) / z_m) <= 5e-16)
          		tmp = y_m * (1.0 / (z_m * x_m));
          	else
          		tmp = (y_m / z_m) / x_m;
          	end
          	tmp_2 = z_s * (y_s * (x_s * tmp));
          end
          
          x\_m = N[Abs[x], $MachinePrecision]
          x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
          y\_m = N[Abs[y], $MachinePrecision]
          y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
          z\_m = N[Abs[z], $MachinePrecision]
          z\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
          code[z$95$s_, y$95$s_, x$95$s_, x$95$m_, y$95$m_, z$95$m_] := N[(z$95$s * N[(y$95$s * N[(x$95$s * If[LessEqual[N[(N[(N[Cosh[x$95$m], $MachinePrecision] * N[(y$95$m / x$95$m), $MachinePrecision]), $MachinePrecision] / z$95$m), $MachinePrecision], 5e-16], N[(y$95$m * N[(1.0 / N[(z$95$m * x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y$95$m / z$95$m), $MachinePrecision] / x$95$m), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
          
          \begin{array}{l}
          x\_m = \left|x\right|
          \\
          x\_s = \mathsf{copysign}\left(1, x\right)
          \\
          y\_m = \left|y\right|
          \\
          y\_s = \mathsf{copysign}\left(1, y\right)
          \\
          z\_m = \left|z\right|
          \\
          z\_s = \mathsf{copysign}\left(1, z\right)
          
          \\
          z\_s \cdot \left(y\_s \cdot \left(x\_s \cdot \begin{array}{l}
          \mathbf{if}\;\frac{\cosh x\_m \cdot \frac{y\_m}{x\_m}}{z\_m} \leq 5 \cdot 10^{-16}:\\
          \;\;\;\;y\_m \cdot \frac{1}{z\_m \cdot x\_m}\\
          
          \mathbf{else}:\\
          \;\;\;\;\frac{\frac{y\_m}{z\_m}}{x\_m}\\
          
          
          \end{array}\right)\right)
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z) < 5.0000000000000004e-16

            1. Initial program 84.0%

              \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
            2. Step-by-step derivation
              1. lift-/.f64N/A

                \[\leadsto \color{blue}{\frac{\cosh x \cdot \frac{y}{x}}{z}} \]
              2. lift-*.f64N/A

                \[\leadsto \frac{\color{blue}{\cosh x \cdot \frac{y}{x}}}{z} \]
              3. lift-/.f64N/A

                \[\leadsto \frac{\cosh x \cdot \color{blue}{\frac{y}{x}}}{z} \]
              4. associate-*r/N/A

                \[\leadsto \frac{\color{blue}{\frac{\cosh x \cdot y}{x}}}{z} \]
              5. associate-/l/N/A

                \[\leadsto \color{blue}{\frac{\cosh x \cdot y}{x \cdot z}} \]
              6. *-commutativeN/A

                \[\leadsto \frac{\color{blue}{y \cdot \cosh x}}{x \cdot z} \]
              7. associate-/l*N/A

                \[\leadsto \color{blue}{y \cdot \frac{\cosh x}{x \cdot z}} \]
              8. lower-*.f64N/A

                \[\leadsto \color{blue}{y \cdot \frac{\cosh x}{x \cdot z}} \]
              9. lower-/.f64N/A

                \[\leadsto y \cdot \color{blue}{\frac{\cosh x}{x \cdot z}} \]
              10. *-commutativeN/A

                \[\leadsto y \cdot \frac{\cosh x}{\color{blue}{z \cdot x}} \]
              11. lower-*.f6482.7

                \[\leadsto y \cdot \frac{\cosh x}{\color{blue}{z \cdot x}} \]
            3. Applied rewrites82.7%

              \[\leadsto \color{blue}{y \cdot \frac{\cosh x}{z \cdot x}} \]
            4. Taylor expanded in x around 0

              \[\leadsto y \cdot \frac{\color{blue}{1}}{z \cdot x} \]
            5. Step-by-step derivation
              1. Applied rewrites48.4%

                \[\leadsto y \cdot \frac{\color{blue}{1}}{z \cdot x} \]

              if 5.0000000000000004e-16 < (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z)

              1. Initial program 84.0%

                \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
              2. Step-by-step derivation
                1. lift-/.f64N/A

                  \[\leadsto \color{blue}{\frac{\cosh x \cdot \frac{y}{x}}{z}} \]
                2. mult-flipN/A

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

                  \[\leadsto \color{blue}{\left(\cosh x \cdot \frac{y}{x}\right)} \cdot \frac{1}{z} \]
                4. lift-/.f64N/A

                  \[\leadsto \left(\cosh x \cdot \color{blue}{\frac{y}{x}}\right) \cdot \frac{1}{z} \]
                5. associate-*r/N/A

                  \[\leadsto \color{blue}{\frac{\cosh x \cdot y}{x}} \cdot \frac{1}{z} \]
                6. associate-*l/N/A

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

                  \[\leadsto \color{blue}{\frac{\left(\cosh x \cdot y\right) \cdot \frac{1}{z}}{x}} \]
                8. mult-flip-revN/A

                  \[\leadsto \frac{\color{blue}{\frac{\cosh x \cdot y}{z}}}{x} \]
                9. lower-/.f64N/A

                  \[\leadsto \frac{\color{blue}{\frac{\cosh x \cdot y}{z}}}{x} \]
                10. *-commutativeN/A

                  \[\leadsto \frac{\frac{\color{blue}{y \cdot \cosh x}}{z}}{x} \]
                11. lower-*.f6496.0

                  \[\leadsto \frac{\frac{\color{blue}{y \cdot \cosh x}}{z}}{x} \]
              3. Applied rewrites96.0%

                \[\leadsto \color{blue}{\frac{\frac{y \cdot \cosh x}{z}}{x}} \]
              4. Taylor expanded in x around 0

                \[\leadsto \frac{\frac{\color{blue}{y}}{z}}{x} \]
              5. Step-by-step derivation
                1. Applied rewrites52.8%

                  \[\leadsto \frac{\frac{\color{blue}{y}}{z}}{x} \]
              6. Recombined 2 regimes into one program.
              7. Add Preprocessing

              Alternative 10: 52.2% accurate, 0.7× speedup?

              \[\begin{array}{l} x\_m = \left|x\right| \\ x\_s = \mathsf{copysign}\left(1, x\right) \\ y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ z\_m = \left|z\right| \\ z\_s = \mathsf{copysign}\left(1, z\right) \\ z\_s \cdot \left(y\_s \cdot \left(x\_s \cdot \begin{array}{l} \mathbf{if}\;\cosh x\_m \cdot \frac{y\_m}{x\_m} \leq 10^{+145}:\\ \;\;\;\;\frac{\frac{y\_m}{x\_m}}{z\_m}\\ \mathbf{else}:\\ \;\;\;\;\frac{y\_m}{x\_m \cdot z\_m}\\ \end{array}\right)\right) \end{array} \]
              x\_m = (fabs.f64 x)
              x\_s = (copysign.f64 #s(literal 1 binary64) x)
              y\_m = (fabs.f64 y)
              y\_s = (copysign.f64 #s(literal 1 binary64) y)
              z\_m = (fabs.f64 z)
              z\_s = (copysign.f64 #s(literal 1 binary64) z)
              (FPCore (z_s y_s x_s x_m y_m z_m)
               :precision binary64
               (*
                z_s
                (*
                 y_s
                 (*
                  x_s
                  (if (<= (* (cosh x_m) (/ y_m x_m)) 1e+145)
                    (/ (/ y_m x_m) z_m)
                    (/ y_m (* x_m z_m)))))))
              x\_m = fabs(x);
              x\_s = copysign(1.0, x);
              y\_m = fabs(y);
              y\_s = copysign(1.0, y);
              z\_m = fabs(z);
              z\_s = copysign(1.0, z);
              double code(double z_s, double y_s, double x_s, double x_m, double y_m, double z_m) {
              	double tmp;
              	if ((cosh(x_m) * (y_m / x_m)) <= 1e+145) {
              		tmp = (y_m / x_m) / z_m;
              	} else {
              		tmp = y_m / (x_m * z_m);
              	}
              	return z_s * (y_s * (x_s * tmp));
              }
              
              x\_m =     private
              x\_s =     private
              y\_m =     private
              y\_s =     private
              z\_m =     private
              z\_s =     private
              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(z_s, y_s, x_s, x_m, y_m, z_m)
              use fmin_fmax_functions
                  real(8), intent (in) :: z_s
                  real(8), intent (in) :: y_s
                  real(8), intent (in) :: x_s
                  real(8), intent (in) :: x_m
                  real(8), intent (in) :: y_m
                  real(8), intent (in) :: z_m
                  real(8) :: tmp
                  if ((cosh(x_m) * (y_m / x_m)) <= 1d+145) then
                      tmp = (y_m / x_m) / z_m
                  else
                      tmp = y_m / (x_m * z_m)
                  end if
                  code = z_s * (y_s * (x_s * tmp))
              end function
              
              x\_m = Math.abs(x);
              x\_s = Math.copySign(1.0, x);
              y\_m = Math.abs(y);
              y\_s = Math.copySign(1.0, y);
              z\_m = Math.abs(z);
              z\_s = Math.copySign(1.0, z);
              public static double code(double z_s, double y_s, double x_s, double x_m, double y_m, double z_m) {
              	double tmp;
              	if ((Math.cosh(x_m) * (y_m / x_m)) <= 1e+145) {
              		tmp = (y_m / x_m) / z_m;
              	} else {
              		tmp = y_m / (x_m * z_m);
              	}
              	return z_s * (y_s * (x_s * tmp));
              }
              
              x\_m = math.fabs(x)
              x\_s = math.copysign(1.0, x)
              y\_m = math.fabs(y)
              y\_s = math.copysign(1.0, y)
              z\_m = math.fabs(z)
              z\_s = math.copysign(1.0, z)
              def code(z_s, y_s, x_s, x_m, y_m, z_m):
              	tmp = 0
              	if (math.cosh(x_m) * (y_m / x_m)) <= 1e+145:
              		tmp = (y_m / x_m) / z_m
              	else:
              		tmp = y_m / (x_m * z_m)
              	return z_s * (y_s * (x_s * tmp))
              
              x\_m = abs(x)
              x\_s = copysign(1.0, x)
              y\_m = abs(y)
              y\_s = copysign(1.0, y)
              z\_m = abs(z)
              z\_s = copysign(1.0, z)
              function code(z_s, y_s, x_s, x_m, y_m, z_m)
              	tmp = 0.0
              	if (Float64(cosh(x_m) * Float64(y_m / x_m)) <= 1e+145)
              		tmp = Float64(Float64(y_m / x_m) / z_m);
              	else
              		tmp = Float64(y_m / Float64(x_m * z_m));
              	end
              	return Float64(z_s * Float64(y_s * Float64(x_s * tmp)))
              end
              
              x\_m = abs(x);
              x\_s = sign(x) * abs(1.0);
              y\_m = abs(y);
              y\_s = sign(y) * abs(1.0);
              z\_m = abs(z);
              z\_s = sign(z) * abs(1.0);
              function tmp_2 = code(z_s, y_s, x_s, x_m, y_m, z_m)
              	tmp = 0.0;
              	if ((cosh(x_m) * (y_m / x_m)) <= 1e+145)
              		tmp = (y_m / x_m) / z_m;
              	else
              		tmp = y_m / (x_m * z_m);
              	end
              	tmp_2 = z_s * (y_s * (x_s * tmp));
              end
              
              x\_m = N[Abs[x], $MachinePrecision]
              x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
              y\_m = N[Abs[y], $MachinePrecision]
              y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
              z\_m = N[Abs[z], $MachinePrecision]
              z\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
              code[z$95$s_, y$95$s_, x$95$s_, x$95$m_, y$95$m_, z$95$m_] := N[(z$95$s * N[(y$95$s * N[(x$95$s * If[LessEqual[N[(N[Cosh[x$95$m], $MachinePrecision] * N[(y$95$m / x$95$m), $MachinePrecision]), $MachinePrecision], 1e+145], N[(N[(y$95$m / x$95$m), $MachinePrecision] / z$95$m), $MachinePrecision], N[(y$95$m / N[(x$95$m * z$95$m), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
              
              \begin{array}{l}
              x\_m = \left|x\right|
              \\
              x\_s = \mathsf{copysign}\left(1, x\right)
              \\
              y\_m = \left|y\right|
              \\
              y\_s = \mathsf{copysign}\left(1, y\right)
              \\
              z\_m = \left|z\right|
              \\
              z\_s = \mathsf{copysign}\left(1, z\right)
              
              \\
              z\_s \cdot \left(y\_s \cdot \left(x\_s \cdot \begin{array}{l}
              \mathbf{if}\;\cosh x\_m \cdot \frac{y\_m}{x\_m} \leq 10^{+145}:\\
              \;\;\;\;\frac{\frac{y\_m}{x\_m}}{z\_m}\\
              
              \mathbf{else}:\\
              \;\;\;\;\frac{y\_m}{x\_m \cdot z\_m}\\
              
              
              \end{array}\right)\right)
              \end{array}
              
              Derivation
              1. Split input into 2 regimes
              2. if (*.f64 (cosh.f64 x) (/.f64 y x)) < 9.9999999999999999e144

                1. Initial program 84.0%

                  \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
                2. Taylor expanded in x around 0

                  \[\leadsto \frac{\color{blue}{\frac{y}{x}}}{z} \]
                3. Step-by-step derivation
                  1. lower-/.f6448.4

                    \[\leadsto \frac{\frac{y}{\color{blue}{x}}}{z} \]
                4. Applied rewrites48.4%

                  \[\leadsto \frac{\color{blue}{\frac{y}{x}}}{z} \]

                if 9.9999999999999999e144 < (*.f64 (cosh.f64 x) (/.f64 y x))

                1. Initial program 84.0%

                  \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
                2. Taylor expanded in x around 0

                  \[\leadsto \color{blue}{\frac{y}{x \cdot z}} \]
                3. Step-by-step derivation
                  1. lower-/.f64N/A

                    \[\leadsto \frac{y}{\color{blue}{x \cdot z}} \]
                  2. lower-*.f6448.8

                    \[\leadsto \frac{y}{x \cdot \color{blue}{z}} \]
                4. Applied rewrites48.8%

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

              Alternative 11: 48.8% accurate, 2.9× speedup?

              \[\begin{array}{l} x\_m = \left|x\right| \\ x\_s = \mathsf{copysign}\left(1, x\right) \\ y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ z\_m = \left|z\right| \\ z\_s = \mathsf{copysign}\left(1, z\right) \\ z\_s \cdot \left(y\_s \cdot \left(x\_s \cdot \frac{y\_m}{x\_m \cdot z\_m}\right)\right) \end{array} \]
              x\_m = (fabs.f64 x)
              x\_s = (copysign.f64 #s(literal 1 binary64) x)
              y\_m = (fabs.f64 y)
              y\_s = (copysign.f64 #s(literal 1 binary64) y)
              z\_m = (fabs.f64 z)
              z\_s = (copysign.f64 #s(literal 1 binary64) z)
              (FPCore (z_s y_s x_s x_m y_m z_m)
               :precision binary64
               (* z_s (* y_s (* x_s (/ y_m (* x_m z_m))))))
              x\_m = fabs(x);
              x\_s = copysign(1.0, x);
              y\_m = fabs(y);
              y\_s = copysign(1.0, y);
              z\_m = fabs(z);
              z\_s = copysign(1.0, z);
              double code(double z_s, double y_s, double x_s, double x_m, double y_m, double z_m) {
              	return z_s * (y_s * (x_s * (y_m / (x_m * z_m))));
              }
              
              x\_m =     private
              x\_s =     private
              y\_m =     private
              y\_s =     private
              z\_m =     private
              z\_s =     private
              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(z_s, y_s, x_s, x_m, y_m, z_m)
              use fmin_fmax_functions
                  real(8), intent (in) :: z_s
                  real(8), intent (in) :: y_s
                  real(8), intent (in) :: x_s
                  real(8), intent (in) :: x_m
                  real(8), intent (in) :: y_m
                  real(8), intent (in) :: z_m
                  code = z_s * (y_s * (x_s * (y_m / (x_m * z_m))))
              end function
              
              x\_m = Math.abs(x);
              x\_s = Math.copySign(1.0, x);
              y\_m = Math.abs(y);
              y\_s = Math.copySign(1.0, y);
              z\_m = Math.abs(z);
              z\_s = Math.copySign(1.0, z);
              public static double code(double z_s, double y_s, double x_s, double x_m, double y_m, double z_m) {
              	return z_s * (y_s * (x_s * (y_m / (x_m * z_m))));
              }
              
              x\_m = math.fabs(x)
              x\_s = math.copysign(1.0, x)
              y\_m = math.fabs(y)
              y\_s = math.copysign(1.0, y)
              z\_m = math.fabs(z)
              z\_s = math.copysign(1.0, z)
              def code(z_s, y_s, x_s, x_m, y_m, z_m):
              	return z_s * (y_s * (x_s * (y_m / (x_m * z_m))))
              
              x\_m = abs(x)
              x\_s = copysign(1.0, x)
              y\_m = abs(y)
              y\_s = copysign(1.0, y)
              z\_m = abs(z)
              z\_s = copysign(1.0, z)
              function code(z_s, y_s, x_s, x_m, y_m, z_m)
              	return Float64(z_s * Float64(y_s * Float64(x_s * Float64(y_m / Float64(x_m * z_m)))))
              end
              
              x\_m = abs(x);
              x\_s = sign(x) * abs(1.0);
              y\_m = abs(y);
              y\_s = sign(y) * abs(1.0);
              z\_m = abs(z);
              z\_s = sign(z) * abs(1.0);
              function tmp = code(z_s, y_s, x_s, x_m, y_m, z_m)
              	tmp = z_s * (y_s * (x_s * (y_m / (x_m * z_m))));
              end
              
              x\_m = N[Abs[x], $MachinePrecision]
              x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
              y\_m = N[Abs[y], $MachinePrecision]
              y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
              z\_m = N[Abs[z], $MachinePrecision]
              z\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
              code[z$95$s_, y$95$s_, x$95$s_, x$95$m_, y$95$m_, z$95$m_] := N[(z$95$s * N[(y$95$s * N[(x$95$s * N[(y$95$m / N[(x$95$m * z$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
              
              \begin{array}{l}
              x\_m = \left|x\right|
              \\
              x\_s = \mathsf{copysign}\left(1, x\right)
              \\
              y\_m = \left|y\right|
              \\
              y\_s = \mathsf{copysign}\left(1, y\right)
              \\
              z\_m = \left|z\right|
              \\
              z\_s = \mathsf{copysign}\left(1, z\right)
              
              \\
              z\_s \cdot \left(y\_s \cdot \left(x\_s \cdot \frac{y\_m}{x\_m \cdot z\_m}\right)\right)
              \end{array}
              
              Derivation
              1. Initial program 84.0%

                \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
              2. Taylor expanded in x around 0

                \[\leadsto \color{blue}{\frac{y}{x \cdot z}} \]
              3. Step-by-step derivation
                1. lower-/.f64N/A

                  \[\leadsto \frac{y}{\color{blue}{x \cdot z}} \]
                2. lower-*.f6448.8

                  \[\leadsto \frac{y}{x \cdot \color{blue}{z}} \]
              4. Applied rewrites48.8%

                \[\leadsto \color{blue}{\frac{y}{x \cdot z}} \]
              5. Add Preprocessing

              Reproduce

              ?
              herbie shell --seed 2025142 
              (FPCore (x y z)
                :name "Linear.Quaternion:$ctan from linear-1.19.1.3"
                :precision binary64
                (/ (* (cosh x) (/ y x)) z))