Linear.Projection:perspective from linear-1.19.1.3, B

Percentage Accurate: 76.9% → 99.7%
Time: 1.4min
Alternatives: 5
Speedup: 0.7×

Specification

?
\[\frac{\left(x \cdot 2\right) \cdot y}{x - y} \]
(FPCore (x y)
  :precision binary64
  (/ (* (* x 2) y) (- x y)))
double code(double x, double y) {
	return ((x * 2.0) * y) / (x - y);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x, y)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = ((x * 2.0d0) * y) / (x - y)
end function
public static double code(double x, double y) {
	return ((x * 2.0) * y) / (x - y);
}
def code(x, y):
	return ((x * 2.0) * y) / (x - y)
function code(x, y)
	return Float64(Float64(Float64(x * 2.0) * y) / Float64(x - y))
end
function tmp = code(x, y)
	tmp = ((x * 2.0) * y) / (x - y);
end
code[x_, y_] := N[(N[(N[(x * 2), $MachinePrecision] * y), $MachinePrecision] / N[(x - y), $MachinePrecision]), $MachinePrecision]
\frac{\left(x \cdot 2\right) \cdot y}{x - y}

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

\[\frac{\left(x \cdot 2\right) \cdot y}{x - y} \]
(FPCore (x y)
  :precision binary64
  (/ (* (* x 2) y) (- x y)))
double code(double x, double y) {
	return ((x * 2.0) * y) / (x - y);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x, y)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = ((x * 2.0d0) * y) / (x - y)
end function
public static double code(double x, double y) {
	return ((x * 2.0) * y) / (x - y);
}
def code(x, y):
	return ((x * 2.0) * y) / (x - y)
function code(x, y)
	return Float64(Float64(Float64(x * 2.0) * y) / Float64(x - y))
end
function tmp = code(x, y)
	tmp = ((x * 2.0) * y) / (x - y);
end
code[x_, y_] := N[(N[(N[(x * 2), $MachinePrecision] * y), $MachinePrecision] / N[(x - y), $MachinePrecision]), $MachinePrecision]
\frac{\left(x \cdot 2\right) \cdot y}{x - y}

Alternative 1: 99.7% accurate, 0.6× speedup?

\[\begin{array}{l} t_0 := \frac{y + y}{x - y} \cdot x\\ \mathbf{if}\;y \leq -500000000000000022442856339037958392774656:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 100000000000000004384584304507619735463404765184:\\ \;\;\;\;\frac{y + y}{\frac{x - y}{x}}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
(FPCore (x y)
  :precision binary64
  (let* ((t_0 (* (/ (+ y y) (- x y)) x)))
  (if (<= y -500000000000000022442856339037958392774656)
    t_0
    (if (<= y 100000000000000004384584304507619735463404765184)
      (/ (+ y y) (/ (- x y) x))
      t_0))))
double code(double x, double y) {
	double t_0 = ((y + y) / (x - y)) * x;
	double tmp;
	if (y <= -5e+41) {
		tmp = t_0;
	} else if (y <= 1e+47) {
		tmp = (y + y) / ((x - y) / x);
	} else {
		tmp = t_0;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x, y)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: t_0
    real(8) :: tmp
    t_0 = ((y + y) / (x - y)) * x
    if (y <= (-5d+41)) then
        tmp = t_0
    else if (y <= 1d+47) then
        tmp = (y + y) / ((x - y) / x)
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = ((y + y) / (x - y)) * x;
	double tmp;
	if (y <= -5e+41) {
		tmp = t_0;
	} else if (y <= 1e+47) {
		tmp = (y + y) / ((x - y) / x);
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y):
	t_0 = ((y + y) / (x - y)) * x
	tmp = 0
	if y <= -5e+41:
		tmp = t_0
	elif y <= 1e+47:
		tmp = (y + y) / ((x - y) / x)
	else:
		tmp = t_0
	return tmp
function code(x, y)
	t_0 = Float64(Float64(Float64(y + y) / Float64(x - y)) * x)
	tmp = 0.0
	if (y <= -5e+41)
		tmp = t_0;
	elseif (y <= 1e+47)
		tmp = Float64(Float64(y + y) / Float64(Float64(x - y) / x));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = ((y + y) / (x - y)) * x;
	tmp = 0.0;
	if (y <= -5e+41)
		tmp = t_0;
	elseif (y <= 1e+47)
		tmp = (y + y) / ((x - y) / x);
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(N[(N[(y + y), $MachinePrecision] / N[(x - y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[y, -500000000000000022442856339037958392774656], t$95$0, If[LessEqual[y, 100000000000000004384584304507619735463404765184], N[(N[(y + y), $MachinePrecision] / N[(N[(x - y), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := \frac{y + y}{x - y} \cdot x\\
\mathbf{if}\;y \leq -500000000000000022442856339037958392774656:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq 100000000000000004384584304507619735463404765184:\\
\;\;\;\;\frac{y + y}{\frac{x - y}{x}}\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -5.0000000000000002e41 or 1e47 < y

    1. Initial program 76.9%

      \[\frac{\left(x \cdot 2\right) \cdot y}{x - y} \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\left(x \cdot 2\right) \cdot y}{x - y}} \]
      2. mult-flipN/A

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

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

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

        \[\leadsto \color{blue}{\left(x \cdot \left(2 \cdot y\right)\right)} \cdot \frac{1}{x - y} \]
      6. associate-*l*N/A

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

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

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

        \[\leadsto \color{blue}{\frac{2 \cdot y}{x - y}} \cdot x \]
      10. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{2 \cdot y}{x - y}} \cdot x \]
      11. count-2-revN/A

        \[\leadsto \frac{\color{blue}{y + y}}{x - y} \cdot x \]
      12. lower-+.f6488.7%

        \[\leadsto \frac{\color{blue}{y + y}}{x - y} \cdot x \]
    3. Applied rewrites88.7%

      \[\leadsto \color{blue}{\frac{y + y}{x - y} \cdot x} \]

    if -5.0000000000000002e41 < y < 1e47

    1. Initial program 76.9%

      \[\frac{\left(x \cdot 2\right) \cdot y}{x - y} \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\left(x \cdot 2\right) \cdot y}{x - y}} \]
      2. mult-flipN/A

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

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

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

        \[\leadsto \color{blue}{\left(x \cdot \left(2 \cdot y\right)\right)} \cdot \frac{1}{x - y} \]
      6. associate-*l*N/A

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

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

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

        \[\leadsto \color{blue}{\frac{2 \cdot y}{x - y}} \cdot x \]
      10. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{2 \cdot y}{x - y}} \cdot x \]
      11. count-2-revN/A

        \[\leadsto \frac{\color{blue}{y + y}}{x - y} \cdot x \]
      12. lower-+.f6488.7%

        \[\leadsto \frac{\color{blue}{y + y}}{x - y} \cdot x \]
    3. Applied rewrites88.7%

      \[\leadsto \color{blue}{\frac{y + y}{x - y} \cdot x} \]
    4. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{\frac{y + y}{x - y} \cdot x} \]
      2. *-commutativeN/A

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

        \[\leadsto x \cdot \color{blue}{\frac{y + y}{x - y}} \]
      4. lift-+.f64N/A

        \[\leadsto x \cdot \frac{\color{blue}{y + y}}{x - y} \]
      5. div-addN/A

        \[\leadsto x \cdot \color{blue}{\left(\frac{y}{x - y} + \frac{y}{x - y}\right)} \]
      6. distribute-lft-inN/A

        \[\leadsto \color{blue}{x \cdot \frac{y}{x - y} + x \cdot \frac{y}{x - y}} \]
      7. distribute-rgt-outN/A

        \[\leadsto \color{blue}{\frac{y}{x - y} \cdot \left(x + x\right)} \]
      8. lift-+.f64N/A

        \[\leadsto \frac{y}{x - y} \cdot \color{blue}{\left(x + x\right)} \]
      9. associate-*l/N/A

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

        \[\leadsto \frac{\color{blue}{y \cdot \left(x + x\right)}}{x - y} \]
      11. div-flip-revN/A

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

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

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(1\right)}{\mathsf{neg}\left(\frac{x - y}{y \cdot \left(x + x\right)}\right)}} \]
      14. metadata-evalN/A

        \[\leadsto \frac{\color{blue}{-1}}{\mathsf{neg}\left(\frac{x - y}{y \cdot \left(x + x\right)}\right)} \]
      15. frac-2negN/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(-1\right)}{\mathsf{neg}\left(\left(\mathsf{neg}\left(\frac{x - y}{y \cdot \left(x + x\right)}\right)\right)\right)}} \]
      16. metadata-evalN/A

        \[\leadsto \frac{\color{blue}{1}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(\frac{x - y}{y \cdot \left(x + x\right)}\right)\right)\right)} \]
      17. remove-double-negN/A

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

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

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

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

        \[\leadsto \frac{1}{\frac{x - y}{\color{blue}{\left(x + x\right)} \cdot y}} \]
      22. count-2N/A

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

        \[\leadsto \frac{1}{\frac{x - y}{\color{blue}{\left(x \cdot 2\right)} \cdot y}} \]
      24. associate-*l*N/A

        \[\leadsto \frac{1}{\frac{x - y}{\color{blue}{x \cdot \left(2 \cdot y\right)}}} \]
      25. count-2-revN/A

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

        \[\leadsto \frac{1}{\frac{x - y}{x \cdot \color{blue}{\left(y + y\right)}}} \]
    5. Applied rewrites88.2%

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

Alternative 2: 98.9% accurate, 0.2× speedup?

\[\begin{array}{l} t_0 := \frac{\left(x \cdot 2\right) \cdot y}{x - y}\\ t_1 := \frac{y + y}{x - y} \cdot x\\ \mathbf{if}\;t\_0 \leq -9999999999999999931398190359470212947659194368:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq \frac{-4712544691453469}{47125446914534694131579097993419809976955095716785201420286055195012674566357244479460731079205201122720511132925006540350105785156086431086764996857554304860885586653967937772270969055149056096849908977391371752266308172471982589601097478449614615258949356272900190565812730839296826751014759649673012612226351104}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;t\_0 \leq 0:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq \frac{578960446186581}{57896044618658097711785492504343953926634992332820282019728792003956564819968}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \]
(FPCore (x y)
  :precision binary64
  (let* ((t_0 (/ (* (* x 2) y) (- x y)))
       (t_1 (* (/ (+ y y) (- x y)) x)))
  (if (<= t_0 -9999999999999999931398190359470212947659194368)
    t_1
    (if (<=
         t_0
         -4712544691453469/47125446914534694131579097993419809976955095716785201420286055195012674566357244479460731079205201122720511132925006540350105785156086431086764996857554304860885586653967937772270969055149056096849908977391371752266308172471982589601097478449614615258949356272900190565812730839296826751014759649673012612226351104)
      t_0
      (if (<= t_0 0)
        t_1
        (if (<=
             t_0
             578960446186581/57896044618658097711785492504343953926634992332820282019728792003956564819968)
          t_0
          t_1))))))
double code(double x, double y) {
	double t_0 = ((x * 2.0) * y) / (x - y);
	double t_1 = ((y + y) / (x - y)) * x;
	double tmp;
	if (t_0 <= -1e+46) {
		tmp = t_1;
	} else if (t_0 <= -1e-298) {
		tmp = t_0;
	} else if (t_0 <= 0.0) {
		tmp = t_1;
	} else if (t_0 <= 1e-62) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x, y)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = ((x * 2.0d0) * y) / (x - y)
    t_1 = ((y + y) / (x - y)) * x
    if (t_0 <= (-1d+46)) then
        tmp = t_1
    else if (t_0 <= (-1d-298)) then
        tmp = t_0
    else if (t_0 <= 0.0d0) then
        tmp = t_1
    else if (t_0 <= 1d-62) then
        tmp = t_0
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = ((x * 2.0) * y) / (x - y);
	double t_1 = ((y + y) / (x - y)) * x;
	double tmp;
	if (t_0 <= -1e+46) {
		tmp = t_1;
	} else if (t_0 <= -1e-298) {
		tmp = t_0;
	} else if (t_0 <= 0.0) {
		tmp = t_1;
	} else if (t_0 <= 1e-62) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y):
	t_0 = ((x * 2.0) * y) / (x - y)
	t_1 = ((y + y) / (x - y)) * x
	tmp = 0
	if t_0 <= -1e+46:
		tmp = t_1
	elif t_0 <= -1e-298:
		tmp = t_0
	elif t_0 <= 0.0:
		tmp = t_1
	elif t_0 <= 1e-62:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(x, y)
	t_0 = Float64(Float64(Float64(x * 2.0) * y) / Float64(x - y))
	t_1 = Float64(Float64(Float64(y + y) / Float64(x - y)) * x)
	tmp = 0.0
	if (t_0 <= -1e+46)
		tmp = t_1;
	elseif (t_0 <= -1e-298)
		tmp = t_0;
	elseif (t_0 <= 0.0)
		tmp = t_1;
	elseif (t_0 <= 1e-62)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = ((x * 2.0) * y) / (x - y);
	t_1 = ((y + y) / (x - y)) * x;
	tmp = 0.0;
	if (t_0 <= -1e+46)
		tmp = t_1;
	elseif (t_0 <= -1e-298)
		tmp = t_0;
	elseif (t_0 <= 0.0)
		tmp = t_1;
	elseif (t_0 <= 1e-62)
		tmp = t_0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(N[(N[(x * 2), $MachinePrecision] * y), $MachinePrecision] / N[(x - y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(y + y), $MachinePrecision] / N[(x - y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[t$95$0, -9999999999999999931398190359470212947659194368], t$95$1, If[LessEqual[t$95$0, -4712544691453469/47125446914534694131579097993419809976955095716785201420286055195012674566357244479460731079205201122720511132925006540350105785156086431086764996857554304860885586653967937772270969055149056096849908977391371752266308172471982589601097478449614615258949356272900190565812730839296826751014759649673012612226351104], t$95$0, If[LessEqual[t$95$0, 0], t$95$1, If[LessEqual[t$95$0, 578960446186581/57896044618658097711785492504343953926634992332820282019728792003956564819968], t$95$0, t$95$1]]]]]]
\begin{array}{l}
t_0 := \frac{\left(x \cdot 2\right) \cdot y}{x - y}\\
t_1 := \frac{y + y}{x - y} \cdot x\\
\mathbf{if}\;t\_0 \leq -9999999999999999931398190359470212947659194368:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_0 \leq \frac{-4712544691453469}{47125446914534694131579097993419809976955095716785201420286055195012674566357244479460731079205201122720511132925006540350105785156086431086764996857554304860885586653967937772270969055149056096849908977391371752266308172471982589601097478449614615258949356272900190565812730839296826751014759649673012612226351104}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_0 \leq \frac{578960446186581}{57896044618658097711785492504343953926634992332820282019728792003956564819968}:\\
\;\;\;\;t\_0\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (*.f64 (*.f64 x #s(literal 2 binary64)) y) (-.f64 x y)) < -9.9999999999999999e45 or -9.9999999999999991e-299 < (/.f64 (*.f64 (*.f64 x #s(literal 2 binary64)) y) (-.f64 x y)) < 0.0 or 1e-62 < (/.f64 (*.f64 (*.f64 x #s(literal 2 binary64)) y) (-.f64 x y))

    1. Initial program 76.9%

      \[\frac{\left(x \cdot 2\right) \cdot y}{x - y} \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\left(x \cdot 2\right) \cdot y}{x - y}} \]
      2. mult-flipN/A

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

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

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

        \[\leadsto \color{blue}{\left(x \cdot \left(2 \cdot y\right)\right)} \cdot \frac{1}{x - y} \]
      6. associate-*l*N/A

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

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

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

        \[\leadsto \color{blue}{\frac{2 \cdot y}{x - y}} \cdot x \]
      10. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{2 \cdot y}{x - y}} \cdot x \]
      11. count-2-revN/A

        \[\leadsto \frac{\color{blue}{y + y}}{x - y} \cdot x \]
      12. lower-+.f6488.7%

        \[\leadsto \frac{\color{blue}{y + y}}{x - y} \cdot x \]
    3. Applied rewrites88.7%

      \[\leadsto \color{blue}{\frac{y + y}{x - y} \cdot x} \]

    if -9.9999999999999999e45 < (/.f64 (*.f64 (*.f64 x #s(literal 2 binary64)) y) (-.f64 x y)) < -9.9999999999999991e-299 or 0.0 < (/.f64 (*.f64 (*.f64 x #s(literal 2 binary64)) y) (-.f64 x y)) < 1e-62

    1. Initial program 76.9%

      \[\frac{\left(x \cdot 2\right) \cdot y}{x - y} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 3: 93.3% accurate, 0.7× speedup?

\[\begin{array}{l} \mathbf{if}\;x \leq -1949999999999999951599835360271914619912912547761700642356953119684478161943531790608413539156809286922127874862350336:\\ \;\;\;\;y + y\\ \mathbf{elif}\;x \leq 16500000000000000644860641467979058610064397036389999038363036908673902220531696917689006626439168:\\ \;\;\;\;\frac{y + y}{x - y} \cdot x\\ \mathbf{else}:\\ \;\;\;\;y + y\\ \end{array} \]
(FPCore (x y)
  :precision binary64
  (if (<=
     x
     -1949999999999999951599835360271914619912912547761700642356953119684478161943531790608413539156809286922127874862350336)
  (+ y y)
  (if (<=
       x
       16500000000000000644860641467979058610064397036389999038363036908673902220531696917689006626439168)
    (* (/ (+ y y) (- x y)) x)
    (+ y y))))
double code(double x, double y) {
	double tmp;
	if (x <= -1.95e+117) {
		tmp = y + y;
	} else if (x <= 1.65e+97) {
		tmp = ((y + y) / (x - y)) * x;
	} else {
		tmp = y + y;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x, y)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (x <= (-1.95d+117)) then
        tmp = y + y
    else if (x <= 1.65d+97) then
        tmp = ((y + y) / (x - y)) * x
    else
        tmp = y + y
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (x <= -1.95e+117) {
		tmp = y + y;
	} else if (x <= 1.65e+97) {
		tmp = ((y + y) / (x - y)) * x;
	} else {
		tmp = y + y;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if x <= -1.95e+117:
		tmp = y + y
	elif x <= 1.65e+97:
		tmp = ((y + y) / (x - y)) * x
	else:
		tmp = y + y
	return tmp
function code(x, y)
	tmp = 0.0
	if (x <= -1.95e+117)
		tmp = Float64(y + y);
	elseif (x <= 1.65e+97)
		tmp = Float64(Float64(Float64(y + y) / Float64(x - y)) * x);
	else
		tmp = Float64(y + y);
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (x <= -1.95e+117)
		tmp = y + y;
	elseif (x <= 1.65e+97)
		tmp = ((y + y) / (x - y)) * x;
	else
		tmp = y + y;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[x, -1949999999999999951599835360271914619912912547761700642356953119684478161943531790608413539156809286922127874862350336], N[(y + y), $MachinePrecision], If[LessEqual[x, 16500000000000000644860641467979058610064397036389999038363036908673902220531696917689006626439168], N[(N[(N[(y + y), $MachinePrecision] / N[(x - y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], N[(y + y), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;x \leq -1949999999999999951599835360271914619912912547761700642356953119684478161943531790608413539156809286922127874862350336:\\
\;\;\;\;y + y\\

\mathbf{elif}\;x \leq 16500000000000000644860641467979058610064397036389999038363036908673902220531696917689006626439168:\\
\;\;\;\;\frac{y + y}{x - y} \cdot x\\

\mathbf{else}:\\
\;\;\;\;y + y\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.95e117 or 1.6500000000000001e97 < x

    1. Initial program 76.9%

      \[\frac{\left(x \cdot 2\right) \cdot y}{x - y} \]
    2. Taylor expanded in x around inf

      \[\leadsto \color{blue}{2 \cdot y} \]
    3. Step-by-step derivation
      1. lower-*.f6450.8%

        \[\leadsto 2 \cdot \color{blue}{y} \]
    4. Applied rewrites50.8%

      \[\leadsto \color{blue}{2 \cdot y} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto 2 \cdot \color{blue}{y} \]
      2. count-2-revN/A

        \[\leadsto y + \color{blue}{y} \]
      3. lift-+.f6450.8%

        \[\leadsto y + \color{blue}{y} \]
    6. Applied rewrites50.8%

      \[\leadsto y + \color{blue}{y} \]

    if -1.95e117 < x < 1.6500000000000001e97

    1. Initial program 76.9%

      \[\frac{\left(x \cdot 2\right) \cdot y}{x - y} \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\left(x \cdot 2\right) \cdot y}{x - y}} \]
      2. mult-flipN/A

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

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

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

        \[\leadsto \color{blue}{\left(x \cdot \left(2 \cdot y\right)\right)} \cdot \frac{1}{x - y} \]
      6. associate-*l*N/A

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

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

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

        \[\leadsto \color{blue}{\frac{2 \cdot y}{x - y}} \cdot x \]
      10. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{2 \cdot y}{x - y}} \cdot x \]
      11. count-2-revN/A

        \[\leadsto \frac{\color{blue}{y + y}}{x - y} \cdot x \]
      12. lower-+.f6488.7%

        \[\leadsto \frac{\color{blue}{y + y}}{x - y} \cdot x \]
    3. Applied rewrites88.7%

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

Alternative 4: 74.2% accurate, 1.4× speedup?

\[\begin{array}{l} \mathbf{if}\;x \leq \frac{-3821530487881633}{83076749736557242056487941267521536}:\\ \;\;\;\;y + y\\ \mathbf{elif}\;x \leq 5799999999999999402444686308071786851092922368:\\ \;\;\;\;-2 \cdot x\\ \mathbf{else}:\\ \;\;\;\;y + y\\ \end{array} \]
(FPCore (x y)
  :precision binary64
  (if (<= x -3821530487881633/83076749736557242056487941267521536)
  (+ y y)
  (if (<= x 5799999999999999402444686308071786851092922368)
    (* -2 x)
    (+ y y))))
double code(double x, double y) {
	double tmp;
	if (x <= -4.6e-20) {
		tmp = y + y;
	} else if (x <= 5.8e+45) {
		tmp = -2.0 * x;
	} else {
		tmp = y + y;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x, y)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (x <= (-4.6d-20)) then
        tmp = y + y
    else if (x <= 5.8d+45) then
        tmp = (-2.0d0) * x
    else
        tmp = y + y
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (x <= -4.6e-20) {
		tmp = y + y;
	} else if (x <= 5.8e+45) {
		tmp = -2.0 * x;
	} else {
		tmp = y + y;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if x <= -4.6e-20:
		tmp = y + y
	elif x <= 5.8e+45:
		tmp = -2.0 * x
	else:
		tmp = y + y
	return tmp
function code(x, y)
	tmp = 0.0
	if (x <= -4.6e-20)
		tmp = Float64(y + y);
	elseif (x <= 5.8e+45)
		tmp = Float64(-2.0 * x);
	else
		tmp = Float64(y + y);
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (x <= -4.6e-20)
		tmp = y + y;
	elseif (x <= 5.8e+45)
		tmp = -2.0 * x;
	else
		tmp = y + y;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[x, -3821530487881633/83076749736557242056487941267521536], N[(y + y), $MachinePrecision], If[LessEqual[x, 5799999999999999402444686308071786851092922368], N[(-2 * x), $MachinePrecision], N[(y + y), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;x \leq \frac{-3821530487881633}{83076749736557242056487941267521536}:\\
\;\;\;\;y + y\\

\mathbf{elif}\;x \leq 5799999999999999402444686308071786851092922368:\\
\;\;\;\;-2 \cdot x\\

\mathbf{else}:\\
\;\;\;\;y + y\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -4.5999999999999998e-20 or 5.7999999999999994e45 < x

    1. Initial program 76.9%

      \[\frac{\left(x \cdot 2\right) \cdot y}{x - y} \]
    2. Taylor expanded in x around inf

      \[\leadsto \color{blue}{2 \cdot y} \]
    3. Step-by-step derivation
      1. lower-*.f6450.8%

        \[\leadsto 2 \cdot \color{blue}{y} \]
    4. Applied rewrites50.8%

      \[\leadsto \color{blue}{2 \cdot y} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto 2 \cdot \color{blue}{y} \]
      2. count-2-revN/A

        \[\leadsto y + \color{blue}{y} \]
      3. lift-+.f6450.8%

        \[\leadsto y + \color{blue}{y} \]
    6. Applied rewrites50.8%

      \[\leadsto y + \color{blue}{y} \]

    if -4.5999999999999998e-20 < x < 5.7999999999999994e45

    1. Initial program 76.9%

      \[\frac{\left(x \cdot 2\right) \cdot y}{x - y} \]
    2. Taylor expanded in x around 0

      \[\leadsto \color{blue}{-2 \cdot x} \]
    3. Step-by-step derivation
      1. lower-*.f6450.7%

        \[\leadsto -2 \cdot \color{blue}{x} \]
    4. Applied rewrites50.7%

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

Alternative 5: 50.8% accurate, 6.3× speedup?

\[y + y \]
(FPCore (x y)
  :precision binary64
  (+ y y))
double code(double x, double y) {
	return y + y;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x, y)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = y + y
end function
public static double code(double x, double y) {
	return y + y;
}
def code(x, y):
	return y + y
function code(x, y)
	return Float64(y + y)
end
function tmp = code(x, y)
	tmp = y + y;
end
code[x_, y_] := N[(y + y), $MachinePrecision]
y + y
Derivation
  1. Initial program 76.9%

    \[\frac{\left(x \cdot 2\right) \cdot y}{x - y} \]
  2. Taylor expanded in x around inf

    \[\leadsto \color{blue}{2 \cdot y} \]
  3. Step-by-step derivation
    1. lower-*.f6450.8%

      \[\leadsto 2 \cdot \color{blue}{y} \]
  4. Applied rewrites50.8%

    \[\leadsto \color{blue}{2 \cdot y} \]
  5. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto 2 \cdot \color{blue}{y} \]
    2. count-2-revN/A

      \[\leadsto y + \color{blue}{y} \]
    3. lift-+.f6450.8%

      \[\leadsto y + \color{blue}{y} \]
  6. Applied rewrites50.8%

    \[\leadsto y + \color{blue}{y} \]
  7. Add Preprocessing

Reproduce

?
herbie shell --seed 2025271 -o generate:evaluate
(FPCore (x y)
  :name "Linear.Projection:perspective from linear-1.19.1.3, B"
  :precision binary64
  (/ (* (* x 2) y) (- x y)))