Graphics.Rendering.Chart.Backend.Diagrams:calcFontMetrics from Chart-diagrams-1.5.1, A

Percentage Accurate: 87.9% → 99.7%
Time: 2.8s
Alternatives: 5
Speedup: N/A×

Specification

?
\[\begin{array}{l} \\ \frac{x + y}{1 - \frac{y}{z}} \end{array} \]
(FPCore (x y z) :precision binary64 (/ (+ x y) (- 1.0 (/ y z))))
double code(double x, double y, double z) {
	return (x + y) / (1.0 - (y / 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 = (x + y) / (1.0d0 - (y / z))
end function
public static double code(double x, double y, double z) {
	return (x + y) / (1.0 - (y / z));
}
def code(x, y, z):
	return (x + y) / (1.0 - (y / z))
function code(x, y, z)
	return Float64(Float64(x + y) / Float64(1.0 - Float64(y / z)))
end
function tmp = code(x, y, z)
	tmp = (x + y) / (1.0 - (y / z));
end
code[x_, y_, z_] := N[(N[(x + y), $MachinePrecision] / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{x + y}{1 - \frac{y}{z}}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 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: 87.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{x + y}{1 - \frac{y}{z}} \end{array} \]
(FPCore (x y z) :precision binary64 (/ (+ x y) (- 1.0 (/ y z))))
double code(double x, double y, double z) {
	return (x + y) / (1.0 - (y / 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 = (x + y) / (1.0d0 - (y / z))
end function
public static double code(double x, double y, double z) {
	return (x + y) / (1.0 - (y / z));
}
def code(x, y, z):
	return (x + y) / (1.0 - (y / z))
function code(x, y, z)
	return Float64(Float64(x + y) / Float64(1.0 - Float64(y / z)))
end
function tmp = code(x, y, z)
	tmp = (x + y) / (1.0 - (y / z));
end
code[x_, y_, z_] := N[(N[(x + y), $MachinePrecision] / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{x + y}{1 - \frac{y}{z}}
\end{array}

Alternative 1: 99.7% accurate, N/A× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -5 \cdot 10^{+74} \lor \neg \left(y \leq 10^{-48}\right):\\ \;\;\;\;\frac{y + x}{\mathsf{fma}\left(-2, z, \left(-1 \cdot -2\right) \cdot y\right)} \cdot \left(-2 \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;-1 \cdot \frac{-1 \cdot \left(x + y\right)}{\frac{2 \cdot z - 2 \cdot y}{2 \cdot z}}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= y -5e+74) (not (<= y 1e-48)))
   (* (/ (+ y x) (fma -2.0 z (* (* -1.0 -2.0) y))) (* -2.0 z))
   (* -1.0 (/ (* -1.0 (+ x y)) (/ (- (* 2.0 z) (* 2.0 y)) (* 2.0 z))))))
double code(double x, double y, double z) {
	double tmp;
	if ((y <= -5e+74) || !(y <= 1e-48)) {
		tmp = ((y + x) / fma(-2.0, z, ((-1.0 * -2.0) * y))) * (-2.0 * z);
	} else {
		tmp = -1.0 * ((-1.0 * (x + y)) / (((2.0 * z) - (2.0 * y)) / (2.0 * z)));
	}
	return tmp;
}
function code(x, y, z)
	tmp = 0.0
	if ((y <= -5e+74) || !(y <= 1e-48))
		tmp = Float64(Float64(Float64(y + x) / fma(-2.0, z, Float64(Float64(-1.0 * -2.0) * y))) * Float64(-2.0 * z));
	else
		tmp = Float64(-1.0 * Float64(Float64(-1.0 * Float64(x + y)) / Float64(Float64(Float64(2.0 * z) - Float64(2.0 * y)) / Float64(2.0 * z))));
	end
	return tmp
end
code[x_, y_, z_] := If[Or[LessEqual[y, -5e+74], N[Not[LessEqual[y, 1e-48]], $MachinePrecision]], N[(N[(N[(y + x), $MachinePrecision] / N[(-2.0 * z + N[(N[(-1.0 * -2.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-2.0 * z), $MachinePrecision]), $MachinePrecision], N[(-1.0 * N[(N[(-1.0 * N[(x + y), $MachinePrecision]), $MachinePrecision] / N[(N[(N[(2.0 * z), $MachinePrecision] - N[(2.0 * y), $MachinePrecision]), $MachinePrecision] / N[(2.0 * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -5 \cdot 10^{+74} \lor \neg \left(y \leq 10^{-48}\right):\\
\;\;\;\;\frac{y + x}{\mathsf{fma}\left(-2, z, \left(-1 \cdot -2\right) \cdot y\right)} \cdot \left(-2 \cdot z\right)\\

\mathbf{else}:\\
\;\;\;\;-1 \cdot \frac{-1 \cdot \left(x + y\right)}{\frac{2 \cdot z - 2 \cdot y}{2 \cdot z}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -4.99999999999999963e74 or 9.9999999999999997e-49 < y

    1. Initial program 72.9%

      \[\frac{x + y}{1 - \frac{y}{z}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift--.f64N/A

        \[\leadsto \frac{x + y}{\color{blue}{1 - \frac{y}{z}}} \]
      2. metadata-evalN/A

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

        \[\leadsto \frac{x + y}{\frac{2}{2} - \color{blue}{\frac{y}{z}}} \]
      4. frac-2negN/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{x + y}{\frac{2 \cdot \left(-1 \cdot z\right) - 2 \cdot \left(-y\right)}{\color{blue}{2 \cdot \left(-1 \cdot z\right)}}} \]
      14. lower-*.f6472.9

        \[\leadsto \frac{x + y}{\frac{2 \cdot \left(-1 \cdot z\right) - 2 \cdot \left(-y\right)}{2 \cdot \color{blue}{\left(-1 \cdot z\right)}}} \]
    4. Applied rewrites72.9%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{x + y}{\frac{2 \cdot \left(-1 \cdot z\right) - \color{blue}{2 \cdot \left(\mathsf{neg}\left(y\right)\right)}}{2 \cdot \left(-1 \cdot z\right)}} \]
      9. associate-/r/N/A

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

        \[\leadsto \color{blue}{\frac{x + y}{2 \cdot \left(-1 \cdot z\right) - 2 \cdot \left(\mathsf{neg}\left(y\right)\right)} \cdot \left(2 \cdot \left(-1 \cdot z\right)\right)} \]
    6. Applied rewrites99.9%

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

    if -4.99999999999999963e74 < y < 9.9999999999999997e-49

    1. Initial program 99.9%

      \[\frac{x + y}{1 - \frac{y}{z}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift--.f64N/A

        \[\leadsto \frac{x + y}{\color{blue}{1 - \frac{y}{z}}} \]
      2. metadata-evalN/A

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

        \[\leadsto \frac{x + y}{\frac{2}{2} - \color{blue}{\frac{y}{z}}} \]
      4. frac-2negN/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{x + y}{\frac{2 \cdot \left(-1 \cdot z\right) - 2 \cdot \left(-y\right)}{\color{blue}{2 \cdot \left(-1 \cdot z\right)}}} \]
      14. lower-*.f64100.0

        \[\leadsto \frac{x + y}{\frac{2 \cdot \left(-1 \cdot z\right) - 2 \cdot \left(-y\right)}{2 \cdot \color{blue}{\left(-1 \cdot z\right)}}} \]
    4. Applied rewrites100.0%

      \[\leadsto \frac{x + y}{\color{blue}{\frac{2 \cdot \left(-1 \cdot z\right) - 2 \cdot \left(-y\right)}{2 \cdot \left(-1 \cdot z\right)}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.9%

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

Alternative 2: 99.3% accurate, N/A× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1 \cdot 10^{-19} \lor \neg \left(y \leq 10^{-48}\right):\\ \;\;\;\;\frac{y + x}{\mathsf{fma}\left(-2, z, \left(-1 \cdot -2\right) \cdot y\right)} \cdot \left(-2 \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x + y}{1 - \frac{y}{z}}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= y -1e-19) (not (<= y 1e-48)))
   (* (/ (+ y x) (fma -2.0 z (* (* -1.0 -2.0) y))) (* -2.0 z))
   (/ (+ x y) (- 1.0 (/ y z)))))
double code(double x, double y, double z) {
	double tmp;
	if ((y <= -1e-19) || !(y <= 1e-48)) {
		tmp = ((y + x) / fma(-2.0, z, ((-1.0 * -2.0) * y))) * (-2.0 * z);
	} else {
		tmp = (x + y) / (1.0 - (y / z));
	}
	return tmp;
}
function code(x, y, z)
	tmp = 0.0
	if ((y <= -1e-19) || !(y <= 1e-48))
		tmp = Float64(Float64(Float64(y + x) / fma(-2.0, z, Float64(Float64(-1.0 * -2.0) * y))) * Float64(-2.0 * z));
	else
		tmp = Float64(Float64(x + y) / Float64(1.0 - Float64(y / z)));
	end
	return tmp
end
code[x_, y_, z_] := If[Or[LessEqual[y, -1e-19], N[Not[LessEqual[y, 1e-48]], $MachinePrecision]], N[(N[(N[(y + x), $MachinePrecision] / N[(-2.0 * z + N[(N[(-1.0 * -2.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-2.0 * z), $MachinePrecision]), $MachinePrecision], N[(N[(x + y), $MachinePrecision] / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \cdot 10^{-19} \lor \neg \left(y \leq 10^{-48}\right):\\
\;\;\;\;\frac{y + x}{\mathsf{fma}\left(-2, z, \left(-1 \cdot -2\right) \cdot y\right)} \cdot \left(-2 \cdot z\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{x + y}{1 - \frac{y}{z}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -9.9999999999999998e-20 or 9.9999999999999997e-49 < y

    1. Initial program 76.0%

      \[\frac{x + y}{1 - \frac{y}{z}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift--.f64N/A

        \[\leadsto \frac{x + y}{\color{blue}{1 - \frac{y}{z}}} \]
      2. metadata-evalN/A

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

        \[\leadsto \frac{x + y}{\frac{2}{2} - \color{blue}{\frac{y}{z}}} \]
      4. frac-2negN/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{x + y}{\frac{2 \cdot \left(-1 \cdot z\right) - 2 \cdot \left(-y\right)}{\color{blue}{2 \cdot \left(-1 \cdot z\right)}}} \]
      14. lower-*.f6476.0

        \[\leadsto \frac{x + y}{\frac{2 \cdot \left(-1 \cdot z\right) - 2 \cdot \left(-y\right)}{2 \cdot \color{blue}{\left(-1 \cdot z\right)}}} \]
    4. Applied rewrites76.0%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{x + y}{\frac{2 \cdot \left(-1 \cdot z\right) - \color{blue}{2 \cdot \left(\mathsf{neg}\left(y\right)\right)}}{2 \cdot \left(-1 \cdot z\right)}} \]
      9. associate-/r/N/A

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

        \[\leadsto \color{blue}{\frac{x + y}{2 \cdot \left(-1 \cdot z\right) - 2 \cdot \left(\mathsf{neg}\left(y\right)\right)} \cdot \left(2 \cdot \left(-1 \cdot z\right)\right)} \]
    6. Applied rewrites99.9%

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

    if -9.9999999999999998e-20 < y < 9.9999999999999997e-49

    1. Initial program 100.0%

      \[\frac{x + y}{1 - \frac{y}{z}} \]
    2. Add Preprocessing
  3. Recombined 2 regimes into one program.
  4. Final simplification99.9%

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

Alternative 3: 92.3% accurate, N/A× speedup?

\[\begin{array}{l} \\ \frac{y + x}{\mathsf{fma}\left(-2, z, \left(-1 \cdot -2\right) \cdot y\right)} \cdot \left(-2 \cdot z\right) \end{array} \]
(FPCore (x y z)
 :precision binary64
 (* (/ (+ y x) (fma -2.0 z (* (* -1.0 -2.0) y))) (* -2.0 z)))
double code(double x, double y, double z) {
	return ((y + x) / fma(-2.0, z, ((-1.0 * -2.0) * y))) * (-2.0 * z);
}
function code(x, y, z)
	return Float64(Float64(Float64(y + x) / fma(-2.0, z, Float64(Float64(-1.0 * -2.0) * y))) * Float64(-2.0 * z))
end
code[x_, y_, z_] := N[(N[(N[(y + x), $MachinePrecision] / N[(-2.0 * z + N[(N[(-1.0 * -2.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-2.0 * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{y + x}{\mathsf{fma}\left(-2, z, \left(-1 \cdot -2\right) \cdot y\right)} \cdot \left(-2 \cdot z\right)
\end{array}
Derivation
  1. Initial program 85.6%

    \[\frac{x + y}{1 - \frac{y}{z}} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift--.f64N/A

      \[\leadsto \frac{x + y}{\color{blue}{1 - \frac{y}{z}}} \]
    2. metadata-evalN/A

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

      \[\leadsto \frac{x + y}{\frac{2}{2} - \color{blue}{\frac{y}{z}}} \]
    4. frac-2negN/A

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{x + y}{\frac{2 \cdot \left(-1 \cdot z\right) - 2 \cdot \left(-y\right)}{\color{blue}{2 \cdot \left(-1 \cdot z\right)}}} \]
    14. lower-*.f6485.6

      \[\leadsto \frac{x + y}{\frac{2 \cdot \left(-1 \cdot z\right) - 2 \cdot \left(-y\right)}{2 \cdot \color{blue}{\left(-1 \cdot z\right)}}} \]
  4. Applied rewrites85.6%

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

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

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

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

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

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

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

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

      \[\leadsto \frac{x + y}{\frac{2 \cdot \left(-1 \cdot z\right) - \color{blue}{2 \cdot \left(\mathsf{neg}\left(y\right)\right)}}{2 \cdot \left(-1 \cdot z\right)}} \]
    9. associate-/r/N/A

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

      \[\leadsto \color{blue}{\frac{x + y}{2 \cdot \left(-1 \cdot z\right) - 2 \cdot \left(\mathsf{neg}\left(y\right)\right)} \cdot \left(2 \cdot \left(-1 \cdot z\right)\right)} \]
  6. Applied rewrites91.1%

    \[\leadsto \color{blue}{\frac{y + x}{\mathsf{fma}\left(-2, z, -2 \cdot \left(-1 \cdot y\right)\right)} \cdot \left(-2 \cdot z\right)} \]
  7. Final simplification91.1%

    \[\leadsto \frac{y + x}{\mathsf{fma}\left(-2, z, \left(-1 \cdot -2\right) \cdot y\right)} \cdot \left(-2 \cdot z\right) \]
  8. Add Preprocessing

Alternative 4: 46.5% accurate, N/A× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq 64000000000:\\ \;\;\;\;\mathsf{fma}\left(-1 \cdot \frac{\mathsf{fma}\left(z, \mathsf{fma}\left(x, \frac{z}{y}, \frac{z \cdot z}{y}\right), z \cdot x\right) - \left(z \cdot z\right) \cdot -1}{-1 \cdot y}, -1, -1 \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;-1 \cdot z\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= z 64000000000.0)
   (fma
    (*
     -1.0
     (/
      (- (fma z (fma x (/ z y) (/ (* z z) y)) (* z x)) (* (* z z) -1.0))
      (* -1.0 y)))
    -1.0
    (* -1.0 z))
   (* -1.0 z)))
double code(double x, double y, double z) {
	double tmp;
	if (z <= 64000000000.0) {
		tmp = fma((-1.0 * ((fma(z, fma(x, (z / y), ((z * z) / y)), (z * x)) - ((z * z) * -1.0)) / (-1.0 * y))), -1.0, (-1.0 * z));
	} else {
		tmp = -1.0 * z;
	}
	return tmp;
}
function code(x, y, z)
	tmp = 0.0
	if (z <= 64000000000.0)
		tmp = fma(Float64(-1.0 * Float64(Float64(fma(z, fma(x, Float64(z / y), Float64(Float64(z * z) / y)), Float64(z * x)) - Float64(Float64(z * z) * -1.0)) / Float64(-1.0 * y))), -1.0, Float64(-1.0 * z));
	else
		tmp = Float64(-1.0 * z);
	end
	return tmp
end
code[x_, y_, z_] := If[LessEqual[z, 64000000000.0], N[(N[(-1.0 * N[(N[(N[(z * N[(x * N[(z / y), $MachinePrecision] + N[(N[(z * z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] + N[(z * x), $MachinePrecision]), $MachinePrecision] - N[(N[(z * z), $MachinePrecision] * -1.0), $MachinePrecision]), $MachinePrecision] / N[(-1.0 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -1.0 + N[(-1.0 * z), $MachinePrecision]), $MachinePrecision], N[(-1.0 * z), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq 64000000000:\\
\;\;\;\;\mathsf{fma}\left(-1 \cdot \frac{\mathsf{fma}\left(z, \mathsf{fma}\left(x, \frac{z}{y}, \frac{z \cdot z}{y}\right), z \cdot x\right) - \left(z \cdot z\right) \cdot -1}{-1 \cdot y}, -1, -1 \cdot z\right)\\

\mathbf{else}:\\
\;\;\;\;-1 \cdot z\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < 6.4e10

    1. Initial program 81.9%

      \[\frac{x + y}{1 - \frac{y}{z}} \]
    2. Add Preprocessing
    3. Taylor expanded in y around -inf

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{\left(x \cdot z + \frac{z \cdot \left(x \cdot z - -1 \cdot {z}^{2}\right)}{y}\right) - -1 \cdot {z}^{2}}{y}, \color{blue}{-1}, -1 \cdot z\right) \]
    5. Applied rewrites62.8%

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

    if 6.4e10 < z

    1. Initial program 99.9%

      \[\frac{x + y}{1 - \frac{y}{z}} \]
    2. Add Preprocessing
    3. Taylor expanded in y around inf

      \[\leadsto \color{blue}{-1 \cdot z} \]
    4. Step-by-step derivation
      1. lower-*.f6428.3

        \[\leadsto -1 \cdot \color{blue}{z} \]
    5. Applied rewrites28.3%

      \[\leadsto \color{blue}{-1 \cdot z} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification55.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq 64000000000:\\ \;\;\;\;\mathsf{fma}\left(-1 \cdot \frac{\mathsf{fma}\left(z, \mathsf{fma}\left(x, \frac{z}{y}, \frac{z \cdot z}{y}\right), z \cdot x\right) - \left(z \cdot z\right) \cdot -1}{-1 \cdot y}, -1, -1 \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;-1 \cdot z\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 35.2% accurate, N/A× speedup?

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

\\
-1 \cdot z
\end{array}
Derivation
  1. Initial program 85.6%

    \[\frac{x + y}{1 - \frac{y}{z}} \]
  2. Add Preprocessing
  3. Taylor expanded in y around inf

    \[\leadsto \color{blue}{-1 \cdot z} \]
  4. Step-by-step derivation
    1. lower-*.f6446.4

      \[\leadsto -1 \cdot \color{blue}{z} \]
  5. Applied rewrites46.4%

    \[\leadsto \color{blue}{-1 \cdot z} \]
  6. Add Preprocessing

Reproduce

?
herbie shell --seed 2025065 
(FPCore (x y z)
  :name "Graphics.Rendering.Chart.Backend.Diagrams:calcFontMetrics from Chart-diagrams-1.5.1, A"
  :precision binary64

  :alt
  (! :herbie-platform default (if (< y -3742931076268985600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (* (/ (+ y x) (- y)) z) (if (< y 3553466245608673400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (/ (+ x y) (- 1 (/ y z))) (* (/ (+ y x) (- y)) z))))

  (/ (+ x y) (- 1.0 (/ y z))))