
(FPCore (x y z) :precision binary64 (+ (+ x (sin y)) (* z (cos y))))
double code(double x, double y, double z) {
return (x + sin(y)) + (z * cos(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 + sin(y)) + (z * cos(y))
end function
public static double code(double x, double y, double z) {
return (x + Math.sin(y)) + (z * Math.cos(y));
}
def code(x, y, z): return (x + math.sin(y)) + (z * math.cos(y))
function code(x, y, z) return Float64(Float64(x + sin(y)) + Float64(z * cos(y))) end
function tmp = code(x, y, z) tmp = (x + sin(y)) + (z * cos(y)); end
code[x_, y_, z_] := N[(N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision] + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + \sin y\right) + z \cdot \cos y
\end{array}
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ (+ x (sin y)) (* z (cos y))))
double code(double x, double y, double z) {
return (x + sin(y)) + (z * cos(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 + sin(y)) + (z * cos(y))
end function
public static double code(double x, double y, double z) {
return (x + Math.sin(y)) + (z * Math.cos(y));
}
def code(x, y, z): return (x + math.sin(y)) + (z * math.cos(y))
function code(x, y, z) return Float64(Float64(x + sin(y)) + Float64(z * cos(y))) end
function tmp = code(x, y, z) tmp = (x + sin(y)) + (z * cos(y)); end
code[x_, y_, z_] := N[(N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision] + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + \sin y\right) + z \cdot \cos y
\end{array}
(FPCore (x y z) :precision binary64 (fma (cos y) z (+ (sin y) x)))
double code(double x, double y, double z) {
return fma(cos(y), z, (sin(y) + x));
}
function code(x, y, z) return fma(cos(y), z, Float64(sin(y) + x)) end
code[x_, y_, z_] := N[(N[Cos[y], $MachinePrecision] * z + N[(N[Sin[y], $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\cos y, z, \sin y + x\right)
\end{array}
Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-rgt-identityN/A
lift-cos.f64N/A
sin-PI/2N/A
lift-cos.f64N/A
sin-PI/2N/A
*-rgt-identityN/A
*-commutativeN/A
*-rgt-identityN/A
lift-cos.f64N/A
sin-PI/2N/A
lift-cos.f64N/A
sin-PI/2N/A
*-rgt-identityN/A
lower-fma.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
Applied rewrites99.9%
(FPCore (x y z) :precision binary64 (if (<= z -2.45e+72) (fma (cos y) z (+ x y)) (if (<= z 1.4e+183) (+ (+ (sin y) z) x) (fma (cos y) z (sin y)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -2.45e+72) {
tmp = fma(cos(y), z, (x + y));
} else if (z <= 1.4e+183) {
tmp = (sin(y) + z) + x;
} else {
tmp = fma(cos(y), z, sin(y));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -2.45e+72) tmp = fma(cos(y), z, Float64(x + y)); elseif (z <= 1.4e+183) tmp = Float64(Float64(sin(y) + z) + x); else tmp = fma(cos(y), z, sin(y)); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -2.45e+72], N[(N[Cos[y], $MachinePrecision] * z + N[(x + y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.4e+183], N[(N[(N[Sin[y], $MachinePrecision] + z), $MachinePrecision] + x), $MachinePrecision], N[(N[Cos[y], $MachinePrecision] * z + N[Sin[y], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.45 \cdot 10^{+72}:\\
\;\;\;\;\mathsf{fma}\left(\cos y, z, x + y\right)\\
\mathbf{elif}\;z \leq 1.4 \cdot 10^{+183}:\\
\;\;\;\;\left(\sin y + z\right) + x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\cos y, z, \sin y\right)\\
\end{array}
\end{array}
if z < -2.45000000000000003e72Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-rgt-identityN/A
lift-cos.f64N/A
sin-PI/2N/A
lift-cos.f64N/A
sin-PI/2N/A
*-rgt-identityN/A
*-commutativeN/A
*-rgt-identityN/A
lift-cos.f64N/A
sin-PI/2N/A
lift-cos.f64N/A
sin-PI/2N/A
*-rgt-identityN/A
lower-fma.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
Applied rewrites99.9%
Taylor expanded in y around 0
lower-+.f6470.7
Applied rewrites70.7%
if -2.45000000000000003e72 < z < 1.40000000000000009e183Initial program 99.9%
Taylor expanded in y around 0
Applied rewrites82.0%
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
+-commutativeN/A
lower-+.f64N/A
lower-+.f6482.0
Applied rewrites82.0%
if 1.40000000000000009e183 < z Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-rgt-identityN/A
lift-cos.f64N/A
sin-PI/2N/A
lift-cos.f64N/A
sin-PI/2N/A
*-rgt-identityN/A
*-commutativeN/A
*-rgt-identityN/A
lift-cos.f64N/A
sin-PI/2N/A
lift-cos.f64N/A
sin-PI/2N/A
*-rgt-identityN/A
lower-fma.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
Applied rewrites99.9%
Taylor expanded in x around 0
lower-sin.f6459.7
Applied rewrites59.7%
(FPCore (x y z) :precision binary64 (let* ((t_0 (fma (cos y) z (+ x y)))) (if (<= z -2.45e+72) t_0 (if (<= z 9e+139) (+ (+ (sin y) z) x) t_0))))
double code(double x, double y, double z) {
double t_0 = fma(cos(y), z, (x + y));
double tmp;
if (z <= -2.45e+72) {
tmp = t_0;
} else if (z <= 9e+139) {
tmp = (sin(y) + z) + x;
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = fma(cos(y), z, Float64(x + y)) tmp = 0.0 if (z <= -2.45e+72) tmp = t_0; elseif (z <= 9e+139) tmp = Float64(Float64(sin(y) + z) + x); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Cos[y], $MachinePrecision] * z + N[(x + y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -2.45e+72], t$95$0, If[LessEqual[z, 9e+139], N[(N[(N[Sin[y], $MachinePrecision] + z), $MachinePrecision] + x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\cos y, z, x + y\right)\\
\mathbf{if}\;z \leq -2.45 \cdot 10^{+72}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 9 \cdot 10^{+139}:\\
\;\;\;\;\left(\sin y + z\right) + x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -2.45000000000000003e72 or 8.9999999999999999e139 < z Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-rgt-identityN/A
lift-cos.f64N/A
sin-PI/2N/A
lift-cos.f64N/A
sin-PI/2N/A
*-rgt-identityN/A
*-commutativeN/A
*-rgt-identityN/A
lift-cos.f64N/A
sin-PI/2N/A
lift-cos.f64N/A
sin-PI/2N/A
*-rgt-identityN/A
lower-fma.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
Applied rewrites99.9%
Taylor expanded in y around 0
lower-+.f6470.7
Applied rewrites70.7%
if -2.45000000000000003e72 < z < 8.9999999999999999e139Initial program 99.9%
Taylor expanded in y around 0
Applied rewrites82.0%
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
+-commutativeN/A
lower-+.f64N/A
lower-+.f6482.0
Applied rewrites82.0%
(FPCore (x y z) :precision binary64 (let* ((t_0 (fma (cos y) z y))) (if (<= z -8e+197) t_0 (if (<= z 1.45e+183) (+ (+ (sin y) z) x) t_0))))
double code(double x, double y, double z) {
double t_0 = fma(cos(y), z, y);
double tmp;
if (z <= -8e+197) {
tmp = t_0;
} else if (z <= 1.45e+183) {
tmp = (sin(y) + z) + x;
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = fma(cos(y), z, y) tmp = 0.0 if (z <= -8e+197) tmp = t_0; elseif (z <= 1.45e+183) tmp = Float64(Float64(sin(y) + z) + x); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Cos[y], $MachinePrecision] * z + y), $MachinePrecision]}, If[LessEqual[z, -8e+197], t$95$0, If[LessEqual[z, 1.45e+183], N[(N[(N[Sin[y], $MachinePrecision] + z), $MachinePrecision] + x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\cos y, z, y\right)\\
\mathbf{if}\;z \leq -8 \cdot 10^{+197}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 1.45 \cdot 10^{+183}:\\
\;\;\;\;\left(\sin y + z\right) + x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -7.9999999999999996e197 or 1.45e183 < z Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-rgt-identityN/A
lift-cos.f64N/A
sin-PI/2N/A
lift-cos.f64N/A
sin-PI/2N/A
*-rgt-identityN/A
*-commutativeN/A
*-rgt-identityN/A
lift-cos.f64N/A
sin-PI/2N/A
lift-cos.f64N/A
sin-PI/2N/A
*-rgt-identityN/A
lower-fma.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
Applied rewrites99.9%
Taylor expanded in y around 0
lower-+.f6470.7
Applied rewrites70.7%
Taylor expanded in x around 0
Applied rewrites39.3%
if -7.9999999999999996e197 < z < 1.45e183Initial program 99.9%
Taylor expanded in y around 0
Applied rewrites82.0%
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
+-commutativeN/A
lower-+.f64N/A
lower-+.f6482.0
Applied rewrites82.0%
(FPCore (x y z) :precision binary64 (if (<= x -470000000.0) (+ x z) (if (<= x 3.7e-9) (+ (sin y) z) (* x (+ 1.0 (/ z x))))))
double code(double x, double y, double z) {
double tmp;
if (x <= -470000000.0) {
tmp = x + z;
} else if (x <= 3.7e-9) {
tmp = sin(y) + z;
} else {
tmp = x * (1.0 + (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 <= (-470000000.0d0)) then
tmp = x + z
else if (x <= 3.7d-9) then
tmp = sin(y) + z
else
tmp = x * (1.0d0 + (z / x))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -470000000.0) {
tmp = x + z;
} else if (x <= 3.7e-9) {
tmp = Math.sin(y) + z;
} else {
tmp = x * (1.0 + (z / x));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -470000000.0: tmp = x + z elif x <= 3.7e-9: tmp = math.sin(y) + z else: tmp = x * (1.0 + (z / x)) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -470000000.0) tmp = Float64(x + z); elseif (x <= 3.7e-9) tmp = Float64(sin(y) + z); else tmp = Float64(x * Float64(1.0 + Float64(z / x))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -470000000.0) tmp = x + z; elseif (x <= 3.7e-9) tmp = sin(y) + z; else tmp = x * (1.0 + (z / x)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -470000000.0], N[(x + z), $MachinePrecision], If[LessEqual[x, 3.7e-9], N[(N[Sin[y], $MachinePrecision] + z), $MachinePrecision], N[(x * N[(1.0 + N[(z / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -470000000:\\
\;\;\;\;x + z\\
\mathbf{elif}\;x \leq 3.7 \cdot 10^{-9}:\\
\;\;\;\;\sin y + z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + \frac{z}{x}\right)\\
\end{array}
\end{array}
if x < -4.7e8Initial program 99.9%
Taylor expanded in y around 0
lower-+.f6465.4
Applied rewrites65.4%
if -4.7e8 < x < 3.7e-9Initial program 99.9%
Taylor expanded in y around 0
Applied rewrites82.0%
Taylor expanded in y around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6453.9
Applied rewrites53.9%
Taylor expanded in x around 0
lower-sin.f6442.4
Applied rewrites42.4%
if 3.7e-9 < x Initial program 99.9%
Taylor expanded in y around 0
lower-+.f6465.4
Applied rewrites65.4%
Taylor expanded in x around inf
lower-*.f64N/A
lower-+.f64N/A
lower-/.f6459.1
Applied rewrites59.1%
(FPCore (x y z)
:precision binary64
(if (<= y -11000000000000.0)
(+ x z)
(if (<= y 4.8)
(+ x (+ z (* y (+ 1.0 (* y (fma -0.5 z (* -0.16666666666666666 y)))))))
(+ x z))))
double code(double x, double y, double z) {
double tmp;
if (y <= -11000000000000.0) {
tmp = x + z;
} else if (y <= 4.8) {
tmp = x + (z + (y * (1.0 + (y * fma(-0.5, z, (-0.16666666666666666 * y))))));
} else {
tmp = x + z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -11000000000000.0) tmp = Float64(x + z); elseif (y <= 4.8) tmp = Float64(x + Float64(z + Float64(y * Float64(1.0 + Float64(y * fma(-0.5, z, Float64(-0.16666666666666666 * y))))))); else tmp = Float64(x + z); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -11000000000000.0], N[(x + z), $MachinePrecision], If[LessEqual[y, 4.8], N[(x + N[(z + N[(y * N[(1.0 + N[(y * N[(-0.5 * z + N[(-0.16666666666666666 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -11000000000000:\\
\;\;\;\;x + z\\
\mathbf{elif}\;y \leq 4.8:\\
\;\;\;\;x + \left(z + y \cdot \left(1 + y \cdot \mathsf{fma}\left(-0.5, z, -0.16666666666666666 \cdot y\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + z\\
\end{array}
\end{array}
if y < -1.1e13 or 4.79999999999999982 < y Initial program 99.9%
Taylor expanded in y around 0
lower-+.f6465.4
Applied rewrites65.4%
if -1.1e13 < y < 4.79999999999999982Initial program 99.9%
Taylor expanded in y around 0
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-fma.f64N/A
lower-*.f6453.4
Applied rewrites53.4%
(FPCore (x y z)
:precision binary64
(if (<= y -1.55e+31)
(+ x z)
(if (<= y 6.2)
(+ (+ x (* y (fma (* -0.16666666666666666 y) y 1.0))) z)
(+ x z))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.55e+31) {
tmp = x + z;
} else if (y <= 6.2) {
tmp = (x + (y * fma((-0.16666666666666666 * y), y, 1.0))) + z;
} else {
tmp = x + z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -1.55e+31) tmp = Float64(x + z); elseif (y <= 6.2) tmp = Float64(Float64(x + Float64(y * fma(Float64(-0.16666666666666666 * y), y, 1.0))) + z); else tmp = Float64(x + z); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -1.55e+31], N[(x + z), $MachinePrecision], If[LessEqual[y, 6.2], N[(N[(x + N[(y * N[(N[(-0.16666666666666666 * y), $MachinePrecision] * y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision], N[(x + z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.55 \cdot 10^{+31}:\\
\;\;\;\;x + z\\
\mathbf{elif}\;y \leq 6.2:\\
\;\;\;\;\left(x + y \cdot \mathsf{fma}\left(-0.16666666666666666 \cdot y, y, 1\right)\right) + z\\
\mathbf{else}:\\
\;\;\;\;x + z\\
\end{array}
\end{array}
if y < -1.5500000000000001e31 or 6.20000000000000018 < y Initial program 99.9%
Taylor expanded in y around 0
lower-+.f6465.4
Applied rewrites65.4%
if -1.5500000000000001e31 < y < 6.20000000000000018Initial program 99.9%
Taylor expanded in y around 0
Applied rewrites82.0%
Taylor expanded in y around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6453.9
Applied rewrites53.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6453.9
Applied rewrites53.9%
(FPCore (x y z)
:precision binary64
(if (<= y -1.2e+15)
(+ x z)
(if (<= y 48000000000000.0)
(+ y (fma (fma (* y y) -0.5 1.0) z x))
(+ x z))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.2e+15) {
tmp = x + z;
} else if (y <= 48000000000000.0) {
tmp = y + fma(fma((y * y), -0.5, 1.0), z, x);
} else {
tmp = x + z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -1.2e+15) tmp = Float64(x + z); elseif (y <= 48000000000000.0) tmp = Float64(y + fma(fma(Float64(y * y), -0.5, 1.0), z, x)); else tmp = Float64(x + z); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -1.2e+15], N[(x + z), $MachinePrecision], If[LessEqual[y, 48000000000000.0], N[(y + N[(N[(N[(y * y), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision] * z + x), $MachinePrecision]), $MachinePrecision], N[(x + z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.2 \cdot 10^{+15}:\\
\;\;\;\;x + z\\
\mathbf{elif}\;y \leq 48000000000000:\\
\;\;\;\;y + \mathsf{fma}\left(\mathsf{fma}\left(y \cdot y, -0.5, 1\right), z, x\right)\\
\mathbf{else}:\\
\;\;\;\;x + z\\
\end{array}
\end{array}
if y < -1.2e15 or 4.8e13 < y Initial program 99.9%
Taylor expanded in y around 0
lower-+.f6465.4
Applied rewrites65.4%
if -1.2e15 < y < 4.8e13Initial program 99.9%
Taylor expanded in y around 0
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6456.7
Applied rewrites56.7%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-+.f64N/A
distribute-lft-inN/A
*-rgt-identityN/A
+-commutativeN/A
+-commutativeN/A
associate-+l+N/A
associate-+l+N/A
lower-+.f64N/A
Applied rewrites55.8%
(FPCore (x y z) :precision binary64 (if (<= y -2.15e+33) (+ x z) (if (<= y 70000000000000.0) (+ x (+ y z)) (+ x z))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.15e+33) {
tmp = x + z;
} else if (y <= 70000000000000.0) {
tmp = x + (y + z);
} else {
tmp = 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 (y <= (-2.15d+33)) then
tmp = x + z
else if (y <= 70000000000000.0d0) then
tmp = x + (y + z)
else
tmp = x + z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -2.15e+33) {
tmp = x + z;
} else if (y <= 70000000000000.0) {
tmp = x + (y + z);
} else {
tmp = x + z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.15e+33: tmp = x + z elif y <= 70000000000000.0: tmp = x + (y + z) else: tmp = x + z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.15e+33) tmp = Float64(x + z); elseif (y <= 70000000000000.0) tmp = Float64(x + Float64(y + z)); else tmp = Float64(x + z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2.15e+33) tmp = x + z; elseif (y <= 70000000000000.0) tmp = x + (y + z); else tmp = x + z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.15e+33], N[(x + z), $MachinePrecision], If[LessEqual[y, 70000000000000.0], N[(x + N[(y + z), $MachinePrecision]), $MachinePrecision], N[(x + z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.15 \cdot 10^{+33}:\\
\;\;\;\;x + z\\
\mathbf{elif}\;y \leq 70000000000000:\\
\;\;\;\;x + \left(y + z\right)\\
\mathbf{else}:\\
\;\;\;\;x + z\\
\end{array}
\end{array}
if y < -2.15000000000000014e33 or 7e13 < y Initial program 99.9%
Taylor expanded in y around 0
lower-+.f6465.4
Applied rewrites65.4%
if -2.15000000000000014e33 < y < 7e13Initial program 99.9%
Taylor expanded in y around 0
lower-+.f64N/A
lower-+.f6461.1
Applied rewrites61.1%
(FPCore (x y z) :precision binary64 (if (<= x -1.12e-114) (+ x z) (if (<= x 2.15e-135) (+ y z) (+ x z))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.12e-114) {
tmp = x + z;
} else if (x <= 2.15e-135) {
tmp = y + z;
} else {
tmp = 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 (x <= (-1.12d-114)) then
tmp = x + z
else if (x <= 2.15d-135) then
tmp = y + z
else
tmp = x + z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -1.12e-114) {
tmp = x + z;
} else if (x <= 2.15e-135) {
tmp = y + z;
} else {
tmp = x + z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.12e-114: tmp = x + z elif x <= 2.15e-135: tmp = y + z else: tmp = x + z return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.12e-114) tmp = Float64(x + z); elseif (x <= 2.15e-135) tmp = Float64(y + z); else tmp = Float64(x + z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.12e-114) tmp = x + z; elseif (x <= 2.15e-135) tmp = y + z; else tmp = x + z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.12e-114], N[(x + z), $MachinePrecision], If[LessEqual[x, 2.15e-135], N[(y + z), $MachinePrecision], N[(x + z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.12 \cdot 10^{-114}:\\
\;\;\;\;x + z\\
\mathbf{elif}\;x \leq 2.15 \cdot 10^{-135}:\\
\;\;\;\;y + z\\
\mathbf{else}:\\
\;\;\;\;x + z\\
\end{array}
\end{array}
if x < -1.11999999999999995e-114 or 2.14999999999999999e-135 < x Initial program 99.9%
Taylor expanded in y around 0
lower-+.f6465.4
Applied rewrites65.4%
if -1.11999999999999995e-114 < x < 2.14999999999999999e-135Initial program 99.9%
Taylor expanded in y around 0
Applied rewrites82.0%
Taylor expanded in y around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6453.9
Applied rewrites53.9%
Taylor expanded in y around 0
lower-+.f6461.1
Applied rewrites61.1%
Taylor expanded in x around 0
Applied rewrites29.9%
(FPCore (x y z) :precision binary64 (+ x z))
double code(double x, double y, double z) {
return x + z;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x + z
end function
public static double code(double x, double y, double z) {
return x + z;
}
def code(x, y, z): return x + z
function code(x, y, z) return Float64(x + z) end
function tmp = code(x, y, z) tmp = x + z; end
code[x_, y_, z_] := N[(x + z), $MachinePrecision]
\begin{array}{l}
\\
x + z
\end{array}
Initial program 99.9%
Taylor expanded in y around 0
lower-+.f6465.4
Applied rewrites65.4%
(FPCore (x y z) :precision binary64 z)
double code(double x, double y, double z) {
return 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 = z
end function
public static double code(double x, double y, double z) {
return z;
}
def code(x, y, z): return z
function code(x, y, z) return z end
function tmp = code(x, y, z) tmp = z; end
code[x_, y_, z_] := z
\begin{array}{l}
\\
z
\end{array}
Initial program 99.9%
Taylor expanded in y around 0
lower-+.f6465.4
Applied rewrites65.4%
Taylor expanded in x around 0
Applied rewrites26.4%
herbie shell --seed 2025156
(FPCore (x y z)
:name "Graphics.Rasterific.Svg.PathConverter:segmentToBezier from rasterific-svg-0.2.3.1, C"
:precision binary64
(+ (+ x (sin y)) (* z (cos y))))