
(FPCore (x y z) :precision binary64 (+ (* x (+ y z)) (* z 5.0)))
double code(double x, double y, double z) {
return (x * (y + z)) + (z * 5.0);
}
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)) + (z * 5.0d0)
end function
public static double code(double x, double y, double z) {
return (x * (y + z)) + (z * 5.0);
}
def code(x, y, z): return (x * (y + z)) + (z * 5.0)
function code(x, y, z) return Float64(Float64(x * Float64(y + z)) + Float64(z * 5.0)) end
function tmp = code(x, y, z) tmp = (x * (y + z)) + (z * 5.0); end
code[x_, y_, z_] := N[(N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision] + N[(z * 5.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(y + z\right) + z \cdot 5
\end{array}
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ (* x (+ y z)) (* z 5.0)))
double code(double x, double y, double z) {
return (x * (y + z)) + (z * 5.0);
}
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)) + (z * 5.0d0)
end function
public static double code(double x, double y, double z) {
return (x * (y + z)) + (z * 5.0);
}
def code(x, y, z): return (x * (y + z)) + (z * 5.0)
function code(x, y, z) return Float64(Float64(x * Float64(y + z)) + Float64(z * 5.0)) end
function tmp = code(x, y, z) tmp = (x * (y + z)) + (z * 5.0); end
code[x_, y_, z_] := N[(N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision] + N[(z * 5.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(y + z\right) + z \cdot 5
\end{array}
(FPCore (x y z) :precision binary64 (fma y x (* (- x -5.0) z)))
double code(double x, double y, double z) {
return fma(y, x, ((x - -5.0) * z));
}
function code(x, y, z) return fma(y, x, Float64(Float64(x - -5.0) * z)) end
code[x_, y_, z_] := N[(y * x + N[(N[(x - -5.0), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y, x, \left(x - -5\right) \cdot z\right)
\end{array}
Initial program 99.9%
Applied rewrites98.9%
(FPCore (x y z) :precision binary64 (if (<= x -90.0) (* (+ z y) x) (if (<= x 5.0) (fma y x (* 5.0 z)) (fma y x (* z x)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -90.0) {
tmp = (z + y) * x;
} else if (x <= 5.0) {
tmp = fma(y, x, (5.0 * z));
} else {
tmp = fma(y, x, (z * x));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= -90.0) tmp = Float64(Float64(z + y) * x); elseif (x <= 5.0) tmp = fma(y, x, Float64(5.0 * z)); else tmp = fma(y, x, Float64(z * x)); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, -90.0], N[(N[(z + y), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[x, 5.0], N[(y * x + N[(5.0 * z), $MachinePrecision]), $MachinePrecision], N[(y * x + N[(z * x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -90:\\
\;\;\;\;\left(z + y\right) \cdot x\\
\mathbf{elif}\;x \leq 5:\\
\;\;\;\;\mathsf{fma}\left(y, x, 5 \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, x, z \cdot x\right)\\
\end{array}
\end{array}
if x < -90Initial program 99.9%
Applied rewrites98.9%
Taylor expanded in x around -inf
*-commutativeN/A
*-commutativeN/A
sub-flipN/A
metadata-evalN/A
distribute-rgt-outN/A
associate-+l+N/A
distribute-lft-outN/A
*-commutativeN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
distribute-lft-outN/A
mul-1-negN/A
+-commutativeN/A
remove-double-negN/A
*-commutativeN/A
lift-+.f64N/A
lift-*.f6464.6
Applied rewrites64.6%
if -90 < x < 5Initial program 99.9%
Applied rewrites98.9%
Taylor expanded in x around 0
Applied rewrites76.0%
if 5 < x Initial program 99.9%
Applied rewrites98.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6463.6
Applied rewrites63.6%
(FPCore (x y z) :precision binary64 (if (<= x -2.7e-40) (* (+ z y) x) (if (<= x 45.0) (* (- x -5.0) z) (fma y x (* z x)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -2.7e-40) {
tmp = (z + y) * x;
} else if (x <= 45.0) {
tmp = (x - -5.0) * z;
} else {
tmp = fma(y, x, (z * x));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= -2.7e-40) tmp = Float64(Float64(z + y) * x); elseif (x <= 45.0) tmp = Float64(Float64(x - -5.0) * z); else tmp = fma(y, x, Float64(z * x)); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, -2.7e-40], N[(N[(z + y), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[x, 45.0], N[(N[(x - -5.0), $MachinePrecision] * z), $MachinePrecision], N[(y * x + N[(z * x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.7 \cdot 10^{-40}:\\
\;\;\;\;\left(z + y\right) \cdot x\\
\mathbf{elif}\;x \leq 45:\\
\;\;\;\;\left(x - -5\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, x, z \cdot x\right)\\
\end{array}
\end{array}
if x < -2.7e-40Initial program 99.9%
Applied rewrites98.9%
Taylor expanded in x around -inf
*-commutativeN/A
*-commutativeN/A
sub-flipN/A
metadata-evalN/A
distribute-rgt-outN/A
associate-+l+N/A
distribute-lft-outN/A
*-commutativeN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
distribute-lft-outN/A
mul-1-negN/A
+-commutativeN/A
remove-double-negN/A
*-commutativeN/A
lift-+.f64N/A
lift-*.f6464.6
Applied rewrites64.6%
if -2.7e-40 < x < 45Initial program 99.9%
Taylor expanded in y around 0
distribute-rgt-outN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f6462.0
Applied rewrites62.0%
if 45 < x Initial program 99.9%
Applied rewrites98.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6463.6
Applied rewrites63.6%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* (+ z y) x))) (if (<= x -2.7e-40) t_0 (if (<= x 45.0) (* (- x -5.0) z) t_0))))
double code(double x, double y, double z) {
double t_0 = (z + y) * x;
double tmp;
if (x <= -2.7e-40) {
tmp = t_0;
} else if (x <= 45.0) {
tmp = (x - -5.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 = (z + y) * x
if (x <= (-2.7d-40)) then
tmp = t_0
else if (x <= 45.0d0) then
tmp = (x - (-5.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 = (z + y) * x;
double tmp;
if (x <= -2.7e-40) {
tmp = t_0;
} else if (x <= 45.0) {
tmp = (x - -5.0) * z;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (z + y) * x tmp = 0 if x <= -2.7e-40: tmp = t_0 elif x <= 45.0: tmp = (x - -5.0) * z else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(z + y) * x) tmp = 0.0 if (x <= -2.7e-40) tmp = t_0; elseif (x <= 45.0) tmp = Float64(Float64(x - -5.0) * z); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (z + y) * x; tmp = 0.0; if (x <= -2.7e-40) tmp = t_0; elseif (x <= 45.0) tmp = (x - -5.0) * z; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(z + y), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[x, -2.7e-40], t$95$0, If[LessEqual[x, 45.0], N[(N[(x - -5.0), $MachinePrecision] * z), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(z + y\right) \cdot x\\
\mathbf{if}\;x \leq -2.7 \cdot 10^{-40}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 45:\\
\;\;\;\;\left(x - -5\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -2.7e-40 or 45 < x Initial program 99.9%
Applied rewrites98.9%
Taylor expanded in x around -inf
*-commutativeN/A
*-commutativeN/A
sub-flipN/A
metadata-evalN/A
distribute-rgt-outN/A
associate-+l+N/A
distribute-lft-outN/A
*-commutativeN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
distribute-lft-outN/A
mul-1-negN/A
+-commutativeN/A
remove-double-negN/A
*-commutativeN/A
lift-+.f64N/A
lift-*.f6464.6
Applied rewrites64.6%
if -2.7e-40 < x < 45Initial program 99.9%
Taylor expanded in y around 0
distribute-rgt-outN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f6462.0
Applied rewrites62.0%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* (- x -5.0) z))) (if (<= z -4.7e-122) t_0 (if (<= z 2.8e-15) (* y x) t_0))))
double code(double x, double y, double z) {
double t_0 = (x - -5.0) * z;
double tmp;
if (z <= -4.7e-122) {
tmp = t_0;
} else if (z <= 2.8e-15) {
tmp = y * 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 = (x - (-5.0d0)) * z
if (z <= (-4.7d-122)) then
tmp = t_0
else if (z <= 2.8d-15) then
tmp = y * x
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x - -5.0) * z;
double tmp;
if (z <= -4.7e-122) {
tmp = t_0;
} else if (z <= 2.8e-15) {
tmp = y * x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (x - -5.0) * z tmp = 0 if z <= -4.7e-122: tmp = t_0 elif z <= 2.8e-15: tmp = y * x else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(x - -5.0) * z) tmp = 0.0 if (z <= -4.7e-122) tmp = t_0; elseif (z <= 2.8e-15) tmp = Float64(y * x); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x - -5.0) * z; tmp = 0.0; if (z <= -4.7e-122) tmp = t_0; elseif (z <= 2.8e-15) tmp = y * x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x - -5.0), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[z, -4.7e-122], t$95$0, If[LessEqual[z, 2.8e-15], N[(y * x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x - -5\right) \cdot z\\
\mathbf{if}\;z \leq -4.7 \cdot 10^{-122}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 2.8 \cdot 10^{-15}:\\
\;\;\;\;y \cdot x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -4.6999999999999999e-122 or 2.80000000000000014e-15 < z Initial program 99.9%
Taylor expanded in y around 0
distribute-rgt-outN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f6462.0
Applied rewrites62.0%
if -4.6999999999999999e-122 < z < 2.80000000000000014e-15Initial program 99.9%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f6441.3
Applied rewrites41.3%
(FPCore (x y z)
:precision binary64
(if (<= x -2.7e-40)
(* y x)
(if (<= x 0.88)
(* 5.0 z)
(if (<= x 2.7e+39) (* y x) (if (<= x 5.4e+203) (* z x) (* y x))))))
double code(double x, double y, double z) {
double tmp;
if (x <= -2.7e-40) {
tmp = y * x;
} else if (x <= 0.88) {
tmp = 5.0 * z;
} else if (x <= 2.7e+39) {
tmp = y * x;
} else if (x <= 5.4e+203) {
tmp = z * x;
} else {
tmp = y * 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 (x <= (-2.7d-40)) then
tmp = y * x
else if (x <= 0.88d0) then
tmp = 5.0d0 * z
else if (x <= 2.7d+39) then
tmp = y * x
else if (x <= 5.4d+203) then
tmp = z * x
else
tmp = y * x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -2.7e-40) {
tmp = y * x;
} else if (x <= 0.88) {
tmp = 5.0 * z;
} else if (x <= 2.7e+39) {
tmp = y * x;
} else if (x <= 5.4e+203) {
tmp = z * x;
} else {
tmp = y * x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -2.7e-40: tmp = y * x elif x <= 0.88: tmp = 5.0 * z elif x <= 2.7e+39: tmp = y * x elif x <= 5.4e+203: tmp = z * x else: tmp = y * x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -2.7e-40) tmp = Float64(y * x); elseif (x <= 0.88) tmp = Float64(5.0 * z); elseif (x <= 2.7e+39) tmp = Float64(y * x); elseif (x <= 5.4e+203) tmp = Float64(z * x); else tmp = Float64(y * x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -2.7e-40) tmp = y * x; elseif (x <= 0.88) tmp = 5.0 * z; elseif (x <= 2.7e+39) tmp = y * x; elseif (x <= 5.4e+203) tmp = z * x; else tmp = y * x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -2.7e-40], N[(y * x), $MachinePrecision], If[LessEqual[x, 0.88], N[(5.0 * z), $MachinePrecision], If[LessEqual[x, 2.7e+39], N[(y * x), $MachinePrecision], If[LessEqual[x, 5.4e+203], N[(z * x), $MachinePrecision], N[(y * x), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.7 \cdot 10^{-40}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;x \leq 0.88:\\
\;\;\;\;5 \cdot z\\
\mathbf{elif}\;x \leq 2.7 \cdot 10^{+39}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;x \leq 5.4 \cdot 10^{+203}:\\
\;\;\;\;z \cdot x\\
\mathbf{else}:\\
\;\;\;\;y \cdot x\\
\end{array}
\end{array}
if x < -2.7e-40 or 0.880000000000000004 < x < 2.70000000000000003e39 or 5.4000000000000001e203 < x Initial program 99.9%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f6441.3
Applied rewrites41.3%
if -2.7e-40 < x < 0.880000000000000004Initial program 99.9%
Taylor expanded in x around 0
lower-*.f6436.9
Applied rewrites36.9%
if 2.70000000000000003e39 < x < 5.4000000000000001e203Initial program 99.9%
Taylor expanded in y around 0
distribute-rgt-outN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f6462.0
Applied rewrites62.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6427.4
Applied rewrites27.4%
(FPCore (x y z) :precision binary64 (if (<= x -90.0) (* z x) (if (<= x 5.0) (* 5.0 z) (* z x))))
double code(double x, double y, double z) {
double tmp;
if (x <= -90.0) {
tmp = z * x;
} else if (x <= 5.0) {
tmp = 5.0 * z;
} else {
tmp = z * 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 (x <= (-90.0d0)) then
tmp = z * x
else if (x <= 5.0d0) then
tmp = 5.0d0 * z
else
tmp = z * x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -90.0) {
tmp = z * x;
} else if (x <= 5.0) {
tmp = 5.0 * z;
} else {
tmp = z * x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -90.0: tmp = z * x elif x <= 5.0: tmp = 5.0 * z else: tmp = z * x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -90.0) tmp = Float64(z * x); elseif (x <= 5.0) tmp = Float64(5.0 * z); else tmp = Float64(z * x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -90.0) tmp = z * x; elseif (x <= 5.0) tmp = 5.0 * z; else tmp = z * x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -90.0], N[(z * x), $MachinePrecision], If[LessEqual[x, 5.0], N[(5.0 * z), $MachinePrecision], N[(z * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -90:\\
\;\;\;\;z \cdot x\\
\mathbf{elif}\;x \leq 5:\\
\;\;\;\;5 \cdot z\\
\mathbf{else}:\\
\;\;\;\;z \cdot x\\
\end{array}
\end{array}
if x < -90 or 5 < x Initial program 99.9%
Taylor expanded in y around 0
distribute-rgt-outN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f6462.0
Applied rewrites62.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6427.4
Applied rewrites27.4%
if -90 < x < 5Initial program 99.9%
Taylor expanded in x around 0
lower-*.f6436.9
Applied rewrites36.9%
(FPCore (x y z) :precision binary64 (* z x))
double code(double x, double y, double z) {
return z * 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 = z * x
end function
public static double code(double x, double y, double z) {
return z * x;
}
def code(x, y, z): return z * x
function code(x, y, z) return Float64(z * x) end
function tmp = code(x, y, z) tmp = z * x; end
code[x_, y_, z_] := N[(z * x), $MachinePrecision]
\begin{array}{l}
\\
z \cdot x
\end{array}
Initial program 99.9%
Taylor expanded in y around 0
distribute-rgt-outN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f6462.0
Applied rewrites62.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6427.4
Applied rewrites27.4%
herbie shell --seed 2025136
(FPCore (x y z)
:name "Graphics.Rendering.Plot.Render.Plot.Legend:renderLegendOutside from plot-0.2.3.4, C"
:precision binary64
(+ (* x (+ y z)) (* z 5.0)))