Diagrams.Backend.Rasterific:rasterificRadialGradient from diagrams-rasterific-1.3.1.3

Percentage Accurate: 87.7% → 99.9%
Time: 2.1min
Alternatives: 6
Speedup: 1.0×

Specification

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

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

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

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 6 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.7% accurate, 1.0× speedup?

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

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

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

Alternative 1: 99.9% accurate, 1.0× speedup?

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

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

real(8) function code(x, y, z)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = y - (((-1.0d0) + y) * (x / z))
end function
public static double code(double x, double y, double z) {
	return y - ((-1.0 + y) * (x / z));
}
def code(x, y, z):
	return y - ((-1.0 + y) * (x / z))
function code(x, y, z)
	return Float64(y - Float64(Float64(-1.0 + y) * Float64(x / z)))
end
function tmp = code(x, y, z)
	tmp = y - ((-1.0 + y) * (x / z));
end
code[x_, y_, z_] := N[(y - N[(N[(-1 + y), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
y - \left(-1 + y\right) \cdot \frac{x}{z}
Derivation
  1. Initial program 87.7%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x \cdot \frac{1}{z}} - \frac{\mathsf{neg}\left(y \cdot \left(z - x\right)\right)}{\mathsf{neg}\left(\left(\mathsf{neg}\left(z\right)\right)\right)} \]
    10. mult-flipN/A

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

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

      \[\leadsto \left(x \cdot 1\right) \cdot \frac{1}{z} - \frac{\mathsf{neg}\left(y \cdot \left(z - x\right)\right)}{\color{blue}{z}} \]
    13. mult-flipN/A

      \[\leadsto \left(x \cdot 1\right) \cdot \frac{1}{z} - \color{blue}{\left(\mathsf{neg}\left(y \cdot \left(z - x\right)\right)\right) \cdot \frac{1}{z}} \]
    14. distribute-rgt-out--N/A

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

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

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

      \[\leadsto \frac{1}{z} \cdot \left(\color{blue}{\frac{x}{z} \cdot z} - \left(\mathsf{neg}\left(y \cdot \left(z - x\right)\right)\right)\right) \]
    18. add-flipN/A

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

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

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

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

      \[\leadsto \frac{1}{z} \cdot \left(y \cdot \left(z - x\right) - \left(\mathsf{neg}\left(\color{blue}{x \cdot \frac{z}{z}}\right)\right)\right) \]
    23. *-inversesN/A

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

    \[\leadsto \color{blue}{\mathsf{134\_z0z1z2z3z4}\left(\left(\frac{1}{z}\right), \left(z - x\right), y, x, -1\right)} \]
  4. Step-by-step derivation
    1. lift-134-z0z1z2z3z4N/A

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

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

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

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

      \[\leadsto \frac{\color{blue}{\left(z - x\right) \cdot y} - x \cdot -1}{z} \]
    6. fp-cancel-sub-sign-invN/A

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

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

      \[\leadsto \frac{\left(z - x\right) \cdot y + \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right)}}{z} \]
    9. sub-flipN/A

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

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

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

      \[\leadsto \frac{y \cdot \color{blue}{\left(z - x\right)} - \left(\mathsf{neg}\left(x\right)\right)}{z} \]
    13. sub-flipN/A

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

      \[\leadsto \frac{\color{blue}{\left(y \cdot z + y \cdot \left(\mathsf{neg}\left(x\right)\right)\right)} - \left(\mathsf{neg}\left(x\right)\right)}{z} \]
    15. distribute-rgt-neg-inN/A

      \[\leadsto \frac{\left(y \cdot z + \color{blue}{\left(\mathsf{neg}\left(y \cdot x\right)\right)}\right) - \left(\mathsf{neg}\left(x\right)\right)}{z} \]
    16. distribute-lft-neg-outN/A

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

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

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

      \[\leadsto \frac{\color{blue}{y \cdot z + \left(\left(-y\right) \cdot x - \left(\mathsf{neg}\left(x\right)\right)\right)}}{z} \]
    20. add-flipN/A

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

      \[\leadsto \frac{y \cdot z + \color{blue}{\left(\left(-y\right) \cdot x + x\right)}}{z} \]
    22. add-flipN/A

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

    \[\leadsto \color{blue}{y - \left(-1 + y\right) \cdot \frac{x}{z}} \]
  6. Add Preprocessing

Alternative 2: 99.2% accurate, 0.7× speedup?

\[\begin{array}{l} t_0 := y - y \cdot \frac{x}{z}\\ \mathbf{if}\;y \leq -49000000:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq \frac{7638104968020361}{36028797018963968}:\\ \;\;\;\;y - -1 \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
(FPCore (x y z)
  :precision binary64
  (let* ((t_0 (- y (* y (/ x z)))))
  (if (<= y -49000000)
    t_0
    (if (<= y 7638104968020361/36028797018963968)
      (- y (* -1 (/ x z)))
      t_0))))
double code(double x, double y, double z) {
	double t_0 = y - (y * (x / z));
	double tmp;
	if (y <= -49000000.0) {
		tmp = t_0;
	} else if (y <= 0.212) {
		tmp = y - (-1.0 * (x / z));
	} 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, z)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: tmp
    t_0 = y - (y * (x / z))
    if (y <= (-49000000.0d0)) then
        tmp = t_0
    else if (y <= 0.212d0) then
        tmp = y - ((-1.0d0) * (x / z))
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = y - (y * (x / z));
	double tmp;
	if (y <= -49000000.0) {
		tmp = t_0;
	} else if (y <= 0.212) {
		tmp = y - (-1.0 * (x / z));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = y - (y * (x / z))
	tmp = 0
	if y <= -49000000.0:
		tmp = t_0
	elif y <= 0.212:
		tmp = y - (-1.0 * (x / z))
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(y - Float64(y * Float64(x / z)))
	tmp = 0.0
	if (y <= -49000000.0)
		tmp = t_0;
	elseif (y <= 0.212)
		tmp = Float64(y - Float64(-1.0 * Float64(x / z)));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = y - (y * (x / z));
	tmp = 0.0;
	if (y <= -49000000.0)
		tmp = t_0;
	elseif (y <= 0.212)
		tmp = y - (-1.0 * (x / z));
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(y - N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -49000000], t$95$0, If[LessEqual[y, 7638104968020361/36028797018963968], N[(y - N[(-1 * N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := y - y \cdot \frac{x}{z}\\
\mathbf{if}\;y \leq -49000000:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq \frac{7638104968020361}{36028797018963968}:\\
\;\;\;\;y - -1 \cdot \frac{x}{z}\\

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -4.9e7 or 0.21199999999999999 < y

    1. Initial program 87.7%

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

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

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

        \[\leadsto \frac{y \cdot \left(z - x\right)}{z} \]
      3. lower--.f6454.7%

        \[\leadsto \frac{y \cdot \left(z - x\right)}{z} \]
    4. Applied rewrites54.7%

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

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

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

        \[\leadsto \frac{y \cdot \left(z - x\right)}{z} \]
      4. sub-flipN/A

        \[\leadsto \frac{y \cdot \left(z + \left(\mathsf{neg}\left(x\right)\right)\right)}{z} \]
      5. distribute-lft-inN/A

        \[\leadsto \frac{y \cdot z + y \cdot \left(\mathsf{neg}\left(x\right)\right)}{z} \]
      6. distribute-rgt-neg-inN/A

        \[\leadsto \frac{y \cdot z + \left(\mathsf{neg}\left(y \cdot x\right)\right)}{z} \]
      7. distribute-lft-neg-outN/A

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

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

        \[\leadsto \frac{y \cdot z + \left(-y\right) \cdot x}{z} \]
      10. add-to-fraction-revN/A

        \[\leadsto y + \color{blue}{\frac{\left(-y\right) \cdot x}{z}} \]
      11. add-flipN/A

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

        \[\leadsto y - \color{blue}{\left(\mathsf{neg}\left(\frac{\left(-y\right) \cdot x}{z}\right)\right)} \]
      13. distribute-neg-frac2N/A

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

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

        \[\leadsto y - \frac{\left(\mathsf{neg}\left(y\right)\right) \cdot x}{\mathsf{neg}\left(z\right)} \]
      16. distribute-lft-neg-outN/A

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

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

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

        \[\leadsto y - y \cdot \color{blue}{\frac{x}{z}} \]
      20. lower-/.f6468.7%

        \[\leadsto y - y \cdot \frac{x}{\color{blue}{z}} \]
    6. Applied rewrites68.7%

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

    if -4.9e7 < y < 0.21199999999999999

    1. Initial program 87.7%

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{x \cdot \frac{1}{z}} - \frac{\mathsf{neg}\left(y \cdot \left(z - x\right)\right)}{\mathsf{neg}\left(\left(\mathsf{neg}\left(z\right)\right)\right)} \]
      10. mult-flipN/A

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

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

        \[\leadsto \left(x \cdot 1\right) \cdot \frac{1}{z} - \frac{\mathsf{neg}\left(y \cdot \left(z - x\right)\right)}{\color{blue}{z}} \]
      13. mult-flipN/A

        \[\leadsto \left(x \cdot 1\right) \cdot \frac{1}{z} - \color{blue}{\left(\mathsf{neg}\left(y \cdot \left(z - x\right)\right)\right) \cdot \frac{1}{z}} \]
      14. distribute-rgt-out--N/A

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

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

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

        \[\leadsto \frac{1}{z} \cdot \left(\color{blue}{\frac{x}{z} \cdot z} - \left(\mathsf{neg}\left(y \cdot \left(z - x\right)\right)\right)\right) \]
      18. add-flipN/A

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

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

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

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

        \[\leadsto \frac{1}{z} \cdot \left(y \cdot \left(z - x\right) - \left(\mathsf{neg}\left(\color{blue}{x \cdot \frac{z}{z}}\right)\right)\right) \]
      23. *-inversesN/A

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

      \[\leadsto \color{blue}{\mathsf{134\_z0z1z2z3z4}\left(\left(\frac{1}{z}\right), \left(z - x\right), y, x, -1\right)} \]
    4. Step-by-step derivation
      1. lift-134-z0z1z2z3z4N/A

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

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

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

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

        \[\leadsto \frac{\color{blue}{\left(z - x\right) \cdot y} - x \cdot -1}{z} \]
      6. fp-cancel-sub-sign-invN/A

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

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

        \[\leadsto \frac{\left(z - x\right) \cdot y + \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right)}}{z} \]
      9. sub-flipN/A

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

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

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

        \[\leadsto \frac{y \cdot \color{blue}{\left(z - x\right)} - \left(\mathsf{neg}\left(x\right)\right)}{z} \]
      13. sub-flipN/A

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

        \[\leadsto \frac{\color{blue}{\left(y \cdot z + y \cdot \left(\mathsf{neg}\left(x\right)\right)\right)} - \left(\mathsf{neg}\left(x\right)\right)}{z} \]
      15. distribute-rgt-neg-inN/A

        \[\leadsto \frac{\left(y \cdot z + \color{blue}{\left(\mathsf{neg}\left(y \cdot x\right)\right)}\right) - \left(\mathsf{neg}\left(x\right)\right)}{z} \]
      16. distribute-lft-neg-outN/A

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

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

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

        \[\leadsto \frac{\color{blue}{y \cdot z + \left(\left(-y\right) \cdot x - \left(\mathsf{neg}\left(x\right)\right)\right)}}{z} \]
      20. add-flipN/A

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

        \[\leadsto \frac{y \cdot z + \color{blue}{\left(\left(-y\right) \cdot x + x\right)}}{z} \]
      22. add-flipN/A

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

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

      \[\leadsto y - \color{blue}{-1} \cdot \frac{x}{z} \]
    7. Step-by-step derivation
      1. Applied rewrites78.0%

        \[\leadsto y - \color{blue}{-1} \cdot \frac{x}{z} \]
    8. Recombined 2 regimes into one program.
    9. Add Preprocessing

    Alternative 3: 82.8% accurate, 0.7× speedup?

    \[\begin{array}{l} t_0 := y - y \cdot \frac{x}{z}\\ \mathbf{if}\;y \leq \frac{-4928960573339599}{16996415770136547158066822609678996074546979767265021542382212422412913915547271767653200072487337141404458543559888032491090538804886631661104639320530795262202600666732583009015300096}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq \frac{2712190898730935}{17498005798264095394980017816940970922825355447145699491406164851279623993595007385788105416184430592}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
    (FPCore (x y z)
      :precision binary64
      (let* ((t_0 (- y (* y (/ x z)))))
      (if (<=
           y
           -4928960573339599/16996415770136547158066822609678996074546979767265021542382212422412913915547271767653200072487337141404458543559888032491090538804886631661104639320530795262202600666732583009015300096)
        t_0
        (if (<=
             y
             2712190898730935/17498005798264095394980017816940970922825355447145699491406164851279623993595007385788105416184430592)
          (/ x z)
          t_0))))
    double code(double x, double y, double z) {
    	double t_0 = y - (y * (x / z));
    	double tmp;
    	if (y <= -2.9e-169) {
    		tmp = t_0;
    	} else if (y <= 1.55e-85) {
    		tmp = x / z;
    	} 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, z)
    use fmin_fmax_functions
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        real(8), intent (in) :: z
        real(8) :: t_0
        real(8) :: tmp
        t_0 = y - (y * (x / z))
        if (y <= (-2.9d-169)) then
            tmp = t_0
        else if (y <= 1.55d-85) then
            tmp = x / z
        else
            tmp = t_0
        end if
        code = tmp
    end function
    
    public static double code(double x, double y, double z) {
    	double t_0 = y - (y * (x / z));
    	double tmp;
    	if (y <= -2.9e-169) {
    		tmp = t_0;
    	} else if (y <= 1.55e-85) {
    		tmp = x / z;
    	} else {
    		tmp = t_0;
    	}
    	return tmp;
    }
    
    def code(x, y, z):
    	t_0 = y - (y * (x / z))
    	tmp = 0
    	if y <= -2.9e-169:
    		tmp = t_0
    	elif y <= 1.55e-85:
    		tmp = x / z
    	else:
    		tmp = t_0
    	return tmp
    
    function code(x, y, z)
    	t_0 = Float64(y - Float64(y * Float64(x / z)))
    	tmp = 0.0
    	if (y <= -2.9e-169)
    		tmp = t_0;
    	elseif (y <= 1.55e-85)
    		tmp = Float64(x / z);
    	else
    		tmp = t_0;
    	end
    	return tmp
    end
    
    function tmp_2 = code(x, y, z)
    	t_0 = y - (y * (x / z));
    	tmp = 0.0;
    	if (y <= -2.9e-169)
    		tmp = t_0;
    	elseif (y <= 1.55e-85)
    		tmp = x / z;
    	else
    		tmp = t_0;
    	end
    	tmp_2 = tmp;
    end
    
    code[x_, y_, z_] := Block[{t$95$0 = N[(y - N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -4928960573339599/16996415770136547158066822609678996074546979767265021542382212422412913915547271767653200072487337141404458543559888032491090538804886631661104639320530795262202600666732583009015300096], t$95$0, If[LessEqual[y, 2712190898730935/17498005798264095394980017816940970922825355447145699491406164851279623993595007385788105416184430592], N[(x / z), $MachinePrecision], t$95$0]]]
    
    \begin{array}{l}
    t_0 := y - y \cdot \frac{x}{z}\\
    \mathbf{if}\;y \leq \frac{-4928960573339599}{16996415770136547158066822609678996074546979767265021542382212422412913915547271767653200072487337141404458543559888032491090538804886631661104639320530795262202600666732583009015300096}:\\
    \;\;\;\;t\_0\\
    
    \mathbf{elif}\;y \leq \frac{2712190898730935}{17498005798264095394980017816940970922825355447145699491406164851279623993595007385788105416184430592}:\\
    \;\;\;\;\frac{x}{z}\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_0\\
    
    
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if y < -2.9000000000000002e-169 or 1.5500000000000001e-85 < y

      1. Initial program 87.7%

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

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

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

          \[\leadsto \frac{y \cdot \left(z - x\right)}{z} \]
        3. lower--.f6454.7%

          \[\leadsto \frac{y \cdot \left(z - x\right)}{z} \]
      4. Applied rewrites54.7%

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

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

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

          \[\leadsto \frac{y \cdot \left(z - x\right)}{z} \]
        4. sub-flipN/A

          \[\leadsto \frac{y \cdot \left(z + \left(\mathsf{neg}\left(x\right)\right)\right)}{z} \]
        5. distribute-lft-inN/A

          \[\leadsto \frac{y \cdot z + y \cdot \left(\mathsf{neg}\left(x\right)\right)}{z} \]
        6. distribute-rgt-neg-inN/A

          \[\leadsto \frac{y \cdot z + \left(\mathsf{neg}\left(y \cdot x\right)\right)}{z} \]
        7. distribute-lft-neg-outN/A

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

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

          \[\leadsto \frac{y \cdot z + \left(-y\right) \cdot x}{z} \]
        10. add-to-fraction-revN/A

          \[\leadsto y + \color{blue}{\frac{\left(-y\right) \cdot x}{z}} \]
        11. add-flipN/A

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

          \[\leadsto y - \color{blue}{\left(\mathsf{neg}\left(\frac{\left(-y\right) \cdot x}{z}\right)\right)} \]
        13. distribute-neg-frac2N/A

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

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

          \[\leadsto y - \frac{\left(\mathsf{neg}\left(y\right)\right) \cdot x}{\mathsf{neg}\left(z\right)} \]
        16. distribute-lft-neg-outN/A

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

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

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

          \[\leadsto y - y \cdot \color{blue}{\frac{x}{z}} \]
        20. lower-/.f6468.7%

          \[\leadsto y - y \cdot \frac{x}{\color{blue}{z}} \]
      6. Applied rewrites68.7%

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

      if -2.9000000000000002e-169 < y < 1.5500000000000001e-85

      1. Initial program 87.7%

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

        \[\leadsto \color{blue}{\frac{x}{z}} \]
      3. Step-by-step derivation
        1. lower-/.f6438.5%

          \[\leadsto \frac{x}{\color{blue}{z}} \]
      4. Applied rewrites38.5%

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

    Alternative 4: 58.7% accurate, 0.8× speedup?

    \[\begin{array}{l} \mathbf{if}\;y \leq \frac{-7547924849643083}{3773962424821541352241554580988268890916921220416440428376206300245624162392148852086126725177658767541468375030763844899770584629924792632561434251432696043649395326976}:\\ \;\;\;\;y\\ \mathbf{elif}\;y \leq \frac{2712190898730935}{17498005798264095394980017816940970922825355447145699491406164851279623993595007385788105416184430592}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z} \cdot z\\ \end{array} \]
    (FPCore (x y z)
      :precision binary64
      (if (<=
         y
         -7547924849643083/3773962424821541352241554580988268890916921220416440428376206300245624162392148852086126725177658767541468375030763844899770584629924792632561434251432696043649395326976)
      y
      (if (<=
           y
           2712190898730935/17498005798264095394980017816940970922825355447145699491406164851279623993595007385788105416184430592)
        (/ x z)
        (* (/ y z) z))))
    double code(double x, double y, double z) {
    	double tmp;
    	if (y <= -2e-153) {
    		tmp = y;
    	} else if (y <= 1.55e-85) {
    		tmp = x / z;
    	} else {
    		tmp = (y / z) * z;
    	}
    	return tmp;
    }
    
    module fmin_fmax_functions
        implicit none
        private
        public fmax
        public fmin
    
        interface fmax
            module procedure fmax88
            module procedure fmax44
            module procedure fmax84
            module procedure fmax48
        end interface
        interface fmin
            module procedure fmin88
            module procedure fmin44
            module procedure fmin84
            module procedure fmin48
        end interface
    contains
        real(8) function fmax88(x, y) result (res)
            real(8), intent (in) :: x
            real(8), intent (in) :: y
            res = merge(y, merge(x, max(x, y), y /= y), x /= x)
        end function
        real(4) function fmax44(x, y) result (res)
            real(4), intent (in) :: x
            real(4), intent (in) :: y
            res = merge(y, merge(x, max(x, y), y /= y), x /= x)
        end function
        real(8) function fmax84(x, y) result(res)
            real(8), intent (in) :: x
            real(4), intent (in) :: y
            res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
        end function
        real(8) function fmax48(x, y) result(res)
            real(4), intent (in) :: x
            real(8), intent (in) :: y
            res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
        end function
        real(8) function fmin88(x, y) result (res)
            real(8), intent (in) :: x
            real(8), intent (in) :: y
            res = merge(y, merge(x, min(x, y), y /= y), x /= x)
        end function
        real(4) function fmin44(x, y) result (res)
            real(4), intent (in) :: x
            real(4), intent (in) :: y
            res = merge(y, merge(x, min(x, y), y /= y), x /= x)
        end function
        real(8) function fmin84(x, y) result(res)
            real(8), intent (in) :: x
            real(4), intent (in) :: y
            res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
        end function
        real(8) function fmin48(x, y) result(res)
            real(4), intent (in) :: x
            real(8), intent (in) :: y
            res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
        end function
    end module
    
    real(8) function code(x, y, z)
    use fmin_fmax_functions
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        real(8), intent (in) :: z
        real(8) :: tmp
        if (y <= (-2d-153)) then
            tmp = y
        else if (y <= 1.55d-85) then
            tmp = x / z
        else
            tmp = (y / z) * z
        end if
        code = tmp
    end function
    
    public static double code(double x, double y, double z) {
    	double tmp;
    	if (y <= -2e-153) {
    		tmp = y;
    	} else if (y <= 1.55e-85) {
    		tmp = x / z;
    	} else {
    		tmp = (y / z) * z;
    	}
    	return tmp;
    }
    
    def code(x, y, z):
    	tmp = 0
    	if y <= -2e-153:
    		tmp = y
    	elif y <= 1.55e-85:
    		tmp = x / z
    	else:
    		tmp = (y / z) * z
    	return tmp
    
    function code(x, y, z)
    	tmp = 0.0
    	if (y <= -2e-153)
    		tmp = y;
    	elseif (y <= 1.55e-85)
    		tmp = Float64(x / z);
    	else
    		tmp = Float64(Float64(y / z) * z);
    	end
    	return tmp
    end
    
    function tmp_2 = code(x, y, z)
    	tmp = 0.0;
    	if (y <= -2e-153)
    		tmp = y;
    	elseif (y <= 1.55e-85)
    		tmp = x / z;
    	else
    		tmp = (y / z) * z;
    	end
    	tmp_2 = tmp;
    end
    
    code[x_, y_, z_] := If[LessEqual[y, -7547924849643083/3773962424821541352241554580988268890916921220416440428376206300245624162392148852086126725177658767541468375030763844899770584629924792632561434251432696043649395326976], y, If[LessEqual[y, 2712190898730935/17498005798264095394980017816940970922825355447145699491406164851279623993595007385788105416184430592], N[(x / z), $MachinePrecision], N[(N[(y / z), $MachinePrecision] * z), $MachinePrecision]]]
    
    \begin{array}{l}
    \mathbf{if}\;y \leq \frac{-7547924849643083}{3773962424821541352241554580988268890916921220416440428376206300245624162392148852086126725177658767541468375030763844899770584629924792632561434251432696043649395326976}:\\
    \;\;\;\;y\\
    
    \mathbf{elif}\;y \leq \frac{2712190898730935}{17498005798264095394980017816940970922825355447145699491406164851279623993595007385788105416184430592}:\\
    \;\;\;\;\frac{x}{z}\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{y}{z} \cdot z\\
    
    
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if y < -2.0000000000000001e-153

      1. Initial program 87.7%

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

        \[\leadsto \color{blue}{y} \]
      3. Step-by-step derivation
        1. Applied rewrites41.8%

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

        if -2.0000000000000001e-153 < y < 1.5500000000000001e-85

        1. Initial program 87.7%

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

          \[\leadsto \color{blue}{\frac{x}{z}} \]
        3. Step-by-step derivation
          1. lower-/.f6438.5%

            \[\leadsto \frac{x}{\color{blue}{z}} \]
        4. Applied rewrites38.5%

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

        if 1.5500000000000001e-85 < y

        1. Initial program 87.7%

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

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

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

            \[\leadsto \frac{y \cdot \left(z - x\right)}{z} \]
          3. lower--.f6454.7%

            \[\leadsto \frac{y \cdot \left(z - x\right)}{z} \]
        4. Applied rewrites54.7%

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

          \[\leadsto \frac{y \cdot z}{z} \]
        6. Step-by-step derivation
          1. Applied rewrites32.3%

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

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

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

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

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

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

              \[\leadsto \frac{y}{z} \cdot \color{blue}{z} \]
            7. lower-/.f6438.1%

              \[\leadsto \frac{y}{z} \cdot z \]
          3. Applied rewrites38.1%

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

        Alternative 5: 57.8% accurate, 1.0× speedup?

        \[\begin{array}{l} \mathbf{if}\;y \leq \frac{-7547924849643083}{3773962424821541352241554580988268890916921220416440428376206300245624162392148852086126725177658767541468375030763844899770584629924792632561434251432696043649395326976}:\\ \;\;\;\;y\\ \mathbf{elif}\;y \leq \frac{2712190898730935}{17498005798264095394980017816940970922825355447145699491406164851279623993595007385788105416184430592}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \]
        (FPCore (x y z)
          :precision binary64
          (if (<=
             y
             -7547924849643083/3773962424821541352241554580988268890916921220416440428376206300245624162392148852086126725177658767541468375030763844899770584629924792632561434251432696043649395326976)
          y
          (if (<=
               y
               2712190898730935/17498005798264095394980017816940970922825355447145699491406164851279623993595007385788105416184430592)
            (/ x z)
            y)))
        double code(double x, double y, double z) {
        	double tmp;
        	if (y <= -2e-153) {
        		tmp = y;
        	} else if (y <= 1.55e-85) {
        		tmp = x / z;
        	} else {
        		tmp = 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, z)
        use fmin_fmax_functions
            real(8), intent (in) :: x
            real(8), intent (in) :: y
            real(8), intent (in) :: z
            real(8) :: tmp
            if (y <= (-2d-153)) then
                tmp = y
            else if (y <= 1.55d-85) then
                tmp = x / z
            else
                tmp = y
            end if
            code = tmp
        end function
        
        public static double code(double x, double y, double z) {
        	double tmp;
        	if (y <= -2e-153) {
        		tmp = y;
        	} else if (y <= 1.55e-85) {
        		tmp = x / z;
        	} else {
        		tmp = y;
        	}
        	return tmp;
        }
        
        def code(x, y, z):
        	tmp = 0
        	if y <= -2e-153:
        		tmp = y
        	elif y <= 1.55e-85:
        		tmp = x / z
        	else:
        		tmp = y
        	return tmp
        
        function code(x, y, z)
        	tmp = 0.0
        	if (y <= -2e-153)
        		tmp = y;
        	elseif (y <= 1.55e-85)
        		tmp = Float64(x / z);
        	else
        		tmp = y;
        	end
        	return tmp
        end
        
        function tmp_2 = code(x, y, z)
        	tmp = 0.0;
        	if (y <= -2e-153)
        		tmp = y;
        	elseif (y <= 1.55e-85)
        		tmp = x / z;
        	else
        		tmp = y;
        	end
        	tmp_2 = tmp;
        end
        
        code[x_, y_, z_] := If[LessEqual[y, -7547924849643083/3773962424821541352241554580988268890916921220416440428376206300245624162392148852086126725177658767541468375030763844899770584629924792632561434251432696043649395326976], y, If[LessEqual[y, 2712190898730935/17498005798264095394980017816940970922825355447145699491406164851279623993595007385788105416184430592], N[(x / z), $MachinePrecision], y]]
        
        \begin{array}{l}
        \mathbf{if}\;y \leq \frac{-7547924849643083}{3773962424821541352241554580988268890916921220416440428376206300245624162392148852086126725177658767541468375030763844899770584629924792632561434251432696043649395326976}:\\
        \;\;\;\;y\\
        
        \mathbf{elif}\;y \leq \frac{2712190898730935}{17498005798264095394980017816940970922825355447145699491406164851279623993595007385788105416184430592}:\\
        \;\;\;\;\frac{x}{z}\\
        
        \mathbf{else}:\\
        \;\;\;\;y\\
        
        
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if y < -2.0000000000000001e-153 or 1.5500000000000001e-85 < y

          1. Initial program 87.7%

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

            \[\leadsto \color{blue}{y} \]
          3. Step-by-step derivation
            1. Applied rewrites41.8%

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

            if -2.0000000000000001e-153 < y < 1.5500000000000001e-85

            1. Initial program 87.7%

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

              \[\leadsto \color{blue}{\frac{x}{z}} \]
            3. Step-by-step derivation
              1. lower-/.f6438.5%

                \[\leadsto \frac{x}{\color{blue}{z}} \]
            4. Applied rewrites38.5%

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

          Alternative 6: 41.8% accurate, 23.0× speedup?

          \[y \]
          (FPCore (x y z)
            :precision binary64
            y)
          double code(double x, double y, double z) {
          	return y;
          }
          
          module fmin_fmax_functions
              implicit none
              private
              public fmax
              public fmin
          
              interface fmax
                  module procedure fmax88
                  module procedure fmax44
                  module procedure fmax84
                  module procedure fmax48
              end interface
              interface fmin
                  module procedure fmin88
                  module procedure fmin44
                  module procedure fmin84
                  module procedure fmin48
              end interface
          contains
              real(8) function fmax88(x, y) result (res)
                  real(8), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
              end function
              real(4) function fmax44(x, y) result (res)
                  real(4), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
              end function
              real(8) function fmax84(x, y) result(res)
                  real(8), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
              end function
              real(8) function fmax48(x, y) result(res)
                  real(4), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
              end function
              real(8) function fmin88(x, y) result (res)
                  real(8), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
              end function
              real(4) function fmin44(x, y) result (res)
                  real(4), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
              end function
              real(8) function fmin84(x, y) result(res)
                  real(8), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
              end function
              real(8) function fmin48(x, y) result(res)
                  real(4), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
              end function
          end module
          
          real(8) function code(x, y, z)
          use fmin_fmax_functions
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              real(8), intent (in) :: z
              code = y
          end function
          
          public static double code(double x, double y, double z) {
          	return y;
          }
          
          def code(x, y, z):
          	return y
          
          function code(x, y, z)
          	return y
          end
          
          function tmp = code(x, y, z)
          	tmp = y;
          end
          
          code[x_, y_, z_] := y
          
          y
          
          Derivation
          1. Initial program 87.7%

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

            \[\leadsto \color{blue}{y} \]
          3. Step-by-step derivation
            1. Applied rewrites41.8%

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

            Reproduce

            ?
            herbie shell --seed 2025271 -o generate:evaluate
            (FPCore (x y z)
              :name "Diagrams.Backend.Rasterific:rasterificRadialGradient from diagrams-rasterific-1.3.1.3"
              :precision binary64
              (/ (+ x (* y (- z x))) z))