
(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}
Herbie found 13 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.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (* 6.0 y) z)))
(if (<= z -1e-79)
t_0
(if (<= z 6.5e-44) x (if (<= z 3e+232) 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 <= -1e-79) {
tmp = t_0;
} else if (z <= 6.5e-44) {
tmp = x;
} else if (z <= 3e+232) {
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 <= (-1d-79)) then
tmp = t_0
else if (z <= 6.5d-44) then
tmp = x
else if (z <= 3d+232) 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 <= -1e-79) {
tmp = t_0;
} else if (z <= 6.5e-44) {
tmp = x;
} else if (z <= 3e+232) {
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 <= -1e-79: tmp = t_0 elif z <= 6.5e-44: tmp = x elif z <= 3e+232: 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 <= -1e-79) tmp = t_0; elseif (z <= 6.5e-44) tmp = x; elseif (z <= 3e+232) 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 <= -1e-79) tmp = t_0; elseif (z <= 6.5e-44) tmp = x; elseif (z <= 3e+232) 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, -1e-79], t$95$0, If[LessEqual[z, 6.5e-44], x, If[LessEqual[z, 3e+232], 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 -1 \cdot 10^{-79}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 6.5 \cdot 10^{-44}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 3 \cdot 10^{+232}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\left(-6 \cdot x\right) \cdot z\\
\end{array}
\end{array}
if z < -1e-79 or 6.5e-44 < z < 3.00000000000000003e232Initial program 99.7%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lower-+.f64N/A
+-commutativeN/A
associate-*l*N/A
lower-fma.f64N/A
lift--.f64N/A
*-commutativeN/A
lower-*.f6499.7
Applied rewrites99.7%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6450.4
Applied rewrites50.4%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6450.4
Applied rewrites50.4%
if -1e-79 < z < 6.5e-44Initial program 99.5%
Taylor expanded in z around 0
Applied rewrites75.0%
if 3.00000000000000003e232 < z Initial program 99.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6453.8
Applied rewrites53.8%
Taylor expanded in z around inf
*-commutativeN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f6454.3
Applied rewrites54.3%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6454.3
Applied rewrites54.3%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (* z y) 6.0)))
(if (<= z -1e-79)
t_0
(if (<= z 6.5e-44) x (if (<= z 3e+232) t_0 (* (* -6.0 x) z))))))
double code(double x, double y, double z) {
double t_0 = (z * y) * 6.0;
double tmp;
if (z <= -1e-79) {
tmp = t_0;
} else if (z <= 6.5e-44) {
tmp = x;
} else if (z <= 3e+232) {
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 = (z * y) * 6.0d0
if (z <= (-1d-79)) then
tmp = t_0
else if (z <= 6.5d-44) then
tmp = x
else if (z <= 3d+232) 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 = (z * y) * 6.0;
double tmp;
if (z <= -1e-79) {
tmp = t_0;
} else if (z <= 6.5e-44) {
tmp = x;
} else if (z <= 3e+232) {
tmp = t_0;
} else {
tmp = (-6.0 * x) * z;
}
return tmp;
}
def code(x, y, z): t_0 = (z * y) * 6.0 tmp = 0 if z <= -1e-79: tmp = t_0 elif z <= 6.5e-44: tmp = x elif z <= 3e+232: tmp = t_0 else: tmp = (-6.0 * x) * z return tmp
function code(x, y, z) t_0 = Float64(Float64(z * y) * 6.0) tmp = 0.0 if (z <= -1e-79) tmp = t_0; elseif (z <= 6.5e-44) tmp = x; elseif (z <= 3e+232) tmp = t_0; else tmp = Float64(Float64(-6.0 * x) * z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (z * y) * 6.0; tmp = 0.0; if (z <= -1e-79) tmp = t_0; elseif (z <= 6.5e-44) tmp = x; elseif (z <= 3e+232) tmp = t_0; else tmp = (-6.0 * x) * z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(z * y), $MachinePrecision] * 6.0), $MachinePrecision]}, If[LessEqual[z, -1e-79], t$95$0, If[LessEqual[z, 6.5e-44], x, If[LessEqual[z, 3e+232], t$95$0, N[(N[(-6.0 * x), $MachinePrecision] * z), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(z \cdot y\right) \cdot 6\\
\mathbf{if}\;z \leq -1 \cdot 10^{-79}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 6.5 \cdot 10^{-44}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 3 \cdot 10^{+232}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\left(-6 \cdot x\right) \cdot z\\
\end{array}
\end{array}
if z < -1e-79 or 6.5e-44 < z < 3.00000000000000003e232Initial program 99.7%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6450.4
Applied rewrites50.4%
if -1e-79 < z < 6.5e-44Initial program 99.5%
Taylor expanded in z around 0
Applied rewrites75.0%
if 3.00000000000000003e232 < z Initial program 99.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6453.8
Applied rewrites53.8%
Taylor expanded in z around inf
*-commutativeN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f6454.3
Applied rewrites54.3%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6454.3
Applied rewrites54.3%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* (* (- y x) 6.0) z))) (if (<= z -9.5e+16) t_0 (if (<= z 0.165) (+ x (* (* y 6.0) z)) t_0))))
double code(double x, double y, double z) {
double t_0 = ((y - x) * 6.0) * z;
double tmp;
if (z <= -9.5e+16) {
tmp = t_0;
} else if (z <= 0.165) {
tmp = x + ((y * 6.0) * 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 - x) * 6.0d0) * z
if (z <= (-9.5d+16)) then
tmp = t_0
else if (z <= 0.165d0) then
tmp = x + ((y * 6.0d0) * 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 - x) * 6.0) * z;
double tmp;
if (z <= -9.5e+16) {
tmp = t_0;
} else if (z <= 0.165) {
tmp = x + ((y * 6.0) * z);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = ((y - x) * 6.0) * z tmp = 0 if z <= -9.5e+16: tmp = t_0 elif z <= 0.165: tmp = x + ((y * 6.0) * z) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(Float64(y - x) * 6.0) * z) tmp = 0.0 if (z <= -9.5e+16) tmp = t_0; elseif (z <= 0.165) tmp = Float64(x + Float64(Float64(y * 6.0) * z)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = ((y - x) * 6.0) * z; tmp = 0.0; if (z <= -9.5e+16) tmp = t_0; elseif (z <= 0.165) tmp = x + ((y * 6.0) * z); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(y - x), $MachinePrecision] * 6.0), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[z, -9.5e+16], t$95$0, If[LessEqual[z, 0.165], N[(x + N[(N[(y * 6.0), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(y - x\right) \cdot 6\right) \cdot z\\
\mathbf{if}\;z \leq -9.5 \cdot 10^{+16}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 0.165:\\
\;\;\;\;x + \left(y \cdot 6\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -9.5e16 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-*.f6499.2
Applied rewrites99.2%
if -9.5e16 < z < 0.165000000000000008Initial program 99.5%
Taylor expanded in x around 0
Applied rewrites97.0%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* (* (- y x) 6.0) z))) (if (<= z -0.2) t_0 (if (<= z 0.165) (fma y (* z 6.0) x) t_0))))
double code(double x, double y, double z) {
double t_0 = ((y - x) * 6.0) * z;
double tmp;
if (z <= -0.2) {
tmp = t_0;
} else if (z <= 0.165) {
tmp = fma(y, (z * 6.0), x);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(Float64(y - x) * 6.0) * z) tmp = 0.0 if (z <= -0.2) tmp = t_0; elseif (z <= 0.165) tmp = fma(y, Float64(z * 6.0), x); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(y - x), $MachinePrecision] * 6.0), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[z, -0.2], t$95$0, If[LessEqual[z, 0.165], N[(y * N[(z * 6.0), $MachinePrecision] + x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(y - x\right) \cdot 6\right) \cdot z\\
\mathbf{if}\;z \leq -0.2:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 0.165:\\
\;\;\;\;\mathsf{fma}\left(y, z \cdot 6, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -0.20000000000000001 or 0.165000000000000008 < z Initial program 99.7%
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.20000000000000001 < z < 0.165000000000000008Initial program 99.5%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lower-+.f64N/A
+-commutativeN/A
associate-*l*N/A
lower-fma.f64N/A
lift--.f64N/A
*-commutativeN/A
lower-*.f6499.9
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites98.6%
(FPCore (x y z) :precision binary64 (let* ((t_0 (fma y (* z 6.0) x))) (if (<= y -6e-81) t_0 (if (<= y 1.05e-61) (fma (* z x) -6.0 x) t_0))))
double code(double x, double y, double z) {
double t_0 = fma(y, (z * 6.0), x);
double tmp;
if (y <= -6e-81) {
tmp = t_0;
} else if (y <= 1.05e-61) {
tmp = fma((z * x), -6.0, x);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = fma(y, Float64(z * 6.0), x) tmp = 0.0 if (y <= -6e-81) tmp = t_0; elseif (y <= 1.05e-61) tmp = fma(Float64(z * x), -6.0, x); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(z * 6.0), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[y, -6e-81], t$95$0, If[LessEqual[y, 1.05e-61], N[(N[(z * x), $MachinePrecision] * -6.0 + x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(y, z \cdot 6, x\right)\\
\mathbf{if}\;y \leq -6 \cdot 10^{-81}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1.05 \cdot 10^{-61}:\\
\;\;\;\;\mathsf{fma}\left(z \cdot x, -6, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -5.9999999999999998e-81 or 1.05e-61 < y Initial program 99.6%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lower-+.f64N/A
+-commutativeN/A
associate-*l*N/A
lower-fma.f64N/A
lift--.f64N/A
*-commutativeN/A
lower-*.f6499.8
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites85.7%
if -5.9999999999999998e-81 < y < 1.05e-61Initial program 99.8%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lower-+.f64N/A
+-commutativeN/A
associate-*l*N/A
lower-fma.f64N/A
lift--.f64N/A
*-commutativeN/A
lower-*.f6499.7
Applied rewrites99.7%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-*.f6487.6
Applied rewrites87.6%
(FPCore (x y z) :precision binary64 (if (<= x -1.25e-57) (fma (* z x) -6.0 x) (if (<= x 1.95e-90) (* (* 6.0 y) z) (* (fma -6.0 z 1.0) x))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.25e-57) {
tmp = fma((z * x), -6.0, x);
} else if (x <= 1.95e-90) {
tmp = (6.0 * y) * z;
} else {
tmp = fma(-6.0, z, 1.0) * x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= -1.25e-57) tmp = fma(Float64(z * x), -6.0, x); elseif (x <= 1.95e-90) tmp = Float64(Float64(6.0 * y) * z); else tmp = Float64(fma(-6.0, z, 1.0) * x); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, -1.25e-57], N[(N[(z * x), $MachinePrecision] * -6.0 + x), $MachinePrecision], If[LessEqual[x, 1.95e-90], N[(N[(6.0 * y), $MachinePrecision] * z), $MachinePrecision], N[(N[(-6.0 * z + 1.0), $MachinePrecision] * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.25 \cdot 10^{-57}:\\
\;\;\;\;\mathsf{fma}\left(z \cdot x, -6, x\right)\\
\mathbf{elif}\;x \leq 1.95 \cdot 10^{-90}:\\
\;\;\;\;\left(6 \cdot y\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-6, z, 1\right) \cdot x\\
\end{array}
\end{array}
if x < -1.25e-57Initial program 99.6%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lower-+.f64N/A
+-commutativeN/A
associate-*l*N/A
lower-fma.f64N/A
lift--.f64N/A
*-commutativeN/A
lower-*.f6499.8
Applied rewrites99.8%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-*.f6481.6
Applied rewrites81.6%
if -1.25e-57 < x < 1.95000000000000002e-90Initial program 99.7%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lower-+.f64N/A
+-commutativeN/A
associate-*l*N/A
lower-fma.f64N/A
lift--.f64N/A
*-commutativeN/A
lower-*.f6499.7
Applied rewrites99.7%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6468.7
Applied rewrites68.7%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6468.7
Applied rewrites68.7%
if 1.95000000000000002e-90 < x Initial program 99.7%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6478.9
Applied rewrites78.9%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* (fma -6.0 z 1.0) x))) (if (<= x -1.25e-57) t_0 (if (<= x 1.95e-90) (* (* 6.0 y) z) t_0))))
double code(double x, double y, double z) {
double t_0 = fma(-6.0, z, 1.0) * x;
double tmp;
if (x <= -1.25e-57) {
tmp = t_0;
} else if (x <= 1.95e-90) {
tmp = (6.0 * y) * z;
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(fma(-6.0, z, 1.0) * x) tmp = 0.0 if (x <= -1.25e-57) tmp = t_0; elseif (x <= 1.95e-90) tmp = Float64(Float64(6.0 * y) * z); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(-6.0 * z + 1.0), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[x, -1.25e-57], t$95$0, If[LessEqual[x, 1.95e-90], N[(N[(6.0 * y), $MachinePrecision] * z), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(-6, z, 1\right) \cdot x\\
\mathbf{if}\;x \leq -1.25 \cdot 10^{-57}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.95 \cdot 10^{-90}:\\
\;\;\;\;\left(6 \cdot y\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.25e-57 or 1.95000000000000002e-90 < x Initial program 99.6%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6480.2
Applied rewrites80.2%
if -1.25e-57 < x < 1.95000000000000002e-90Initial program 99.7%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lower-+.f64N/A
+-commutativeN/A
associate-*l*N/A
lower-fma.f64N/A
lift--.f64N/A
*-commutativeN/A
lower-*.f6499.7
Applied rewrites99.7%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6468.7
Applied rewrites68.7%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6468.7
Applied rewrites68.7%
(FPCore (x y z) :precision binary64 (if (<= z -0.165) (* (* -6.0 z) x) (if (<= z 0.165) x (* (* -6.0 x) z))))
double code(double x, double y, double z) {
double tmp;
if (z <= -0.165) {
tmp = (-6.0 * z) * x;
} else if (z <= 0.165) {
tmp = x;
} 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 <= (-0.165d0)) then
tmp = ((-6.0d0) * z) * x
else if (z <= 0.165d0) then
tmp = x
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 <= -0.165) {
tmp = (-6.0 * z) * x;
} else if (z <= 0.165) {
tmp = x;
} else {
tmp = (-6.0 * x) * z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -0.165: tmp = (-6.0 * z) * x elif z <= 0.165: tmp = x else: tmp = (-6.0 * x) * z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -0.165) tmp = Float64(Float64(-6.0 * z) * x); elseif (z <= 0.165) tmp = x; else tmp = Float64(Float64(-6.0 * x) * z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -0.165) tmp = (-6.0 * z) * x; elseif (z <= 0.165) tmp = x; else tmp = (-6.0 * x) * z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -0.165], N[(N[(-6.0 * z), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[z, 0.165], x, N[(N[(-6.0 * x), $MachinePrecision] * z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.165:\\
\;\;\;\;\left(-6 \cdot z\right) \cdot x\\
\mathbf{elif}\;z \leq 0.165:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\left(-6 \cdot x\right) \cdot z\\
\end{array}
\end{array}
if z < -0.165000000000000008Initial program 99.7%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6452.4
Applied rewrites52.4%
Taylor expanded in z around inf
lower-*.f6451.3
Applied rewrites51.3%
if -0.165000000000000008 < z < 0.165000000000000008Initial program 99.5%
Taylor expanded in z around 0
Applied rewrites70.7%
if 0.165000000000000008 < z Initial program 99.8%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6452.8
Applied rewrites52.8%
Taylor expanded in z around inf
*-commutativeN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f6451.9
Applied rewrites51.9%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6451.9
Applied rewrites51.9%
(FPCore (x y z) :precision binary64 (if (<= z -0.165) (* (* z x) -6.0) (if (<= z 0.165) x (* (* -6.0 x) z))))
double code(double x, double y, double z) {
double tmp;
if (z <= -0.165) {
tmp = (z * x) * -6.0;
} else if (z <= 0.165) {
tmp = x;
} 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 <= (-0.165d0)) then
tmp = (z * x) * (-6.0d0)
else if (z <= 0.165d0) then
tmp = x
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 <= -0.165) {
tmp = (z * x) * -6.0;
} else if (z <= 0.165) {
tmp = x;
} else {
tmp = (-6.0 * x) * z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -0.165: tmp = (z * x) * -6.0 elif z <= 0.165: tmp = x else: tmp = (-6.0 * x) * z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -0.165) tmp = Float64(Float64(z * x) * -6.0); elseif (z <= 0.165) tmp = x; else tmp = Float64(Float64(-6.0 * x) * z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -0.165) tmp = (z * x) * -6.0; elseif (z <= 0.165) tmp = x; else tmp = (-6.0 * x) * z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -0.165], N[(N[(z * x), $MachinePrecision] * -6.0), $MachinePrecision], If[LessEqual[z, 0.165], x, N[(N[(-6.0 * x), $MachinePrecision] * z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.165:\\
\;\;\;\;\left(z \cdot x\right) \cdot -6\\
\mathbf{elif}\;z \leq 0.165:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\left(-6 \cdot x\right) \cdot z\\
\end{array}
\end{array}
if z < -0.165000000000000008Initial program 99.7%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6452.4
Applied rewrites52.4%
Taylor expanded in z around inf
*-commutativeN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f6451.3
Applied rewrites51.3%
if -0.165000000000000008 < z < 0.165000000000000008Initial program 99.5%
Taylor expanded in z around 0
Applied rewrites70.7%
if 0.165000000000000008 < z Initial program 99.8%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6452.8
Applied rewrites52.8%
Taylor expanded in z around inf
*-commutativeN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f6451.9
Applied rewrites51.9%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6451.9
Applied rewrites51.9%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* (* -6.0 x) z))) (if (<= z -0.165) t_0 (if (<= z 0.165) x t_0))))
double code(double x, double y, double z) {
double t_0 = (-6.0 * x) * z;
double tmp;
if (z <= -0.165) {
tmp = t_0;
} else if (z <= 0.165) {
tmp = x;
} else {
tmp = t_0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, 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) * x) * z
if (z <= (-0.165d0)) then
tmp = t_0
else if (z <= 0.165d0) then
tmp = x
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (-6.0 * x) * z;
double tmp;
if (z <= -0.165) {
tmp = t_0;
} else if (z <= 0.165) {
tmp = x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (-6.0 * x) * z tmp = 0 if z <= -0.165: tmp = t_0 elif z <= 0.165: tmp = x else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(-6.0 * x) * z) tmp = 0.0 if (z <= -0.165) tmp = t_0; elseif (z <= 0.165) tmp = x; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (-6.0 * x) * z; tmp = 0.0; if (z <= -0.165) tmp = t_0; elseif (z <= 0.165) tmp = x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(-6.0 * x), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[z, -0.165], t$95$0, If[LessEqual[z, 0.165], x, t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(-6 \cdot x\right) \cdot z\\
\mathbf{if}\;z \leq -0.165:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 0.165:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -0.165000000000000008 or 0.165000000000000008 < z Initial program 99.7%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6452.6
Applied rewrites52.6%
Taylor expanded in z around inf
*-commutativeN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f6451.6
Applied rewrites51.6%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6451.6
Applied rewrites51.6%
if -0.165000000000000008 < z < 0.165000000000000008Initial program 99.5%
Taylor expanded in z around 0
Applied rewrites70.7%
(FPCore (x y z) :precision binary64 (fma (- y x) (* z 6.0) x))
double code(double x, double y, double z) {
return fma((y - x), (z * 6.0), x);
}
function code(x, y, z) return fma(Float64(y - x), Float64(z * 6.0), x) end
code[x_, y_, z_] := N[(N[(y - x), $MachinePrecision] * N[(z * 6.0), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y - x, z \cdot 6, x\right)
\end{array}
Initial program 99.6%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lower-+.f64N/A
+-commutativeN/A
associate-*l*N/A
lower-fma.f64N/A
lift--.f64N/A
*-commutativeN/A
lower-*.f6499.8
Applied rewrites99.8%
(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.6%
Taylor expanded in z around 0
Applied rewrites36.8%
(FPCore (x y z) :precision binary64 (- x (* (* 6.0 z) (- x y))))
double code(double x, double y, double z) {
return x - ((6.0 * z) * (x - y));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x - ((6.0d0 * z) * (x - y))
end function
public static double code(double x, double y, double z) {
return x - ((6.0 * z) * (x - y));
}
def code(x, y, z): return x - ((6.0 * z) * (x - y))
function code(x, y, z) return Float64(x - Float64(Float64(6.0 * z) * Float64(x - y))) end
function tmp = code(x, y, z) tmp = x - ((6.0 * z) * (x - y)); end
code[x_, y_, z_] := N[(x - N[(N[(6.0 * z), $MachinePrecision] * N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \left(6 \cdot z\right) \cdot \left(x - y\right)
\end{array}
herbie shell --seed 2025089
(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)))