
(FPCore (x y z) :precision binary64 (- (+ x (cos y)) (* z (sin y))))
double code(double x, double y, double z) {
return (x + cos(y)) - (z * sin(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 + cos(y)) - (z * sin(y))
end function
public static double code(double x, double y, double z) {
return (x + Math.cos(y)) - (z * Math.sin(y));
}
def code(x, y, z): return (x + math.cos(y)) - (z * math.sin(y))
function code(x, y, z) return Float64(Float64(x + cos(y)) - Float64(z * sin(y))) end
function tmp = code(x, y, z) tmp = (x + cos(y)) - (z * sin(y)); end
code[x_, y_, z_] := N[(N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision] - N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + \cos y\right) - z \cdot \sin y
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 16 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (- (+ x (cos y)) (* z (sin y))))
double code(double x, double y, double z) {
return (x + cos(y)) - (z * sin(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 + cos(y)) - (z * sin(y))
end function
public static double code(double x, double y, double z) {
return (x + Math.cos(y)) - (z * Math.sin(y));
}
def code(x, y, z): return (x + math.cos(y)) - (z * math.sin(y))
function code(x, y, z) return Float64(Float64(x + cos(y)) - Float64(z * sin(y))) end
function tmp = code(x, y, z) tmp = (x + cos(y)) - (z * sin(y)); end
code[x_, y_, z_] := N[(N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision] - N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + \cos y\right) - z \cdot \sin y
\end{array}
(FPCore (x y z) :precision binary64 (fma (sin y) (- z) (+ (cos y) x)))
double code(double x, double y, double z) {
return fma(sin(y), -z, (cos(y) + x));
}
function code(x, y, z) return fma(sin(y), Float64(-z), Float64(cos(y) + x)) end
code[x_, y_, z_] := N[(N[Sin[y], $MachinePrecision] * (-z) + N[(N[Cos[y], $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\sin y, -z, \cos y + x\right)
\end{array}
Initial program 99.9%
lift--.f64N/A
lift-+.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
associate-+r+N/A
+-commutativeN/A
+-commutativeN/A
associate-+l+N/A
mul-1-negN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
+-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lower-neg.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-cos.f6499.9
Applied rewrites99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (+ x (cos y)) (* z (sin y)))) (t_1 (- x (fma z y -1.0))))
(if (<= t_0 -2700000000000.0)
t_1
(if (<= t_0 0.99999) (cos y) (if (<= t_0 1.2e+188) t_1 (- x -1.0))))))
double code(double x, double y, double z) {
double t_0 = (x + cos(y)) - (z * sin(y));
double t_1 = x - fma(z, y, -1.0);
double tmp;
if (t_0 <= -2700000000000.0) {
tmp = t_1;
} else if (t_0 <= 0.99999) {
tmp = cos(y);
} else if (t_0 <= 1.2e+188) {
tmp = t_1;
} else {
tmp = x - -1.0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(x + cos(y)) - Float64(z * sin(y))) t_1 = Float64(x - fma(z, y, -1.0)) tmp = 0.0 if (t_0 <= -2700000000000.0) tmp = t_1; elseif (t_0 <= 0.99999) tmp = cos(y); elseif (t_0 <= 1.2e+188) tmp = t_1; else tmp = Float64(x - -1.0); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision] - N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x - N[(z * y + -1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -2700000000000.0], t$95$1, If[LessEqual[t$95$0, 0.99999], N[Cos[y], $MachinePrecision], If[LessEqual[t$95$0, 1.2e+188], t$95$1, N[(x - -1.0), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x + \cos y\right) - z \cdot \sin y\\
t_1 := x - \mathsf{fma}\left(z, y, -1\right)\\
\mathbf{if}\;t\_0 \leq -2700000000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 0.99999:\\
\;\;\;\;\cos y\\
\mathbf{elif}\;t\_0 \leq 1.2 \cdot 10^{+188}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;x - -1\\
\end{array}
\end{array}
if (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) < -2.7e12 or 0.999990000000000046 < (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) < 1.2e188Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f64N/A
metadata-evalN/A
fp-cancel-sub-sign-invN/A
*-lft-identityN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6477.3
Applied rewrites77.3%
lift--.f64N/A
lift--.f64N/A
associate--l-N/A
lower--.f64N/A
lift-*.f64N/A
lower-fma.f6477.3
Applied rewrites77.3%
if -2.7e12 < (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) < 0.999990000000000046Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
lift-cos.f6494.7
Applied rewrites94.7%
Taylor expanded in x around 0
lift-cos.f6494.7
Applied rewrites94.7%
if 1.2e188 < (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f6461.6
Applied rewrites61.6%
Final simplification77.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (sin y))) (t_1 (- (+ x (cos y)) t_0)))
(if (or (<= t_1 -2000000000000.0) (not (<= t_1 1e+14)))
(- x t_0)
(+ (cos y) x))))
double code(double x, double y, double z) {
double t_0 = z * sin(y);
double t_1 = (x + cos(y)) - t_0;
double tmp;
if ((t_1 <= -2000000000000.0) || !(t_1 <= 1e+14)) {
tmp = x - t_0;
} else {
tmp = cos(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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = z * sin(y)
t_1 = (x + cos(y)) - t_0
if ((t_1 <= (-2000000000000.0d0)) .or. (.not. (t_1 <= 1d+14))) then
tmp = x - t_0
else
tmp = cos(y) + x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = z * Math.sin(y);
double t_1 = (x + Math.cos(y)) - t_0;
double tmp;
if ((t_1 <= -2000000000000.0) || !(t_1 <= 1e+14)) {
tmp = x - t_0;
} else {
tmp = Math.cos(y) + x;
}
return tmp;
}
def code(x, y, z): t_0 = z * math.sin(y) t_1 = (x + math.cos(y)) - t_0 tmp = 0 if (t_1 <= -2000000000000.0) or not (t_1 <= 1e+14): tmp = x - t_0 else: tmp = math.cos(y) + x return tmp
function code(x, y, z) t_0 = Float64(z * sin(y)) t_1 = Float64(Float64(x + cos(y)) - t_0) tmp = 0.0 if ((t_1 <= -2000000000000.0) || !(t_1 <= 1e+14)) tmp = Float64(x - t_0); else tmp = Float64(cos(y) + x); end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * sin(y); t_1 = (x + cos(y)) - t_0; tmp = 0.0; if ((t_1 <= -2000000000000.0) || ~((t_1 <= 1e+14))) tmp = x - t_0; else tmp = cos(y) + x; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -2000000000000.0], N[Not[LessEqual[t$95$1, 1e+14]], $MachinePrecision]], N[(x - t$95$0), $MachinePrecision], N[(N[Cos[y], $MachinePrecision] + x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \sin y\\
t_1 := \left(x + \cos y\right) - t\_0\\
\mathbf{if}\;t\_1 \leq -2000000000000 \lor \neg \left(t\_1 \leq 10^{+14}\right):\\
\;\;\;\;x - t\_0\\
\mathbf{else}:\\
\;\;\;\;\cos y + x\\
\end{array}
\end{array}
if (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) < -2e12 or 1e14 < (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) Initial program 99.9%
Taylor expanded in x around inf
Applied rewrites99.6%
if -2e12 < (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) < 1e14Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
lift-cos.f6498.2
Applied rewrites98.2%
Final simplification99.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (sin y))) (t_1 (- (+ x (cos y)) t_0)))
(if (<= t_1 -2000000000000.0)
(fma (sin y) (- z) x)
(if (<= t_1 1e+14) (+ (cos y) x) (- x t_0)))))
double code(double x, double y, double z) {
double t_0 = z * sin(y);
double t_1 = (x + cos(y)) - t_0;
double tmp;
if (t_1 <= -2000000000000.0) {
tmp = fma(sin(y), -z, x);
} else if (t_1 <= 1e+14) {
tmp = cos(y) + x;
} else {
tmp = x - t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(z * sin(y)) t_1 = Float64(Float64(x + cos(y)) - t_0) tmp = 0.0 if (t_1 <= -2000000000000.0) tmp = fma(sin(y), Float64(-z), x); elseif (t_1 <= 1e+14) tmp = Float64(cos(y) + x); else tmp = Float64(x - t_0); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]}, If[LessEqual[t$95$1, -2000000000000.0], N[(N[Sin[y], $MachinePrecision] * (-z) + x), $MachinePrecision], If[LessEqual[t$95$1, 1e+14], N[(N[Cos[y], $MachinePrecision] + x), $MachinePrecision], N[(x - t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \sin y\\
t_1 := \left(x + \cos y\right) - t\_0\\
\mathbf{if}\;t\_1 \leq -2000000000000:\\
\;\;\;\;\mathsf{fma}\left(\sin y, -z, x\right)\\
\mathbf{elif}\;t\_1 \leq 10^{+14}:\\
\;\;\;\;\cos y + x\\
\mathbf{else}:\\
\;\;\;\;x - t\_0\\
\end{array}
\end{array}
if (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) < -2e12Initial program 99.9%
lift--.f64N/A
lift-+.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
associate-+r+N/A
+-commutativeN/A
+-commutativeN/A
associate-+l+N/A
mul-1-negN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
+-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lower-neg.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-cos.f6499.9
Applied rewrites99.9%
Taylor expanded in x around inf
Applied rewrites99.3%
if -2e12 < (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) < 1e14Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
lift-cos.f6498.2
Applied rewrites98.2%
if 1e14 < (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) Initial program 99.9%
Taylor expanded in x around inf
Applied rewrites99.9%
Final simplification99.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (sin y))))
(if (<= x -1.0)
(- x t_0)
(if (<= x 0.122) (- (cos y) t_0) (fma (sin y) (- z) x)))))
double code(double x, double y, double z) {
double t_0 = z * sin(y);
double tmp;
if (x <= -1.0) {
tmp = x - t_0;
} else if (x <= 0.122) {
tmp = cos(y) - t_0;
} else {
tmp = fma(sin(y), -z, x);
}
return tmp;
}
function code(x, y, z) t_0 = Float64(z * sin(y)) tmp = 0.0 if (x <= -1.0) tmp = Float64(x - t_0); elseif (x <= 0.122) tmp = Float64(cos(y) - t_0); else tmp = fma(sin(y), Float64(-z), x); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.0], N[(x - t$95$0), $MachinePrecision], If[LessEqual[x, 0.122], N[(N[Cos[y], $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[Sin[y], $MachinePrecision] * (-z) + x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \sin y\\
\mathbf{if}\;x \leq -1:\\
\;\;\;\;x - t\_0\\
\mathbf{elif}\;x \leq 0.122:\\
\;\;\;\;\cos y - t\_0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\sin y, -z, x\right)\\
\end{array}
\end{array}
if x < -1Initial program 100.0%
Taylor expanded in x around inf
Applied rewrites99.7%
if -1 < x < 0.122Initial program 99.9%
Taylor expanded in x around 0
lift-cos.f6499.3
Applied rewrites99.3%
if 0.122 < x Initial program 100.0%
lift--.f64N/A
lift-+.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
associate-+r+N/A
+-commutativeN/A
+-commutativeN/A
associate-+l+N/A
mul-1-negN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
+-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lower-neg.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-cos.f64100.0
Applied rewrites100.0%
Taylor expanded in x around inf
Applied rewrites98.4%
Final simplification99.2%
(FPCore (x y z) :precision binary64 (- (+ x (cos y)) (* z (sin y))))
double code(double x, double y, double z) {
return (x + cos(y)) - (z * sin(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 + cos(y)) - (z * sin(y))
end function
public static double code(double x, double y, double z) {
return (x + Math.cos(y)) - (z * Math.sin(y));
}
def code(x, y, z): return (x + math.cos(y)) - (z * math.sin(y))
function code(x, y, z) return Float64(Float64(x + cos(y)) - Float64(z * sin(y))) end
function tmp = code(x, y, z) tmp = (x + cos(y)) - (z * sin(y)); end
code[x_, y_, z_] := N[(N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision] - N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + \cos y\right) - z \cdot \sin y
\end{array}
Initial program 99.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -5.5e+206) (not (<= z 1.45e+66))) (* (- z) (sin y)) (+ (cos y) x)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -5.5e+206) || !(z <= 1.45e+66)) {
tmp = -z * sin(y);
} else {
tmp = cos(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 ((z <= (-5.5d+206)) .or. (.not. (z <= 1.45d+66))) then
tmp = -z * sin(y)
else
tmp = cos(y) + x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -5.5e+206) || !(z <= 1.45e+66)) {
tmp = -z * Math.sin(y);
} else {
tmp = Math.cos(y) + x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -5.5e+206) or not (z <= 1.45e+66): tmp = -z * math.sin(y) else: tmp = math.cos(y) + x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -5.5e+206) || !(z <= 1.45e+66)) tmp = Float64(Float64(-z) * sin(y)); else tmp = Float64(cos(y) + x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -5.5e+206) || ~((z <= 1.45e+66))) tmp = -z * sin(y); else tmp = cos(y) + x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -5.5e+206], N[Not[LessEqual[z, 1.45e+66]], $MachinePrecision]], N[((-z) * N[Sin[y], $MachinePrecision]), $MachinePrecision], N[(N[Cos[y], $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.5 \cdot 10^{+206} \lor \neg \left(z \leq 1.45 \cdot 10^{+66}\right):\\
\;\;\;\;\left(-z\right) \cdot \sin y\\
\mathbf{else}:\\
\;\;\;\;\cos y + x\\
\end{array}
\end{array}
if z < -5.50000000000000021e206 or 1.44999999999999993e66 < z Initial program 99.8%
Taylor expanded in z around inf
mul-1-negN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
lift-sin.f6466.9
Applied rewrites66.9%
if -5.50000000000000021e206 < z < 1.44999999999999993e66Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
lift-cos.f6490.6
Applied rewrites90.6%
Final simplification83.2%
(FPCore (x y z) :precision binary64 (if (or (<= y -5.8e+30) (not (<= y 0.086))) (+ (cos y) x) (fma (- (* (- (* 0.16666666666666666 (* z y)) 0.5) y) z) y (- x -1.0))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -5.8e+30) || !(y <= 0.086)) {
tmp = cos(y) + x;
} else {
tmp = fma(((((0.16666666666666666 * (z * y)) - 0.5) * y) - z), y, (x - -1.0));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if ((y <= -5.8e+30) || !(y <= 0.086)) tmp = Float64(cos(y) + x); else tmp = fma(Float64(Float64(Float64(Float64(0.16666666666666666 * Float64(z * y)) - 0.5) * y) - z), y, Float64(x - -1.0)); end return tmp end
code[x_, y_, z_] := If[Or[LessEqual[y, -5.8e+30], N[Not[LessEqual[y, 0.086]], $MachinePrecision]], N[(N[Cos[y], $MachinePrecision] + x), $MachinePrecision], N[(N[(N[(N[(N[(0.16666666666666666 * N[(z * y), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision] * y), $MachinePrecision] - z), $MachinePrecision] * y + N[(x - -1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.8 \cdot 10^{+30} \lor \neg \left(y \leq 0.086\right):\\
\;\;\;\;\cos y + x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(0.16666666666666666 \cdot \left(z \cdot y\right) - 0.5\right) \cdot y - z, y, x - -1\right)\\
\end{array}
\end{array}
if y < -5.7999999999999996e30 or 0.085999999999999993 < y Initial program 99.9%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
lift-cos.f6459.1
Applied rewrites59.1%
if -5.7999999999999996e30 < y < 0.085999999999999993Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
Applied rewrites99.7%
Final simplification81.0%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.7e+57) (not (<= y 4.6))) (- x -1.0) (fma (- (* (- (* 0.16666666666666666 (* z y)) 0.5) y) z) y (- x -1.0))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.7e+57) || !(y <= 4.6)) {
tmp = x - -1.0;
} else {
tmp = fma(((((0.16666666666666666 * (z * y)) - 0.5) * y) - z), y, (x - -1.0));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if ((y <= -1.7e+57) || !(y <= 4.6)) tmp = Float64(x - -1.0); else tmp = fma(Float64(Float64(Float64(Float64(0.16666666666666666 * Float64(z * y)) - 0.5) * y) - z), y, Float64(x - -1.0)); end return tmp end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.7e+57], N[Not[LessEqual[y, 4.6]], $MachinePrecision]], N[(x - -1.0), $MachinePrecision], N[(N[(N[(N[(N[(0.16666666666666666 * N[(z * y), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision] * y), $MachinePrecision] - z), $MachinePrecision] * y + N[(x - -1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.7 \cdot 10^{+57} \lor \neg \left(y \leq 4.6\right):\\
\;\;\;\;x - -1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(0.16666666666666666 \cdot \left(z \cdot y\right) - 0.5\right) \cdot y - z, y, x - -1\right)\\
\end{array}
\end{array}
if y < -1.69999999999999996e57 or 4.5999999999999996 < y Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f6439.1
Applied rewrites39.1%
if -1.69999999999999996e57 < y < 4.5999999999999996Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
Applied rewrites94.8%
Final simplification71.1%
(FPCore (x y z) :precision binary64 (if (or (<= y -7.8e+55) (not (<= y 2.9e+36))) (- x -1.0) (fma (- (* (* (* 0.16666666666666666 y) z) y) z) y (- x -1.0))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -7.8e+55) || !(y <= 2.9e+36)) {
tmp = x - -1.0;
} else {
tmp = fma(((((0.16666666666666666 * y) * z) * y) - z), y, (x - -1.0));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if ((y <= -7.8e+55) || !(y <= 2.9e+36)) tmp = Float64(x - -1.0); else tmp = fma(Float64(Float64(Float64(Float64(0.16666666666666666 * y) * z) * y) - z), y, Float64(x - -1.0)); end return tmp end
code[x_, y_, z_] := If[Or[LessEqual[y, -7.8e+55], N[Not[LessEqual[y, 2.9e+36]], $MachinePrecision]], N[(x - -1.0), $MachinePrecision], N[(N[(N[(N[(N[(0.16666666666666666 * y), $MachinePrecision] * z), $MachinePrecision] * y), $MachinePrecision] - z), $MachinePrecision] * y + N[(x - -1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.8 \cdot 10^{+55} \lor \neg \left(y \leq 2.9 \cdot 10^{+36}\right):\\
\;\;\;\;x - -1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(0.16666666666666666 \cdot y\right) \cdot z\right) \cdot y - z, y, x - -1\right)\\
\end{array}
\end{array}
if y < -7.80000000000000054e55 or 2.9e36 < y Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f6439.6
Applied rewrites39.6%
if -7.80000000000000054e55 < y < 2.9e36Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
Applied rewrites91.3%
Taylor expanded in y around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f6491.9
Applied rewrites91.9%
Final simplification71.1%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.25e+32) (not (<= y 4.6))) (- x -1.0) (fma (- (* -0.5 y) z) y (- x -1.0))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.25e+32) || !(y <= 4.6)) {
tmp = x - -1.0;
} else {
tmp = fma(((-0.5 * y) - z), y, (x - -1.0));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if ((y <= -1.25e+32) || !(y <= 4.6)) tmp = Float64(x - -1.0); else tmp = fma(Float64(Float64(-0.5 * y) - z), y, Float64(x - -1.0)); end return tmp end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.25e+32], N[Not[LessEqual[y, 4.6]], $MachinePrecision]], N[(x - -1.0), $MachinePrecision], N[(N[(N[(-0.5 * y), $MachinePrecision] - z), $MachinePrecision] * y + N[(x - -1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.25 \cdot 10^{+32} \lor \neg \left(y \leq 4.6\right):\\
\;\;\;\;x - -1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.5 \cdot y - z, y, x - -1\right)\\
\end{array}
\end{array}
if y < -1.2499999999999999e32 or 4.5999999999999996 < y Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f6437.8
Applied rewrites37.8%
if -1.2499999999999999e32 < y < 4.5999999999999996Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f64N/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f6498.3
Applied rewrites98.3%
Final simplification70.9%
(FPCore (x y z) :precision binary64 (if (or (<= y -2e+51) (not (<= y 1.7e+26))) (- x -1.0) (- x (fma z y -1.0))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -2e+51) || !(y <= 1.7e+26)) {
tmp = x - -1.0;
} else {
tmp = x - fma(z, y, -1.0);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if ((y <= -2e+51) || !(y <= 1.7e+26)) tmp = Float64(x - -1.0); else tmp = Float64(x - fma(z, y, -1.0)); end return tmp end
code[x_, y_, z_] := If[Or[LessEqual[y, -2e+51], N[Not[LessEqual[y, 1.7e+26]], $MachinePrecision]], N[(x - -1.0), $MachinePrecision], N[(x - N[(z * y + -1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2 \cdot 10^{+51} \lor \neg \left(y \leq 1.7 \cdot 10^{+26}\right):\\
\;\;\;\;x - -1\\
\mathbf{else}:\\
\;\;\;\;x - \mathsf{fma}\left(z, y, -1\right)\\
\end{array}
\end{array}
if y < -2e51 or 1.7000000000000001e26 < y Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f6438.7
Applied rewrites38.7%
if -2e51 < y < 1.7000000000000001e26Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f64N/A
metadata-evalN/A
fp-cancel-sub-sign-invN/A
*-lft-identityN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6494.0
Applied rewrites94.0%
lift--.f64N/A
lift--.f64N/A
associate--l-N/A
lower--.f64N/A
lift-*.f64N/A
lower-fma.f6494.0
Applied rewrites94.0%
Final simplification70.9%
(FPCore (x y z) :precision binary64 (if (<= x -5.5e+16) x (if (<= x 9500000.0) (- 1.0 (* z y)) (- x -1.0))))
double code(double x, double y, double z) {
double tmp;
if (x <= -5.5e+16) {
tmp = x;
} else if (x <= 9500000.0) {
tmp = 1.0 - (z * y);
} else {
tmp = x - -1.0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x <= (-5.5d+16)) then
tmp = x
else if (x <= 9500000.0d0) then
tmp = 1.0d0 - (z * y)
else
tmp = x - (-1.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -5.5e+16) {
tmp = x;
} else if (x <= 9500000.0) {
tmp = 1.0 - (z * y);
} else {
tmp = x - -1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -5.5e+16: tmp = x elif x <= 9500000.0: tmp = 1.0 - (z * y) else: tmp = x - -1.0 return tmp
function code(x, y, z) tmp = 0.0 if (x <= -5.5e+16) tmp = x; elseif (x <= 9500000.0) tmp = Float64(1.0 - Float64(z * y)); else tmp = Float64(x - -1.0); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -5.5e+16) tmp = x; elseif (x <= 9500000.0) tmp = 1.0 - (z * y); else tmp = x - -1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -5.5e+16], x, If[LessEqual[x, 9500000.0], N[(1.0 - N[(z * y), $MachinePrecision]), $MachinePrecision], N[(x - -1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.5 \cdot 10^{+16}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 9500000:\\
\;\;\;\;1 - z \cdot y\\
\mathbf{else}:\\
\;\;\;\;x - -1\\
\end{array}
\end{array}
if x < -5.5e16Initial program 100.0%
Taylor expanded in x around inf
Applied rewrites84.4%
if -5.5e16 < x < 9.5e6Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f64N/A
metadata-evalN/A
fp-cancel-sub-sign-invN/A
*-lft-identityN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6457.8
Applied rewrites57.8%
Taylor expanded in x around 0
lower--.f64N/A
*-commutativeN/A
lift-*.f6456.2
Applied rewrites56.2%
if 9.5e6 < x Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f6483.1
Applied rewrites83.1%
(FPCore (x y z) :precision binary64 (if (<= z 2.6e+212) (- x -1.0) (* (- z) y)))
double code(double x, double y, double z) {
double tmp;
if (z <= 2.6e+212) {
tmp = x - -1.0;
} else {
tmp = -z * y;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= 2.6d+212) then
tmp = x - (-1.0d0)
else
tmp = -z * y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= 2.6e+212) {
tmp = x - -1.0;
} else {
tmp = -z * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 2.6e+212: tmp = x - -1.0 else: tmp = -z * y return tmp
function code(x, y, z) tmp = 0.0 if (z <= 2.6e+212) tmp = Float64(x - -1.0); else tmp = Float64(Float64(-z) * y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= 2.6e+212) tmp = x - -1.0; else tmp = -z * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 2.6e+212], N[(x - -1.0), $MachinePrecision], N[((-z) * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 2.6 \cdot 10^{+212}:\\
\;\;\;\;x - -1\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) \cdot y\\
\end{array}
\end{array}
if z < 2.5999999999999998e212Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f6466.4
Applied rewrites66.4%
if 2.5999999999999998e212 < z Initial program 99.8%
Taylor expanded in z around inf
mul-1-negN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
lift-sin.f6482.9
Applied rewrites82.9%
Taylor expanded in y around 0
Applied rewrites38.0%
(FPCore (x y z) :precision binary64 (- x -1.0))
double code(double x, double y, double z) {
return x - -1.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 - (-1.0d0)
end function
public static double code(double x, double y, double z) {
return x - -1.0;
}
def code(x, y, z): return x - -1.0
function code(x, y, z) return Float64(x - -1.0) end
function tmp = code(x, y, z) tmp = x - -1.0; end
code[x_, y_, z_] := N[(x - -1.0), $MachinePrecision]
\begin{array}{l}
\\
x - -1
\end{array}
Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f6462.3
Applied rewrites62.3%
(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.9%
Taylor expanded in x around inf
Applied rewrites38.7%
herbie shell --seed 2025080
(FPCore (x y z)
:name "Graphics.Rasterific.Svg.PathConverter:segmentToBezier from rasterific-svg-0.2.3.1, B"
:precision binary64
(- (+ x (cos y)) (* z (sin y))))