
(FPCore (x y z) :precision binary64 (+ x (* (* (- y x) 6.0) z)))
double code(double x, double y, double z) {
return x + (((y - x) * 6.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 = x + (((y - x) * 6.0d0) * z)
end function
public static double code(double x, double y, double z) {
return x + (((y - x) * 6.0) * z);
}
def code(x, y, z): return x + (((y - x) * 6.0) * z)
function code(x, y, z) return Float64(x + Float64(Float64(Float64(y - x) * 6.0) * z)) end
function tmp = code(x, y, z) tmp = x + (((y - x) * 6.0) * z); end
code[x_, y_, z_] := N[(x + N[(N[(N[(y - x), $MachinePrecision] * 6.0), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\left(y - x\right) \cdot 6\right) \cdot z
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ x (* (* (- y x) 6.0) z)))
double code(double x, double y, double z) {
return x + (((y - x) * 6.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 = x + (((y - x) * 6.0d0) * z)
end function
public static double code(double x, double y, double z) {
return x + (((y - x) * 6.0) * z);
}
def code(x, y, z): return x + (((y - x) * 6.0) * z)
function code(x, y, z) return Float64(x + Float64(Float64(Float64(y - x) * 6.0) * z)) end
function tmp = code(x, y, z) tmp = x + (((y - x) * 6.0) * z); end
code[x_, y_, z_] := N[(x + N[(N[(N[(y - x), $MachinePrecision] * 6.0), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\left(y - x\right) \cdot 6\right) \cdot z
\end{array}
(FPCore (x y z) :precision binary64 (+ x (* (* (- y x) 6.0) z)))
double code(double x, double y, double z) {
return x + (((y - x) * 6.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 = x + (((y - x) * 6.0d0) * z)
end function
public static double code(double x, double y, double z) {
return x + (((y - x) * 6.0) * z);
}
def code(x, y, z): return x + (((y - x) * 6.0) * z)
function code(x, y, z) return Float64(x + Float64(Float64(Float64(y - x) * 6.0) * z)) end
function tmp = code(x, y, z) tmp = x + (((y - x) * 6.0) * z); end
code[x_, y_, z_] := N[(x + N[(N[(N[(y - x), $MachinePrecision] * 6.0), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\left(y - x\right) \cdot 6\right) \cdot z
\end{array}
Initial program 99.8%
(FPCore (x y z)
:precision binary64
(if (<= z -3.15e-112)
(* (* z 6.0) y)
(if (<= z 6.6e-44)
x
(if (<= z 1.16e+154) (* (* 6.0 y) z) (* (* -6.0 x) z)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -3.15e-112) {
tmp = (z * 6.0) * y;
} else if (z <= 6.6e-44) {
tmp = x;
} else if (z <= 1.16e+154) {
tmp = (6.0 * y) * z;
} else {
tmp = (-6.0 * x) * 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 (z <= (-3.15d-112)) then
tmp = (z * 6.0d0) * y
else if (z <= 6.6d-44) then
tmp = x
else if (z <= 1.16d+154) then
tmp = (6.0d0 * y) * z
else
tmp = ((-6.0d0) * x) * z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -3.15e-112) {
tmp = (z * 6.0) * y;
} else if (z <= 6.6e-44) {
tmp = x;
} else if (z <= 1.16e+154) {
tmp = (6.0 * y) * z;
} else {
tmp = (-6.0 * x) * z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -3.15e-112: tmp = (z * 6.0) * y elif z <= 6.6e-44: tmp = x elif z <= 1.16e+154: tmp = (6.0 * y) * z else: tmp = (-6.0 * x) * z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -3.15e-112) tmp = Float64(Float64(z * 6.0) * y); elseif (z <= 6.6e-44) tmp = x; elseif (z <= 1.16e+154) tmp = Float64(Float64(6.0 * y) * z); else tmp = Float64(Float64(-6.0 * x) * z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -3.15e-112) tmp = (z * 6.0) * y; elseif (z <= 6.6e-44) tmp = x; elseif (z <= 1.16e+154) tmp = (6.0 * y) * z; else tmp = (-6.0 * x) * z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -3.15e-112], N[(N[(z * 6.0), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[z, 6.6e-44], x, If[LessEqual[z, 1.16e+154], N[(N[(6.0 * y), $MachinePrecision] * z), $MachinePrecision], N[(N[(-6.0 * x), $MachinePrecision] * z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.15 \cdot 10^{-112}:\\
\;\;\;\;\left(z \cdot 6\right) \cdot y\\
\mathbf{elif}\;z \leq 6.6 \cdot 10^{-44}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 1.16 \cdot 10^{+154}:\\
\;\;\;\;\left(6 \cdot y\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;\left(-6 \cdot x\right) \cdot z\\
\end{array}
\end{array}
if z < -3.15000000000000008e-112Initial program 99.8%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6459.2
Applied rewrites59.2%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6459.3
Applied rewrites59.3%
if -3.15000000000000008e-112 < z < 6.60000000000000011e-44Initial program 99.9%
Taylor expanded in z around 0
Applied rewrites76.0%
if 6.60000000000000011e-44 < z < 1.16000000000000001e154Initial program 99.7%
Taylor expanded in z around inf
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f6491.8
Applied rewrites91.8%
Taylor expanded in x around 0
lower-*.f6465.0
Applied rewrites65.0%
if 1.16000000000000001e154 < z Initial program 99.9%
Taylor expanded in z around inf
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f6499.9
Applied rewrites99.9%
Taylor expanded in x around inf
lower-*.f6480.5
Applied rewrites80.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (* 6.0 y) z)))
(if (<= z -3.15e-112)
t_0
(if (<= z 6.6e-44) x (if (<= z 1.16e+154) t_0 (* (* -6.0 x) z))))))
double code(double x, double y, double z) {
double t_0 = (6.0 * y) * z;
double tmp;
if (z <= -3.15e-112) {
tmp = t_0;
} else if (z <= 6.6e-44) {
tmp = x;
} else if (z <= 1.16e+154) {
tmp = t_0;
} else {
tmp = (-6.0 * x) * 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) :: t_0
real(8) :: tmp
t_0 = (6.0d0 * y) * z
if (z <= (-3.15d-112)) then
tmp = t_0
else if (z <= 6.6d-44) then
tmp = x
else if (z <= 1.16d+154) then
tmp = t_0
else
tmp = ((-6.0d0) * x) * z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (6.0 * y) * z;
double tmp;
if (z <= -3.15e-112) {
tmp = t_0;
} else if (z <= 6.6e-44) {
tmp = x;
} else if (z <= 1.16e+154) {
tmp = t_0;
} else {
tmp = (-6.0 * x) * z;
}
return tmp;
}
def code(x, y, z): t_0 = (6.0 * y) * z tmp = 0 if z <= -3.15e-112: tmp = t_0 elif z <= 6.6e-44: tmp = x elif z <= 1.16e+154: tmp = t_0 else: tmp = (-6.0 * x) * z return tmp
function code(x, y, z) t_0 = Float64(Float64(6.0 * y) * z) tmp = 0.0 if (z <= -3.15e-112) tmp = t_0; elseif (z <= 6.6e-44) tmp = x; elseif (z <= 1.16e+154) tmp = t_0; else tmp = Float64(Float64(-6.0 * x) * z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (6.0 * y) * z; tmp = 0.0; if (z <= -3.15e-112) tmp = t_0; elseif (z <= 6.6e-44) tmp = x; elseif (z <= 1.16e+154) tmp = t_0; else tmp = (-6.0 * x) * z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(6.0 * y), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[z, -3.15e-112], t$95$0, If[LessEqual[z, 6.6e-44], x, If[LessEqual[z, 1.16e+154], t$95$0, N[(N[(-6.0 * x), $MachinePrecision] * z), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(6 \cdot y\right) \cdot z\\
\mathbf{if}\;z \leq -3.15 \cdot 10^{-112}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 6.6 \cdot 10^{-44}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 1.16 \cdot 10^{+154}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\left(-6 \cdot x\right) \cdot z\\
\end{array}
\end{array}
if z < -3.15000000000000008e-112 or 6.60000000000000011e-44 < z < 1.16000000000000001e154Initial program 99.8%
Taylor expanded in z around inf
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f6487.1
Applied rewrites87.1%
Taylor expanded in x around 0
lower-*.f6461.2
Applied rewrites61.2%
if -3.15000000000000008e-112 < z < 6.60000000000000011e-44Initial program 99.9%
Taylor expanded in z around 0
Applied rewrites76.0%
if 1.16000000000000001e154 < z Initial program 99.9%
Taylor expanded in z around inf
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f6499.9
Applied rewrites99.9%
Taylor expanded in x around inf
lower-*.f6480.5
Applied rewrites80.5%
(FPCore (x y z) :precision binary64 (if (or (<= z -0.165) (not (<= z 0.165))) (* (* (- y x) 6.0) z) (+ x (* (* y 6.0) z))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -0.165) || !(z <= 0.165)) {
tmp = ((y - x) * 6.0) * z;
} else {
tmp = x + ((y * 6.0) * 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 ((z <= (-0.165d0)) .or. (.not. (z <= 0.165d0))) then
tmp = ((y - x) * 6.0d0) * z
else
tmp = x + ((y * 6.0d0) * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -0.165) || !(z <= 0.165)) {
tmp = ((y - x) * 6.0) * z;
} else {
tmp = x + ((y * 6.0) * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -0.165) or not (z <= 0.165): tmp = ((y - x) * 6.0) * z else: tmp = x + ((y * 6.0) * z) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -0.165) || !(z <= 0.165)) tmp = Float64(Float64(Float64(y - x) * 6.0) * z); else tmp = Float64(x + Float64(Float64(y * 6.0) * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -0.165) || ~((z <= 0.165))) tmp = ((y - x) * 6.0) * z; else tmp = x + ((y * 6.0) * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -0.165], N[Not[LessEqual[z, 0.165]], $MachinePrecision]], N[(N[(N[(y - x), $MachinePrecision] * 6.0), $MachinePrecision] * z), $MachinePrecision], N[(x + N[(N[(y * 6.0), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.165 \lor \neg \left(z \leq 0.165\right):\\
\;\;\;\;\left(\left(y - x\right) \cdot 6\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;x + \left(y \cdot 6\right) \cdot z\\
\end{array}
\end{array}
if z < -0.165000000000000008 or 0.165000000000000008 < z Initial program 99.8%
Taylor expanded in z around inf
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f6498.6
Applied rewrites98.6%
if -0.165000000000000008 < z < 0.165000000000000008Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites97.2%
Final simplification97.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -0.15) (not (<= z 0.165))) (* (* (- y x) 6.0) z) (+ x (* (* 6.0 z) y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -0.15) || !(z <= 0.165)) {
tmp = ((y - x) * 6.0) * z;
} else {
tmp = x + ((6.0 * z) * 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 ((z <= (-0.15d0)) .or. (.not. (z <= 0.165d0))) then
tmp = ((y - x) * 6.0d0) * z
else
tmp = x + ((6.0d0 * z) * y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -0.15) || !(z <= 0.165)) {
tmp = ((y - x) * 6.0) * z;
} else {
tmp = x + ((6.0 * z) * y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -0.15) or not (z <= 0.165): tmp = ((y - x) * 6.0) * z else: tmp = x + ((6.0 * z) * y) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -0.15) || !(z <= 0.165)) tmp = Float64(Float64(Float64(y - x) * 6.0) * z); else tmp = Float64(x + Float64(Float64(6.0 * z) * y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -0.15) || ~((z <= 0.165))) tmp = ((y - x) * 6.0) * z; else tmp = x + ((6.0 * z) * y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -0.15], N[Not[LessEqual[z, 0.165]], $MachinePrecision]], N[(N[(N[(y - x), $MachinePrecision] * 6.0), $MachinePrecision] * z), $MachinePrecision], N[(x + N[(N[(6.0 * z), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.15 \lor \neg \left(z \leq 0.165\right):\\
\;\;\;\;\left(\left(y - x\right) \cdot 6\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;x + \left(6 \cdot z\right) \cdot y\\
\end{array}
\end{array}
if z < -0.149999999999999994 or 0.165000000000000008 < z Initial program 99.8%
Taylor expanded in z around inf
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f6498.6
Applied rewrites98.6%
if -0.149999999999999994 < z < 0.165000000000000008Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites97.2%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6497.2
Applied rewrites97.2%
Final simplification97.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -0.175) (not (<= z 2600000.0))) (* (* (- y x) 6.0) z) (+ x (* (* z y) 6.0))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -0.175) || !(z <= 2600000.0)) {
tmp = ((y - x) * 6.0) * z;
} else {
tmp = x + ((z * y) * 6.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) :: tmp
if ((z <= (-0.175d0)) .or. (.not. (z <= 2600000.0d0))) then
tmp = ((y - x) * 6.0d0) * z
else
tmp = x + ((z * y) * 6.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -0.175) || !(z <= 2600000.0)) {
tmp = ((y - x) * 6.0) * z;
} else {
tmp = x + ((z * y) * 6.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -0.175) or not (z <= 2600000.0): tmp = ((y - x) * 6.0) * z else: tmp = x + ((z * y) * 6.0) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -0.175) || !(z <= 2600000.0)) tmp = Float64(Float64(Float64(y - x) * 6.0) * z); else tmp = Float64(x + Float64(Float64(z * y) * 6.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -0.175) || ~((z <= 2600000.0))) tmp = ((y - x) * 6.0) * z; else tmp = x + ((z * y) * 6.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -0.175], N[Not[LessEqual[z, 2600000.0]], $MachinePrecision]], N[(N[(N[(y - x), $MachinePrecision] * 6.0), $MachinePrecision] * z), $MachinePrecision], N[(x + N[(N[(z * y), $MachinePrecision] * 6.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.175 \lor \neg \left(z \leq 2600000\right):\\
\;\;\;\;\left(\left(y - x\right) \cdot 6\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;x + \left(z \cdot y\right) \cdot 6\\
\end{array}
\end{array}
if z < -0.17499999999999999 or 2.6e6 < z Initial program 99.8%
Taylor expanded in z around inf
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f6498.6
Applied rewrites98.6%
if -0.17499999999999999 < z < 2.6e6Initial program 99.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
distribute-lft-out--N/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6496.0
Applied rewrites96.0%
Taylor expanded in x around 0
*-commutativeN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f6497.3
Applied rewrites97.3%
Final simplification97.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -3.15e-112) (not (<= z 6.6e-44))) (* (* (- y x) 6.0) z) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -3.15e-112) || !(z <= 6.6e-44)) {
tmp = ((y - x) * 6.0) * z;
} else {
tmp = x;
}
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 ((z <= (-3.15d-112)) .or. (.not. (z <= 6.6d-44))) then
tmp = ((y - x) * 6.0d0) * z
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -3.15e-112) || !(z <= 6.6e-44)) {
tmp = ((y - x) * 6.0) * z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -3.15e-112) or not (z <= 6.6e-44): tmp = ((y - x) * 6.0) * z else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -3.15e-112) || !(z <= 6.6e-44)) tmp = Float64(Float64(Float64(y - x) * 6.0) * z); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -3.15e-112) || ~((z <= 6.6e-44))) tmp = ((y - x) * 6.0) * z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -3.15e-112], N[Not[LessEqual[z, 6.6e-44]], $MachinePrecision]], N[(N[(N[(y - x), $MachinePrecision] * 6.0), $MachinePrecision] * z), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.15 \cdot 10^{-112} \lor \neg \left(z \leq 6.6 \cdot 10^{-44}\right):\\
\;\;\;\;\left(\left(y - x\right) \cdot 6\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -3.15000000000000008e-112 or 6.60000000000000011e-44 < z Initial program 99.8%
Taylor expanded in z around inf
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f6489.3
Applied rewrites89.3%
if -3.15000000000000008e-112 < z < 6.60000000000000011e-44Initial program 99.9%
Taylor expanded in z around 0
Applied rewrites76.0%
Final simplification85.0%
(FPCore (x y z) :precision binary64 (if (or (<= z -0.165) (not (<= z 0.165))) (* (* -6.0 x) z) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -0.165) || !(z <= 0.165)) {
tmp = (-6.0 * x) * z;
} else {
tmp = x;
}
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 ((z <= (-0.165d0)) .or. (.not. (z <= 0.165d0))) then
tmp = ((-6.0d0) * x) * z
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -0.165) || !(z <= 0.165)) {
tmp = (-6.0 * x) * z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -0.165) or not (z <= 0.165): tmp = (-6.0 * x) * z else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -0.165) || !(z <= 0.165)) tmp = Float64(Float64(-6.0 * x) * z); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -0.165) || ~((z <= 0.165))) tmp = (-6.0 * x) * z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -0.165], N[Not[LessEqual[z, 0.165]], $MachinePrecision]], N[(N[(-6.0 * x), $MachinePrecision] * z), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.165 \lor \neg \left(z \leq 0.165\right):\\
\;\;\;\;\left(-6 \cdot x\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -0.165000000000000008 or 0.165000000000000008 < z Initial program 99.8%
Taylor expanded in z around inf
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f6498.6
Applied rewrites98.6%
Taylor expanded in x around inf
lower-*.f6451.4
Applied rewrites51.4%
if -0.165000000000000008 < z < 0.165000000000000008Initial program 99.9%
Taylor expanded in z around 0
Applied rewrites62.5%
Final simplification56.7%
(FPCore (x y z) :precision binary64 x)
double code(double x, double y, double z) {
return x;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x
end function
public static double code(double x, double y, double z) {
return x;
}
def code(x, y, z): return x
function code(x, y, z) return x end
function tmp = code(x, y, z) tmp = x; end
code[x_, y_, z_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 99.8%
Taylor expanded in z around 0
Applied rewrites31.3%
herbie shell --seed 2025065
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSL:hsl from colour-2.3.3, E"
:precision binary64
:alt
(! :herbie-platform default (- x (* (* 6 z) (- x y))))
(+ x (* (* (- y x) 6.0) z)))