
(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 (- (+ 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
(let* ((t_0 (* z (sin y))) (t_1 (- (+ x (cos y)) t_0)))
(if (or (<= t_1 -2000000000.0) (not (<= t_1 0.998)))
(- (+ x 1.0) t_0)
(* (/ (cos y) x) 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 <= -2000000000.0) || !(t_1 <= 0.998)) {
tmp = (x + 1.0) - t_0;
} else {
tmp = (cos(y) / x) * 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 <= (-2000000000.0d0)) .or. (.not. (t_1 <= 0.998d0))) then
tmp = (x + 1.0d0) - t_0
else
tmp = (cos(y) / x) * 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 <= -2000000000.0) || !(t_1 <= 0.998)) {
tmp = (x + 1.0) - t_0;
} else {
tmp = (Math.cos(y) / x) * 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 <= -2000000000.0) or not (t_1 <= 0.998): tmp = (x + 1.0) - t_0 else: tmp = (math.cos(y) / x) * 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 <= -2000000000.0) || !(t_1 <= 0.998)) tmp = Float64(Float64(x + 1.0) - t_0); else tmp = Float64(Float64(cos(y) / x) * 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 <= -2000000000.0) || ~((t_1 <= 0.998))) tmp = (x + 1.0) - t_0; else tmp = (cos(y) / x) * 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, -2000000000.0], N[Not[LessEqual[t$95$1, 0.998]], $MachinePrecision]], N[(N[(x + 1.0), $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[(N[Cos[y], $MachinePrecision] / x), $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 -2000000000 \lor \neg \left(t\_1 \leq 0.998\right):\\
\;\;\;\;\left(x + 1\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos y}{x} \cdot x\\
\end{array}
\end{array}
if (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) < -2e9 or 0.998 < (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) Initial program 99.9%
Taylor expanded in y around 0
Applied rewrites99.0%
if -2e9 < (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) < 0.998Initial program 100.0%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
div-add-revN/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-cos.f64N/A
lower-sin.f6499.5
Applied rewrites99.5%
Taylor expanded in x around inf
Applied rewrites99.2%
Taylor expanded in z around 0
Applied rewrites99.7%
Taylor expanded in x around 0
Applied rewrites96.5%
Final simplification98.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ x (cos y))) (t_1 (* z (sin y))) (t_2 (- t_0 t_1)))
(if (or (<= t_2 -5e+26) (not (<= t_2 0.99999999995)))
(- (+ x 1.0) t_1)
(- t_0 (* z y)))))
double code(double x, double y, double z) {
double t_0 = x + cos(y);
double t_1 = z * sin(y);
double t_2 = t_0 - t_1;
double tmp;
if ((t_2 <= -5e+26) || !(t_2 <= 0.99999999995)) {
tmp = (x + 1.0) - t_1;
} else {
tmp = t_0 - (z * y);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = x + cos(y)
t_1 = z * sin(y)
t_2 = t_0 - t_1
if ((t_2 <= (-5d+26)) .or. (.not. (t_2 <= 0.99999999995d0))) then
tmp = (x + 1.0d0) - t_1
else
tmp = t_0 - (z * y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x + Math.cos(y);
double t_1 = z * Math.sin(y);
double t_2 = t_0 - t_1;
double tmp;
if ((t_2 <= -5e+26) || !(t_2 <= 0.99999999995)) {
tmp = (x + 1.0) - t_1;
} else {
tmp = t_0 - (z * y);
}
return tmp;
}
def code(x, y, z): t_0 = x + math.cos(y) t_1 = z * math.sin(y) t_2 = t_0 - t_1 tmp = 0 if (t_2 <= -5e+26) or not (t_2 <= 0.99999999995): tmp = (x + 1.0) - t_1 else: tmp = t_0 - (z * y) return tmp
function code(x, y, z) t_0 = Float64(x + cos(y)) t_1 = Float64(z * sin(y)) t_2 = Float64(t_0 - t_1) tmp = 0.0 if ((t_2 <= -5e+26) || !(t_2 <= 0.99999999995)) tmp = Float64(Float64(x + 1.0) - t_1); else tmp = Float64(t_0 - Float64(z * y)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x + cos(y); t_1 = z * sin(y); t_2 = t_0 - t_1; tmp = 0.0; if ((t_2 <= -5e+26) || ~((t_2 <= 0.99999999995))) tmp = (x + 1.0) - t_1; else tmp = t_0 - (z * y); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 - t$95$1), $MachinePrecision]}, If[Or[LessEqual[t$95$2, -5e+26], N[Not[LessEqual[t$95$2, 0.99999999995]], $MachinePrecision]], N[(N[(x + 1.0), $MachinePrecision] - t$95$1), $MachinePrecision], N[(t$95$0 - N[(z * y), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x + \cos y\\
t_1 := z \cdot \sin y\\
t_2 := t\_0 - t\_1\\
\mathbf{if}\;t\_2 \leq -5 \cdot 10^{+26} \lor \neg \left(t\_2 \leq 0.99999999995\right):\\
\;\;\;\;\left(x + 1\right) - t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0 - z \cdot y\\
\end{array}
\end{array}
if (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) < -5.0000000000000001e26 or 0.99999999995 < (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) Initial program 99.9%
Taylor expanded in y around 0
Applied rewrites99.1%
if -5.0000000000000001e26 < (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) < 0.99999999995Initial program 100.0%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f6455.7
Applied rewrites55.7%
Final simplification91.8%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.9e-6) (not (<= z 1.05e-27))) (- (+ x 1.0) (* z (sin y))) (* (/ (+ (cos y) x) x) x)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.9e-6) || !(z <= 1.05e-27)) {
tmp = (x + 1.0) - (z * sin(y));
} else {
tmp = ((cos(y) + x) / x) * 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 <= (-1.9d-6)) .or. (.not. (z <= 1.05d-27))) then
tmp = (x + 1.0d0) - (z * sin(y))
else
tmp = ((cos(y) + x) / x) * x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.9e-6) || !(z <= 1.05e-27)) {
tmp = (x + 1.0) - (z * Math.sin(y));
} else {
tmp = ((Math.cos(y) + x) / x) * x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.9e-6) or not (z <= 1.05e-27): tmp = (x + 1.0) - (z * math.sin(y)) else: tmp = ((math.cos(y) + x) / x) * x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.9e-6) || !(z <= 1.05e-27)) tmp = Float64(Float64(x + 1.0) - Float64(z * sin(y))); else tmp = Float64(Float64(Float64(cos(y) + x) / x) * x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.9e-6) || ~((z <= 1.05e-27))) tmp = (x + 1.0) - (z * sin(y)); else tmp = ((cos(y) + x) / x) * x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.9e-6], N[Not[LessEqual[z, 1.05e-27]], $MachinePrecision]], N[(N[(x + 1.0), $MachinePrecision] - N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[Cos[y], $MachinePrecision] + x), $MachinePrecision] / x), $MachinePrecision] * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.9 \cdot 10^{-6} \lor \neg \left(z \leq 1.05 \cdot 10^{-27}\right):\\
\;\;\;\;\left(x + 1\right) - z \cdot \sin y\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos y + x}{x} \cdot x\\
\end{array}
\end{array}
if z < -1.9e-6 or 1.05000000000000008e-27 < z Initial program 99.8%
Taylor expanded in y around 0
Applied rewrites98.8%
if -1.9e-6 < z < 1.05000000000000008e-27Initial program 100.0%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
div-add-revN/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-cos.f64N/A
lower-sin.f6472.2
Applied rewrites72.2%
Taylor expanded in x around inf
Applied rewrites99.7%
Taylor expanded in z around 0
Applied rewrites99.9%
Final simplification99.4%
(FPCore (x y z)
:precision binary64
(if (<= y -1.85e+161)
(+ 1.0 x)
(if (<= y -1e+29)
(* (- z) (sin y))
(if (<= y 2.95e+16) (- x (fma z y -1.0)) (+ 1.0 x)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.85e+161) {
tmp = 1.0 + x;
} else if (y <= -1e+29) {
tmp = -z * sin(y);
} else if (y <= 2.95e+16) {
tmp = x - fma(z, y, -1.0);
} else {
tmp = 1.0 + x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -1.85e+161) tmp = Float64(1.0 + x); elseif (y <= -1e+29) tmp = Float64(Float64(-z) * sin(y)); elseif (y <= 2.95e+16) tmp = Float64(x - fma(z, y, -1.0)); else tmp = Float64(1.0 + x); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -1.85e+161], N[(1.0 + x), $MachinePrecision], If[LessEqual[y, -1e+29], N[((-z) * N[Sin[y], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.95e+16], N[(x - N[(z * y + -1.0), $MachinePrecision]), $MachinePrecision], N[(1.0 + x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.85 \cdot 10^{+161}:\\
\;\;\;\;1 + x\\
\mathbf{elif}\;y \leq -1 \cdot 10^{+29}:\\
\;\;\;\;\left(-z\right) \cdot \sin y\\
\mathbf{elif}\;y \leq 2.95 \cdot 10^{+16}:\\
\;\;\;\;x - \mathsf{fma}\left(z, y, -1\right)\\
\mathbf{else}:\\
\;\;\;\;1 + x\\
\end{array}
\end{array}
if y < -1.8499999999999999e161 or 2.95e16 < y Initial program 99.9%
Taylor expanded in y around 0
lower-+.f6449.8
Applied rewrites49.8%
if -1.8499999999999999e161 < y < -9.99999999999999914e28Initial program 99.7%
Taylor expanded in z around inf
mul-1-negN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sin.f6453.1
Applied rewrites53.1%
if -9.99999999999999914e28 < y < 2.95e16Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites96.5%
Taylor expanded in y around 0
+-commutativeN/A
associate-*r*N/A
mul-1-negN/A
fp-cancel-sub-signN/A
associate-+l-N/A
lower--.f64N/A
metadata-evalN/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
lower-fma.f6495.6
Applied rewrites95.6%
(FPCore (x y z) :precision binary64 (- (+ x 1.0) (* z (sin y))))
double code(double x, double y, double z) {
return (x + 1.0) - (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 + 1.0d0) - (z * sin(y))
end function
public static double code(double x, double y, double z) {
return (x + 1.0) - (z * Math.sin(y));
}
def code(x, y, z): return (x + 1.0) - (z * math.sin(y))
function code(x, y, z) return Float64(Float64(x + 1.0) - Float64(z * sin(y))) end
function tmp = code(x, y, z) tmp = (x + 1.0) - (z * sin(y)); end
code[x_, y_, z_] := N[(N[(x + 1.0), $MachinePrecision] - N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + 1\right) - z \cdot \sin y
\end{array}
Initial program 99.9%
Taylor expanded in y around 0
Applied rewrites85.6%
(FPCore (x y z)
:precision binary64
(if (or (<= y -4200.0) (not (<= y 23.0)))
(+ 1.0 x)
(-
(+ x (fma (* y y) -0.5 1.0))
(*
(fma
(* z (fma 0.008333333333333333 (* y y) -0.16666666666666666))
(* y y)
z)
y))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -4200.0) || !(y <= 23.0)) {
tmp = 1.0 + x;
} else {
tmp = (x + fma((y * y), -0.5, 1.0)) - (fma((z * fma(0.008333333333333333, (y * y), -0.16666666666666666)), (y * y), z) * y);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if ((y <= -4200.0) || !(y <= 23.0)) tmp = Float64(1.0 + x); else tmp = Float64(Float64(x + fma(Float64(y * y), -0.5, 1.0)) - Float64(fma(Float64(z * fma(0.008333333333333333, Float64(y * y), -0.16666666666666666)), Float64(y * y), z) * y)); end return tmp end
code[x_, y_, z_] := If[Or[LessEqual[y, -4200.0], N[Not[LessEqual[y, 23.0]], $MachinePrecision]], N[(1.0 + x), $MachinePrecision], N[(N[(x + N[(N[(y * y), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(z * N[(0.008333333333333333 * N[(y * y), $MachinePrecision] + -0.16666666666666666), $MachinePrecision]), $MachinePrecision] * N[(y * y), $MachinePrecision] + z), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4200 \lor \neg \left(y \leq 23\right):\\
\;\;\;\;1 + x\\
\mathbf{else}:\\
\;\;\;\;\left(x + \mathsf{fma}\left(y \cdot y, -0.5, 1\right)\right) - \mathsf{fma}\left(z \cdot \mathsf{fma}\left(0.008333333333333333, y \cdot y, -0.16666666666666666\right), y \cdot y, z\right) \cdot y\\
\end{array}
\end{array}
if y < -4200 or 23 < y Initial program 99.8%
Taylor expanded in y around 0
lower-+.f6443.4
Applied rewrites43.4%
if -4200 < y < 23Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6499.6
Applied rewrites99.6%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
lower-*.f64N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6499.5
Applied rewrites99.5%
Final simplification70.6%
(FPCore (x y z) :precision binary64 (if (or (<= y -4200.0) (not (<= y 30.0))) (+ 1.0 x) (fma (- (* (- (* 0.16666666666666666 (* z y)) 0.5) y) z) y (+ 1.0 x))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -4200.0) || !(y <= 30.0)) {
tmp = 1.0 + x;
} else {
tmp = fma(((((0.16666666666666666 * (z * y)) - 0.5) * y) - z), y, (1.0 + x));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if ((y <= -4200.0) || !(y <= 30.0)) tmp = Float64(1.0 + x); else tmp = fma(Float64(Float64(Float64(Float64(0.16666666666666666 * Float64(z * y)) - 0.5) * y) - z), y, Float64(1.0 + x)); end return tmp end
code[x_, y_, z_] := If[Or[LessEqual[y, -4200.0], N[Not[LessEqual[y, 30.0]], $MachinePrecision]], N[(1.0 + x), $MachinePrecision], N[(N[(N[(N[(N[(0.16666666666666666 * N[(z * y), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision] * y), $MachinePrecision] - z), $MachinePrecision] * y + N[(1.0 + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4200 \lor \neg \left(y \leq 30\right):\\
\;\;\;\;1 + x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(0.16666666666666666 \cdot \left(z \cdot y\right) - 0.5\right) \cdot y - z, y, 1 + x\right)\\
\end{array}
\end{array}
if y < -4200 or 30 < y Initial program 99.8%
Taylor expanded in y around 0
lower-+.f6443.4
Applied rewrites43.4%
if -4200 < y < 30Initial 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
lower-+.f6499.5
Applied rewrites99.5%
Final simplification70.5%
(FPCore (x y z)
:precision binary64
(if (<= y -4500.0)
(+ 1.0 x)
(if (<= y 5000000000.0)
(- x (fma (fma 0.5 y z) y -1.0))
(* (/ (- x -1.0) x) x))))
double code(double x, double y, double z) {
double tmp;
if (y <= -4500.0) {
tmp = 1.0 + x;
} else if (y <= 5000000000.0) {
tmp = x - fma(fma(0.5, y, z), y, -1.0);
} else {
tmp = ((x - -1.0) / x) * x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -4500.0) tmp = Float64(1.0 + x); elseif (y <= 5000000000.0) tmp = Float64(x - fma(fma(0.5, y, z), y, -1.0)); else tmp = Float64(Float64(Float64(x - -1.0) / x) * x); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -4500.0], N[(1.0 + x), $MachinePrecision], If[LessEqual[y, 5000000000.0], N[(x - N[(N[(0.5 * y + z), $MachinePrecision] * y + -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x - -1.0), $MachinePrecision] / x), $MachinePrecision] * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4500:\\
\;\;\;\;1 + x\\
\mathbf{elif}\;y \leq 5000000000:\\
\;\;\;\;x - \mathsf{fma}\left(\mathsf{fma}\left(0.5, y, z\right), y, -1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x - -1}{x} \cdot x\\
\end{array}
\end{array}
if y < -4500Initial program 99.8%
Taylor expanded in y around 0
lower-+.f6445.8
Applied rewrites45.8%
if -4500 < y < 5e9Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites99.4%
Taylor expanded in y around 0
+-commutativeN/A
fp-cancel-sign-sub-invN/A
associate-+l-N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
lower--.f64N/A
metadata-evalN/A
metadata-evalN/A
fp-cancel-sign-subN/A
Applied rewrites98.7%
if 5e9 < y Initial program 99.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
div-add-revN/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-cos.f64N/A
lower-sin.f6487.4
Applied rewrites87.4%
Taylor expanded in x around inf
Applied rewrites90.5%
Taylor expanded in y around 0
Applied rewrites41.2%
(FPCore (x y z) :precision binary64 (if (or (<= y -4500.0) (not (<= y 5000000000.0))) (+ 1.0 x) (- x (fma (fma 0.5 y z) y -1.0))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -4500.0) || !(y <= 5000000000.0)) {
tmp = 1.0 + x;
} else {
tmp = x - fma(fma(0.5, y, z), y, -1.0);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if ((y <= -4500.0) || !(y <= 5000000000.0)) tmp = Float64(1.0 + x); else tmp = Float64(x - fma(fma(0.5, y, z), y, -1.0)); end return tmp end
code[x_, y_, z_] := If[Or[LessEqual[y, -4500.0], N[Not[LessEqual[y, 5000000000.0]], $MachinePrecision]], N[(1.0 + x), $MachinePrecision], N[(x - N[(N[(0.5 * y + z), $MachinePrecision] * y + -1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4500 \lor \neg \left(y \leq 5000000000\right):\\
\;\;\;\;1 + x\\
\mathbf{else}:\\
\;\;\;\;x - \mathsf{fma}\left(\mathsf{fma}\left(0.5, y, z\right), y, -1\right)\\
\end{array}
\end{array}
if y < -4500 or 5e9 < y Initial program 99.8%
Taylor expanded in y around 0
lower-+.f6443.6
Applied rewrites43.6%
if -4500 < y < 5e9Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites99.4%
Taylor expanded in y around 0
+-commutativeN/A
fp-cancel-sign-sub-invN/A
associate-+l-N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
lower--.f64N/A
metadata-evalN/A
metadata-evalN/A
fp-cancel-sign-subN/A
Applied rewrites98.7%
Final simplification70.5%
(FPCore (x y z) :precision binary64 (if (or (<= y -4.5e+21) (not (<= y 1000000000.0))) (+ 1.0 x) (- x (fma z y -1.0))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -4.5e+21) || !(y <= 1000000000.0)) {
tmp = 1.0 + x;
} else {
tmp = x - fma(z, y, -1.0);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if ((y <= -4.5e+21) || !(y <= 1000000000.0)) tmp = Float64(1.0 + x); else tmp = Float64(x - fma(z, y, -1.0)); end return tmp end
code[x_, y_, z_] := If[Or[LessEqual[y, -4.5e+21], N[Not[LessEqual[y, 1000000000.0]], $MachinePrecision]], N[(1.0 + x), $MachinePrecision], N[(x - N[(z * y + -1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.5 \cdot 10^{+21} \lor \neg \left(y \leq 1000000000\right):\\
\;\;\;\;1 + x\\
\mathbf{else}:\\
\;\;\;\;x - \mathsf{fma}\left(z, y, -1\right)\\
\end{array}
\end{array}
if y < -4.5e21 or 1e9 < y Initial program 99.8%
Taylor expanded in y around 0
lower-+.f6442.1
Applied rewrites42.1%
if -4.5e21 < y < 1e9Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites98.2%
Taylor expanded in y around 0
+-commutativeN/A
associate-*r*N/A
mul-1-negN/A
fp-cancel-sub-signN/A
associate-+l-N/A
lower--.f64N/A
metadata-evalN/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
lower-fma.f6497.3
Applied rewrites97.3%
Final simplification70.4%
(FPCore (x y z) :precision binary64 (if (or (<= z -4.5e+219) (not (<= z 7.2e+189))) (- x (* z y)) (+ 1.0 x)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -4.5e+219) || !(z <= 7.2e+189)) {
tmp = x - (z * y);
} else {
tmp = 1.0 + 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 <= (-4.5d+219)) .or. (.not. (z <= 7.2d+189))) then
tmp = x - (z * y)
else
tmp = 1.0d0 + x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -4.5e+219) || !(z <= 7.2e+189)) {
tmp = x - (z * y);
} else {
tmp = 1.0 + x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -4.5e+219) or not (z <= 7.2e+189): tmp = x - (z * y) else: tmp = 1.0 + x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -4.5e+219) || !(z <= 7.2e+189)) tmp = Float64(x - Float64(z * y)); else tmp = Float64(1.0 + x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -4.5e+219) || ~((z <= 7.2e+189))) tmp = x - (z * y); else tmp = 1.0 + x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -4.5e+219], N[Not[LessEqual[z, 7.2e+189]], $MachinePrecision]], N[(x - N[(z * y), $MachinePrecision]), $MachinePrecision], N[(1.0 + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.5 \cdot 10^{+219} \lor \neg \left(z \leq 7.2 \cdot 10^{+189}\right):\\
\;\;\;\;x - z \cdot y\\
\mathbf{else}:\\
\;\;\;\;1 + x\\
\end{array}
\end{array}
if z < -4.50000000000000023e219 or 7.20000000000000017e189 < z Initial program 99.7%
Taylor expanded in y around 0
Applied rewrites99.7%
Taylor expanded in y around 0
+-commutativeN/A
associate-*r*N/A
mul-1-negN/A
fp-cancel-sub-signN/A
associate-+l-N/A
lower--.f64N/A
metadata-evalN/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
lower-fma.f6458.2
Applied rewrites58.2%
Taylor expanded in y around inf
Applied rewrites58.2%
if -4.50000000000000023e219 < z < 7.20000000000000017e189Initial program 100.0%
Taylor expanded in y around 0
lower-+.f6469.4
Applied rewrites69.4%
Final simplification67.9%
(FPCore (x y z) :precision binary64 (if (or (<= x -7.8e-11) (not (<= x 1.12e-119))) (+ 1.0 x) (- 1.0 (* z y))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -7.8e-11) || !(x <= 1.12e-119)) {
tmp = 1.0 + x;
} else {
tmp = 1.0 - (z * y);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((x <= (-7.8d-11)) .or. (.not. (x <= 1.12d-119))) then
tmp = 1.0d0 + x
else
tmp = 1.0d0 - (z * y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -7.8e-11) || !(x <= 1.12e-119)) {
tmp = 1.0 + x;
} else {
tmp = 1.0 - (z * y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -7.8e-11) or not (x <= 1.12e-119): tmp = 1.0 + x else: tmp = 1.0 - (z * y) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -7.8e-11) || !(x <= 1.12e-119)) tmp = Float64(1.0 + x); else tmp = Float64(1.0 - Float64(z * y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -7.8e-11) || ~((x <= 1.12e-119))) tmp = 1.0 + x; else tmp = 1.0 - (z * y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -7.8e-11], N[Not[LessEqual[x, 1.12e-119]], $MachinePrecision]], N[(1.0 + x), $MachinePrecision], N[(1.0 - N[(z * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7.8 \cdot 10^{-11} \lor \neg \left(x \leq 1.12 \cdot 10^{-119}\right):\\
\;\;\;\;1 + x\\
\mathbf{else}:\\
\;\;\;\;1 - z \cdot y\\
\end{array}
\end{array}
if x < -7.80000000000000021e-11 or 1.11999999999999998e-119 < x Initial program 99.9%
Taylor expanded in y around 0
lower-+.f6474.9
Applied rewrites74.9%
if -7.80000000000000021e-11 < x < 1.11999999999999998e-119Initial program 99.9%
Taylor expanded in y around 0
Applied rewrites71.4%
Taylor expanded in y around 0
+-commutativeN/A
associate-*r*N/A
mul-1-negN/A
fp-cancel-sub-signN/A
associate-+l-N/A
lower--.f64N/A
metadata-evalN/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
lower-fma.f6454.7
Applied rewrites54.7%
Taylor expanded in x around 0
Applied rewrites54.7%
Final simplification67.3%
(FPCore (x y z) :precision binary64 (if (<= z -1.85e+234) (* (- y) z) (+ 1.0 x)))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.85e+234) {
tmp = -y * z;
} else {
tmp = 1.0 + 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 <= (-1.85d+234)) then
tmp = -y * z
else
tmp = 1.0d0 + x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1.85e+234) {
tmp = -y * z;
} else {
tmp = 1.0 + x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.85e+234: tmp = -y * z else: tmp = 1.0 + x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.85e+234) tmp = Float64(Float64(-y) * z); else tmp = Float64(1.0 + x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.85e+234) tmp = -y * z; else tmp = 1.0 + x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.85e+234], N[((-y) * z), $MachinePrecision], N[(1.0 + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.85 \cdot 10^{+234}:\\
\;\;\;\;\left(-y\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;1 + x\\
\end{array}
\end{array}
if z < -1.84999999999999983e234Initial program 99.5%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
div-add-revN/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-cos.f64N/A
lower-sin.f6499.5
Applied rewrites99.5%
Taylor expanded in y around 0
Applied rewrites46.5%
Taylor expanded in z around inf
Applied rewrites47.2%
if -1.84999999999999983e234 < z Initial program 99.9%
Taylor expanded in y around 0
lower-+.f6465.1
Applied rewrites65.1%
(FPCore (x y z) :precision binary64 (+ 1.0 x))
double code(double x, double y, double z) {
return 1.0 + 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 = 1.0d0 + x
end function
public static double code(double x, double y, double z) {
return 1.0 + x;
}
def code(x, y, z): return 1.0 + x
function code(x, y, z) return Float64(1.0 + x) end
function tmp = code(x, y, z) tmp = 1.0 + x; end
code[x_, y_, z_] := N[(1.0 + x), $MachinePrecision]
\begin{array}{l}
\\
1 + x
\end{array}
Initial program 99.9%
Taylor expanded in y around 0
lower-+.f6462.9
Applied rewrites62.9%
(FPCore (x y z) :precision binary64 1.0)
double code(double x, double y, double z) {
return 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 = 1.0d0
end function
public static double code(double x, double y, double z) {
return 1.0;
}
def code(x, y, z): return 1.0
function code(x, y, z) return 1.0 end
function tmp = code(x, y, z) tmp = 1.0; end
code[x_, y_, z_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 99.9%
Taylor expanded in y around 0
lower-+.f6462.9
Applied rewrites62.9%
Taylor expanded in x around 0
Applied rewrites21.9%
herbie shell --seed 2025015
(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))))