Examples.Basics.BasicTests:f1 from sbv-4.4

Percentage Accurate: 100.0% → 100.0%
Time: 1.4s
Alternatives: 4
Speedup: 1.0×

Specification

?
\[\left(x + y\right) \cdot \left(x - y\right) \]
(FPCore (x y)
  :precision binary64
  (* (+ x y) (- x y)))
double code(double x, double y) {
	return (x + 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 + y) * (x - y)
end function
public static double code(double x, double y) {
	return (x + y) * (x - y);
}
def code(x, y):
	return (x + y) * (x - y)
function code(x, y)
	return Float64(Float64(x + y) * Float64(x - y))
end
function tmp = code(x, y)
	tmp = (x + y) * (x - y);
end
code[x_, y_] := N[(N[(x + y), $MachinePrecision] * N[(x - y), $MachinePrecision]), $MachinePrecision]
\left(x + y\right) \cdot \left(x - y\right)

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

\[\left(x + y\right) \cdot \left(x - y\right) \]
(FPCore (x y)
  :precision binary64
  (* (+ x y) (- x y)))
double code(double x, double y) {
	return (x + 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 + y) * (x - y)
end function
public static double code(double x, double y) {
	return (x + y) * (x - y);
}
def code(x, y):
	return (x + y) * (x - y)
function code(x, y)
	return Float64(Float64(x + y) * Float64(x - y))
end
function tmp = code(x, y)
	tmp = (x + y) * (x - y);
end
code[x_, y_] := N[(N[(x + y), $MachinePrecision] * N[(x - y), $MachinePrecision]), $MachinePrecision]
\left(x + y\right) \cdot \left(x - y\right)

Alternative 1: 99.1% accurate, 0.3× speedup?

\[\begin{array}{l} t_0 := \left|x\right| - \left|y\right|\\ \mathbf{if}\;\left(\left|x\right| + \left|y\right|\right) \cdot t\_0 \leq \frac{-40480450661}{202402253307310618352495346718917307049556649764142118356901358027430339567995346891960383701437124495187077864316811911389808737385793476867013399940738509921517424276566361364466907742093216341239767678472745068562007483424692698618103355649159556340810056512358769552333414615230502532186327508646006263307707741093494784}:\\ \;\;\;\;\left(-\left|y\right|\right) \cdot \left|y\right|\\ \mathbf{else}:\\ \;\;\;\;\left|x\right| \cdot t\_0\\ \end{array} \]
(FPCore (x y)
  :precision binary64
  (let* ((t_0 (- (fabs x) (fabs y))))
  (if (<=
       (* (+ (fabs x) (fabs y)) t_0)
       -40480450661/202402253307310618352495346718917307049556649764142118356901358027430339567995346891960383701437124495187077864316811911389808737385793476867013399940738509921517424276566361364466907742093216341239767678472745068562007483424692698618103355649159556340810056512358769552333414615230502532186327508646006263307707741093494784)
    (* (- (fabs y)) (fabs y))
    (* (fabs x) t_0))))
double code(double x, double y) {
	double t_0 = fabs(x) - fabs(y);
	double tmp;
	if (((fabs(x) + fabs(y)) * t_0) <= -2e-313) {
		tmp = -fabs(y) * fabs(y);
	} else {
		tmp = fabs(x) * 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 = abs(x) - abs(y)
    if (((abs(x) + abs(y)) * t_0) <= (-2d-313)) then
        tmp = -abs(y) * abs(y)
    else
        tmp = abs(x) * t_0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = Math.abs(x) - Math.abs(y);
	double tmp;
	if (((Math.abs(x) + Math.abs(y)) * t_0) <= -2e-313) {
		tmp = -Math.abs(y) * Math.abs(y);
	} else {
		tmp = Math.abs(x) * t_0;
	}
	return tmp;
}
def code(x, y):
	t_0 = math.fabs(x) - math.fabs(y)
	tmp = 0
	if ((math.fabs(x) + math.fabs(y)) * t_0) <= -2e-313:
		tmp = -math.fabs(y) * math.fabs(y)
	else:
		tmp = math.fabs(x) * t_0
	return tmp
function code(x, y)
	t_0 = Float64(abs(x) - abs(y))
	tmp = 0.0
	if (Float64(Float64(abs(x) + abs(y)) * t_0) <= -2e-313)
		tmp = Float64(Float64(-abs(y)) * abs(y));
	else
		tmp = Float64(abs(x) * t_0);
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = abs(x) - abs(y);
	tmp = 0.0;
	if (((abs(x) + abs(y)) * t_0) <= -2e-313)
		tmp = -abs(y) * abs(y);
	else
		tmp = abs(x) * t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(N[Abs[x], $MachinePrecision] - N[Abs[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(N[Abs[x], $MachinePrecision] + N[Abs[y], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], -40480450661/202402253307310618352495346718917307049556649764142118356901358027430339567995346891960383701437124495187077864316811911389808737385793476867013399940738509921517424276566361364466907742093216341239767678472745068562007483424692698618103355649159556340810056512358769552333414615230502532186327508646006263307707741093494784], N[((-N[Abs[y], $MachinePrecision]) * N[Abs[y], $MachinePrecision]), $MachinePrecision], N[(N[Abs[x], $MachinePrecision] * t$95$0), $MachinePrecision]]]
\begin{array}{l}
t_0 := \left|x\right| - \left|y\right|\\
\mathbf{if}\;\left(\left|x\right| + \left|y\right|\right) \cdot t\_0 \leq \frac{-40480450661}{202402253307310618352495346718917307049556649764142118356901358027430339567995346891960383701437124495187077864316811911389808737385793476867013399940738509921517424276566361364466907742093216341239767678472745068562007483424692698618103355649159556340810056512358769552333414615230502532186327508646006263307707741093494784}:\\
\;\;\;\;\left(-\left|y\right|\right) \cdot \left|y\right|\\

\mathbf{else}:\\
\;\;\;\;\left|x\right| \cdot t\_0\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (+.f64 x y) (-.f64 x y)) < -1.9999999999771681e-313

    1. Initial program 100.0%

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

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

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

        \[\leadsto y \cdot \color{blue}{\left(-1 \cdot y\right)} \]
      3. Step-by-step derivation
        1. lower-*.f6454.0%

          \[\leadsto y \cdot \left(-1 \cdot \color{blue}{y}\right) \]
      4. Applied rewrites54.0%

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

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

          \[\leadsto \color{blue}{\left(-1 \cdot y\right) \cdot y} \]
        3. lower-*.f6454.0%

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

          \[\leadsto \left(-1 \cdot \color{blue}{y}\right) \cdot y \]
        5. mul-1-negN/A

          \[\leadsto \left(\mathsf{neg}\left(y\right)\right) \cdot y \]
        6. remove-double-negN/A

          \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(y\right)\right)\right)\right)\right)\right) \cdot y \]
        7. lower-neg.f64N/A

          \[\leadsto \left(-\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(y\right)\right)\right)\right)\right) \cdot y \]
        8. mul-1-negN/A

          \[\leadsto \left(-\left(\mathsf{neg}\left(-1 \cdot y\right)\right)\right) \cdot y \]
        9. distribute-lft-neg-outN/A

          \[\leadsto \left(-\left(\mathsf{neg}\left(-1\right)\right) \cdot y\right) \cdot y \]
        10. metadata-evalN/A

          \[\leadsto \left(-1 \cdot y\right) \cdot y \]
        11. *-lft-identity54.0%

          \[\leadsto \left(-y\right) \cdot y \]
      6. Applied rewrites54.0%

        \[\leadsto \color{blue}{\left(-y\right) \cdot y} \]

      if -1.9999999999771681e-313 < (*.f64 (+.f64 x y) (-.f64 x y))

      1. Initial program 100.0%

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

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

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

          \[\leadsto y \cdot \color{blue}{\left(-1 \cdot y\right)} \]
        3. Step-by-step derivation
          1. lower-*.f6454.0%

            \[\leadsto y \cdot \left(-1 \cdot \color{blue}{y}\right) \]
        4. Applied rewrites54.0%

          \[\leadsto y \cdot \color{blue}{\left(-1 \cdot y\right)} \]
        5. Taylor expanded in x around inf

          \[\leadsto \color{blue}{x} \cdot \left(-1 \cdot y\right) \]
        6. Step-by-step derivation
          1. Applied rewrites15.4%

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

            \[\leadsto x \cdot \color{blue}{\left(x - y\right)} \]
          3. Step-by-step derivation
            1. lower--.f6456.7%

              \[\leadsto x \cdot \left(x - \color{blue}{y}\right) \]
          4. Applied rewrites56.7%

            \[\leadsto x \cdot \color{blue}{\left(x - y\right)} \]
        7. Recombined 2 regimes into one program.
        8. Add Preprocessing

        Alternative 2: 54.0% accurate, 1.5× speedup?

        \[\left(-y\right) \cdot 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(Float64(-y) * y)
        end
        
        function tmp = code(x, y)
        	tmp = -y * y;
        end
        
        code[x_, y_] := N[((-y) * y), $MachinePrecision]
        
        \left(-y\right) \cdot y
        
        Derivation
        1. Initial program 100.0%

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

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

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

            \[\leadsto y \cdot \color{blue}{\left(-1 \cdot y\right)} \]
          3. Step-by-step derivation
            1. lower-*.f6454.0%

              \[\leadsto y \cdot \left(-1 \cdot \color{blue}{y}\right) \]
          4. Applied rewrites54.0%

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

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

              \[\leadsto \color{blue}{\left(-1 \cdot y\right) \cdot y} \]
            3. lower-*.f6454.0%

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

              \[\leadsto \left(-1 \cdot \color{blue}{y}\right) \cdot y \]
            5. mul-1-negN/A

              \[\leadsto \left(\mathsf{neg}\left(y\right)\right) \cdot y \]
            6. remove-double-negN/A

              \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(y\right)\right)\right)\right)\right)\right) \cdot y \]
            7. lower-neg.f64N/A

              \[\leadsto \left(-\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(y\right)\right)\right)\right)\right) \cdot y \]
            8. mul-1-negN/A

              \[\leadsto \left(-\left(\mathsf{neg}\left(-1 \cdot y\right)\right)\right) \cdot y \]
            9. distribute-lft-neg-outN/A

              \[\leadsto \left(-\left(\mathsf{neg}\left(-1\right)\right) \cdot y\right) \cdot y \]
            10. metadata-evalN/A

              \[\leadsto \left(-1 \cdot y\right) \cdot y \]
            11. *-lft-identity54.0%

              \[\leadsto \left(-y\right) \cdot y \]
          6. Applied rewrites54.0%

            \[\leadsto \color{blue}{\left(-y\right) \cdot y} \]
          7. Add Preprocessing

          Alternative 3: 15.4% accurate, 1.5× speedup?

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

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

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

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

              \[\leadsto y \cdot \color{blue}{\left(-1 \cdot y\right)} \]
            3. Step-by-step derivation
              1. lower-*.f6454.0%

                \[\leadsto y \cdot \left(-1 \cdot \color{blue}{y}\right) \]
            4. Applied rewrites54.0%

              \[\leadsto y \cdot \color{blue}{\left(-1 \cdot y\right)} \]
            5. Taylor expanded in x around inf

              \[\leadsto \color{blue}{x} \cdot \left(-1 \cdot y\right) \]
            6. Step-by-step derivation
              1. Applied rewrites15.4%

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

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

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

                  \[\leadsto \left(-1 \cdot \color{blue}{y}\right) \cdot x \]
                4. mul-1-negN/A

                  \[\leadsto \left(\mathsf{neg}\left(y\right)\right) \cdot x \]
                5. lift-neg.f64N/A

                  \[\leadsto \left(-y\right) \cdot x \]
                6. lower-*.f6415.4%

                  \[\leadsto \color{blue}{\left(-y\right) \cdot x} \]
              3. Applied rewrites15.4%

                \[\leadsto \color{blue}{\left(-y\right) \cdot x} \]
              4. Add Preprocessing

              Reproduce

              ?
              herbie shell --seed 2025271 -o generate:evaluate
              (FPCore (x y)
                :name "Examples.Basics.BasicTests:f1 from sbv-4.4"
                :precision binary64
                (* (+ x y) (- x y)))