
(FPCore (x y z t) :precision binary64 (+ (- x (/ y (* z 3.0))) (/ t (* (* z 3.0) y))))
double code(double x, double y, double z, double t) {
return (x - (y / (z * 3.0))) + (t / ((z * 3.0) * 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, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (x - (y / (z * 3.0d0))) + (t / ((z * 3.0d0) * y))
end function
public static double code(double x, double y, double z, double t) {
return (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y));
}
def code(x, y, z, t): return (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y))
function code(x, y, z, t) return Float64(Float64(x - Float64(y / Float64(z * 3.0))) + Float64(t / Float64(Float64(z * 3.0) * y))) end
function tmp = code(x, y, z, t) tmp = (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y)); end
code[x_, y_, z_, t_] := N[(N[(x - N[(y / N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t / N[(N[(z * 3.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (+ (- x (/ y (* z 3.0))) (/ t (* (* z 3.0) y))))
double code(double x, double y, double z, double t) {
return (x - (y / (z * 3.0))) + (t / ((z * 3.0) * 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, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (x - (y / (z * 3.0d0))) + (t / ((z * 3.0d0) * y))
end function
public static double code(double x, double y, double z, double t) {
return (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y));
}
def code(x, y, z, t): return (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y))
function code(x, y, z, t) return Float64(Float64(x - Float64(y / Float64(z * 3.0))) + Float64(t / Float64(Float64(z * 3.0) * y))) end
function tmp = code(x, y, z, t) tmp = (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y)); end
code[x_, y_, z_, t_] := N[(N[(x - N[(y / N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t / N[(N[(z * 3.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}
\end{array}
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- x (/ y (* z 3.0)))))
(if (<= t 4.2e+36)
(+ t_1 (/ (/ t z) (* 3.0 y)))
(+ t_1 (/ t (* (* z 3.0) y))))))
double code(double x, double y, double z, double t) {
double t_1 = x - (y / (z * 3.0));
double tmp;
if (t <= 4.2e+36) {
tmp = t_1 + ((t / z) / (3.0 * y));
} else {
tmp = t_1 + (t / ((z * 3.0) * 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, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = x - (y / (z * 3.0d0))
if (t <= 4.2d+36) then
tmp = t_1 + ((t / z) / (3.0d0 * y))
else
tmp = t_1 + (t / ((z * 3.0d0) * y))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = x - (y / (z * 3.0));
double tmp;
if (t <= 4.2e+36) {
tmp = t_1 + ((t / z) / (3.0 * y));
} else {
tmp = t_1 + (t / ((z * 3.0) * y));
}
return tmp;
}
def code(x, y, z, t): t_1 = x - (y / (z * 3.0)) tmp = 0 if t <= 4.2e+36: tmp = t_1 + ((t / z) / (3.0 * y)) else: tmp = t_1 + (t / ((z * 3.0) * y)) return tmp
function code(x, y, z, t) t_1 = Float64(x - Float64(y / Float64(z * 3.0))) tmp = 0.0 if (t <= 4.2e+36) tmp = Float64(t_1 + Float64(Float64(t / z) / Float64(3.0 * y))); else tmp = Float64(t_1 + Float64(t / Float64(Float64(z * 3.0) * y))); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = x - (y / (z * 3.0)); tmp = 0.0; if (t <= 4.2e+36) tmp = t_1 + ((t / z) / (3.0 * y)); else tmp = t_1 + (t / ((z * 3.0) * y)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x - N[(y / N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t, 4.2e+36], N[(t$95$1 + N[(N[(t / z), $MachinePrecision] / N[(3.0 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 + N[(t / N[(N[(z * 3.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x - \frac{y}{z \cdot 3}\\
\mathbf{if}\;t \leq 4.2 \cdot 10^{+36}:\\
\;\;\;\;t\_1 + \frac{\frac{t}{z}}{3 \cdot y}\\
\mathbf{else}:\\
\;\;\;\;t\_1 + \frac{t}{\left(z \cdot 3\right) \cdot y}\\
\end{array}
\end{array}
if t < 4.20000000000000009e36Initial program 94.7%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6499.3
Applied rewrites99.3%
if 4.20000000000000009e36 < t Initial program 98.1%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- x (/ (* 0.3333333333333333 y) z))))
(if (<= y -6.4e+15)
t_1
(if (<= y 6.2)
(+ x (/ (/ t (* 3.0 z)) y))
(if (<= y 1.5e+111) (* (- (/ t y) y) (/ 0.3333333333333333 z)) t_1)))))
double code(double x, double y, double z, double t) {
double t_1 = x - ((0.3333333333333333 * y) / z);
double tmp;
if (y <= -6.4e+15) {
tmp = t_1;
} else if (y <= 6.2) {
tmp = x + ((t / (3.0 * z)) / y);
} else if (y <= 1.5e+111) {
tmp = ((t / y) - y) * (0.3333333333333333 / z);
} else {
tmp = t_1;
}
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, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = x - ((0.3333333333333333d0 * y) / z)
if (y <= (-6.4d+15)) then
tmp = t_1
else if (y <= 6.2d0) then
tmp = x + ((t / (3.0d0 * z)) / y)
else if (y <= 1.5d+111) then
tmp = ((t / y) - y) * (0.3333333333333333d0 / z)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = x - ((0.3333333333333333 * y) / z);
double tmp;
if (y <= -6.4e+15) {
tmp = t_1;
} else if (y <= 6.2) {
tmp = x + ((t / (3.0 * z)) / y);
} else if (y <= 1.5e+111) {
tmp = ((t / y) - y) * (0.3333333333333333 / z);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = x - ((0.3333333333333333 * y) / z) tmp = 0 if y <= -6.4e+15: tmp = t_1 elif y <= 6.2: tmp = x + ((t / (3.0 * z)) / y) elif y <= 1.5e+111: tmp = ((t / y) - y) * (0.3333333333333333 / z) else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(x - Float64(Float64(0.3333333333333333 * y) / z)) tmp = 0.0 if (y <= -6.4e+15) tmp = t_1; elseif (y <= 6.2) tmp = Float64(x + Float64(Float64(t / Float64(3.0 * z)) / y)); elseif (y <= 1.5e+111) tmp = Float64(Float64(Float64(t / y) - y) * Float64(0.3333333333333333 / z)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = x - ((0.3333333333333333 * y) / z); tmp = 0.0; if (y <= -6.4e+15) tmp = t_1; elseif (y <= 6.2) tmp = x + ((t / (3.0 * z)) / y); elseif (y <= 1.5e+111) tmp = ((t / y) - y) * (0.3333333333333333 / z); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x - N[(N[(0.3333333333333333 * y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -6.4e+15], t$95$1, If[LessEqual[y, 6.2], N[(x + N[(N[(t / N[(3.0 * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.5e+111], N[(N[(N[(t / y), $MachinePrecision] - y), $MachinePrecision] * N[(0.3333333333333333 / z), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x - \frac{0.3333333333333333 \cdot y}{z}\\
\mathbf{if}\;y \leq -6.4 \cdot 10^{+15}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 6.2:\\
\;\;\;\;x + \frac{\frac{t}{3 \cdot z}}{y}\\
\mathbf{elif}\;y \leq 1.5 \cdot 10^{+111}:\\
\;\;\;\;\left(\frac{t}{y} - y\right) \cdot \frac{0.3333333333333333}{z}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -6.4e15 or 1.5e111 < y Initial program 98.0%
Taylor expanded in t around 0
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
lower-fma.f64N/A
lower-/.f6495.5
Applied rewrites95.5%
lift-/.f64N/A
lift-fma.f64N/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6495.5
Applied rewrites95.5%
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f6495.7
Applied rewrites95.7%
if -6.4e15 < y < 6.20000000000000018Initial program 92.6%
Taylor expanded in x around inf
Applied rewrites87.3%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6493.0
Applied rewrites93.0%
if 6.20000000000000018 < y < 1.5e111Initial program 99.7%
Taylor expanded in x around 0
associate-/r*N/A
associate-*r/N/A
associate-*r/N/A
div-subN/A
lower-/.f64N/A
distribute-lft-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f6481.3
Applied rewrites81.3%
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-/.f64N/A
associate-/l*N/A
metadata-evalN/A
associate-*r/N/A
lower-*.f64N/A
lift-/.f64N/A
lift--.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f6481.4
Applied rewrites81.4%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- x (/ (* 0.3333333333333333 y) z))))
(if (<= y -6.4e+15)
t_1
(if (<= y 14.5)
(+ x (/ t (* z (* 3.0 y))))
(if (<= y 1.5e+111) (* (- (/ t y) y) (/ 0.3333333333333333 z)) t_1)))))
double code(double x, double y, double z, double t) {
double t_1 = x - ((0.3333333333333333 * y) / z);
double tmp;
if (y <= -6.4e+15) {
tmp = t_1;
} else if (y <= 14.5) {
tmp = x + (t / (z * (3.0 * y)));
} else if (y <= 1.5e+111) {
tmp = ((t / y) - y) * (0.3333333333333333 / z);
} else {
tmp = t_1;
}
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, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = x - ((0.3333333333333333d0 * y) / z)
if (y <= (-6.4d+15)) then
tmp = t_1
else if (y <= 14.5d0) then
tmp = x + (t / (z * (3.0d0 * y)))
else if (y <= 1.5d+111) then
tmp = ((t / y) - y) * (0.3333333333333333d0 / z)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = x - ((0.3333333333333333 * y) / z);
double tmp;
if (y <= -6.4e+15) {
tmp = t_1;
} else if (y <= 14.5) {
tmp = x + (t / (z * (3.0 * y)));
} else if (y <= 1.5e+111) {
tmp = ((t / y) - y) * (0.3333333333333333 / z);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = x - ((0.3333333333333333 * y) / z) tmp = 0 if y <= -6.4e+15: tmp = t_1 elif y <= 14.5: tmp = x + (t / (z * (3.0 * y))) elif y <= 1.5e+111: tmp = ((t / y) - y) * (0.3333333333333333 / z) else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(x - Float64(Float64(0.3333333333333333 * y) / z)) tmp = 0.0 if (y <= -6.4e+15) tmp = t_1; elseif (y <= 14.5) tmp = Float64(x + Float64(t / Float64(z * Float64(3.0 * y)))); elseif (y <= 1.5e+111) tmp = Float64(Float64(Float64(t / y) - y) * Float64(0.3333333333333333 / z)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = x - ((0.3333333333333333 * y) / z); tmp = 0.0; if (y <= -6.4e+15) tmp = t_1; elseif (y <= 14.5) tmp = x + (t / (z * (3.0 * y))); elseif (y <= 1.5e+111) tmp = ((t / y) - y) * (0.3333333333333333 / z); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x - N[(N[(0.3333333333333333 * y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -6.4e+15], t$95$1, If[LessEqual[y, 14.5], N[(x + N[(t / N[(z * N[(3.0 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.5e+111], N[(N[(N[(t / y), $MachinePrecision] - y), $MachinePrecision] * N[(0.3333333333333333 / z), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x - \frac{0.3333333333333333 \cdot y}{z}\\
\mathbf{if}\;y \leq -6.4 \cdot 10^{+15}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 14.5:\\
\;\;\;\;x + \frac{t}{z \cdot \left(3 \cdot y\right)}\\
\mathbf{elif}\;y \leq 1.5 \cdot 10^{+111}:\\
\;\;\;\;\left(\frac{t}{y} - y\right) \cdot \frac{0.3333333333333333}{z}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -6.4e15 or 1.5e111 < y Initial program 98.0%
Taylor expanded in t around 0
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
lower-fma.f64N/A
lower-/.f6495.5
Applied rewrites95.5%
lift-/.f64N/A
lift-fma.f64N/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6495.5
Applied rewrites95.5%
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f6495.7
Applied rewrites95.7%
if -6.4e15 < y < 14.5Initial program 92.7%
Taylor expanded in x around inf
Applied rewrites87.4%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6487.5
Applied rewrites87.5%
if 14.5 < y < 1.5e111Initial program 99.7%
Taylor expanded in x around 0
associate-/r*N/A
associate-*r/N/A
associate-*r/N/A
div-subN/A
lower-/.f64N/A
distribute-lft-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f6480.7
Applied rewrites80.7%
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-/.f64N/A
associate-/l*N/A
metadata-evalN/A
associate-*r/N/A
lower-*.f64N/A
lift-/.f64N/A
lift--.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f6480.8
Applied rewrites80.8%
(FPCore (x y z t) :precision binary64 (if (or (<= y -6.4e+15) (not (<= y 7e+54))) (- x (/ (* 0.3333333333333333 y) z)) (+ x (/ t (* z (* 3.0 y))))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -6.4e+15) || !(y <= 7e+54)) {
tmp = x - ((0.3333333333333333 * y) / z);
} else {
tmp = x + (t / (z * (3.0 * 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, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((y <= (-6.4d+15)) .or. (.not. (y <= 7d+54))) then
tmp = x - ((0.3333333333333333d0 * y) / z)
else
tmp = x + (t / (z * (3.0d0 * y)))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -6.4e+15) || !(y <= 7e+54)) {
tmp = x - ((0.3333333333333333 * y) / z);
} else {
tmp = x + (t / (z * (3.0 * y)));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -6.4e+15) or not (y <= 7e+54): tmp = x - ((0.3333333333333333 * y) / z) else: tmp = x + (t / (z * (3.0 * y))) return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -6.4e+15) || !(y <= 7e+54)) tmp = Float64(x - Float64(Float64(0.3333333333333333 * y) / z)); else tmp = Float64(x + Float64(t / Float64(z * Float64(3.0 * y)))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= -6.4e+15) || ~((y <= 7e+54))) tmp = x - ((0.3333333333333333 * y) / z); else tmp = x + (t / (z * (3.0 * y))); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -6.4e+15], N[Not[LessEqual[y, 7e+54]], $MachinePrecision]], N[(x - N[(N[(0.3333333333333333 * y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(x + N[(t / N[(z * N[(3.0 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.4 \cdot 10^{+15} \lor \neg \left(y \leq 7 \cdot 10^{+54}\right):\\
\;\;\;\;x - \frac{0.3333333333333333 \cdot y}{z}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{t}{z \cdot \left(3 \cdot y\right)}\\
\end{array}
\end{array}
if y < -6.4e15 or 7.0000000000000002e54 < y Initial program 98.1%
Taylor expanded in t around 0
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
lower-fma.f64N/A
lower-/.f6494.0
Applied rewrites94.0%
lift-/.f64N/A
lift-fma.f64N/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6494.0
Applied rewrites94.0%
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f6494.2
Applied rewrites94.2%
if -6.4e15 < y < 7.0000000000000002e54Initial program 93.7%
Taylor expanded in x around inf
Applied rewrites84.0%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6484.1
Applied rewrites84.1%
Final simplification88.3%
(FPCore (x y z t) :precision binary64 (if (or (<= y -6.4e+15) (not (<= y 7e+54))) (- x (/ (* 0.3333333333333333 y) z)) (fma (/ t (* z y)) 0.3333333333333333 x)))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -6.4e+15) || !(y <= 7e+54)) {
tmp = x - ((0.3333333333333333 * y) / z);
} else {
tmp = fma((t / (z * y)), 0.3333333333333333, x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if ((y <= -6.4e+15) || !(y <= 7e+54)) tmp = Float64(x - Float64(Float64(0.3333333333333333 * y) / z)); else tmp = fma(Float64(t / Float64(z * y)), 0.3333333333333333, x); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -6.4e+15], N[Not[LessEqual[y, 7e+54]], $MachinePrecision]], N[(x - N[(N[(0.3333333333333333 * y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(N[(t / N[(z * y), $MachinePrecision]), $MachinePrecision] * 0.3333333333333333 + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.4 \cdot 10^{+15} \lor \neg \left(y \leq 7 \cdot 10^{+54}\right):\\
\;\;\;\;x - \frac{0.3333333333333333 \cdot y}{z}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t}{z \cdot y}, 0.3333333333333333, x\right)\\
\end{array}
\end{array}
if y < -6.4e15 or 7.0000000000000002e54 < y Initial program 98.1%
Taylor expanded in t around 0
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
lower-fma.f64N/A
lower-/.f6494.0
Applied rewrites94.0%
lift-/.f64N/A
lift-fma.f64N/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6494.0
Applied rewrites94.0%
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f6494.2
Applied rewrites94.2%
if -6.4e15 < y < 7.0000000000000002e54Initial program 93.7%
Taylor expanded in x around 0
associate--l+N/A
distribute-lft-out--N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
associate-/r*N/A
sub-divN/A
associate-/l*N/A
distribute-lft-out--N/A
*-lft-identityN/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
Applied rewrites94.0%
Taylor expanded in y around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f6483.9
Applied rewrites83.9%
Final simplification88.2%
(FPCore (x y z t) :precision binary64 (if (or (<= y -2.4e-26) (not (<= y 8.1e-13))) (- x (/ (* 0.3333333333333333 y) z)) (* (/ t (* z y)) 0.3333333333333333)))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -2.4e-26) || !(y <= 8.1e-13)) {
tmp = x - ((0.3333333333333333 * y) / z);
} else {
tmp = (t / (z * y)) * 0.3333333333333333;
}
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, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((y <= (-2.4d-26)) .or. (.not. (y <= 8.1d-13))) then
tmp = x - ((0.3333333333333333d0 * y) / z)
else
tmp = (t / (z * y)) * 0.3333333333333333d0
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -2.4e-26) || !(y <= 8.1e-13)) {
tmp = x - ((0.3333333333333333 * y) / z);
} else {
tmp = (t / (z * y)) * 0.3333333333333333;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -2.4e-26) or not (y <= 8.1e-13): tmp = x - ((0.3333333333333333 * y) / z) else: tmp = (t / (z * y)) * 0.3333333333333333 return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -2.4e-26) || !(y <= 8.1e-13)) tmp = Float64(x - Float64(Float64(0.3333333333333333 * y) / z)); else tmp = Float64(Float64(t / Float64(z * y)) * 0.3333333333333333); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= -2.4e-26) || ~((y <= 8.1e-13))) tmp = x - ((0.3333333333333333 * y) / z); else tmp = (t / (z * y)) * 0.3333333333333333; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -2.4e-26], N[Not[LessEqual[y, 8.1e-13]], $MachinePrecision]], N[(x - N[(N[(0.3333333333333333 * y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(N[(t / N[(z * y), $MachinePrecision]), $MachinePrecision] * 0.3333333333333333), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.4 \cdot 10^{-26} \lor \neg \left(y \leq 8.1 \cdot 10^{-13}\right):\\
\;\;\;\;x - \frac{0.3333333333333333 \cdot y}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{t}{z \cdot y} \cdot 0.3333333333333333\\
\end{array}
\end{array}
if y < -2.4000000000000001e-26 or 8.0999999999999998e-13 < y Initial program 98.5%
Taylor expanded in t around 0
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
lower-fma.f64N/A
lower-/.f6487.0
Applied rewrites87.0%
lift-/.f64N/A
lift-fma.f64N/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6487.0
Applied rewrites87.0%
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f6487.1
Applied rewrites87.1%
if -2.4000000000000001e-26 < y < 8.0999999999999998e-13Initial program 91.6%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6466.9
Applied rewrites66.9%
Final simplification78.3%
(FPCore (x y z t) :precision binary64 (fma (/ (- (/ t y) y) z) 0.3333333333333333 x))
double code(double x, double y, double z, double t) {
return fma((((t / y) - y) / z), 0.3333333333333333, x);
}
function code(x, y, z, t) return fma(Float64(Float64(Float64(t / y) - y) / z), 0.3333333333333333, x) end
code[x_, y_, z_, t_] := N[(N[(N[(N[(t / y), $MachinePrecision] - y), $MachinePrecision] / z), $MachinePrecision] * 0.3333333333333333 + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{\frac{t}{y} - y}{z}, 0.3333333333333333, x\right)
\end{array}
Initial program 95.5%
Taylor expanded in x around 0
associate--l+N/A
distribute-lft-out--N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
associate-/r*N/A
sub-divN/A
associate-/l*N/A
distribute-lft-out--N/A
*-lft-identityN/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
Applied rewrites96.4%
(FPCore (x y z t) :precision binary64 (if (or (<= z -2.8e+73) (not (<= z 1.4e+158))) x (/ (* -0.3333333333333333 y) z)))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -2.8e+73) || !(z <= 1.4e+158)) {
tmp = x;
} else {
tmp = (-0.3333333333333333 * y) / z;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((z <= (-2.8d+73)) .or. (.not. (z <= 1.4d+158))) then
tmp = x
else
tmp = ((-0.3333333333333333d0) * y) / z
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -2.8e+73) || !(z <= 1.4e+158)) {
tmp = x;
} else {
tmp = (-0.3333333333333333 * y) / z;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -2.8e+73) or not (z <= 1.4e+158): tmp = x else: tmp = (-0.3333333333333333 * y) / z return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -2.8e+73) || !(z <= 1.4e+158)) tmp = x; else tmp = Float64(Float64(-0.3333333333333333 * y) / z); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -2.8e+73) || ~((z <= 1.4e+158))) tmp = x; else tmp = (-0.3333333333333333 * y) / z; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -2.8e+73], N[Not[LessEqual[z, 1.4e+158]], $MachinePrecision]], x, N[(N[(-0.3333333333333333 * y), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.8 \cdot 10^{+73} \lor \neg \left(z \leq 1.4 \cdot 10^{+158}\right):\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.3333333333333333 \cdot y}{z}\\
\end{array}
\end{array}
if z < -2.80000000000000008e73 or 1.40000000000000001e158 < z Initial program 98.6%
Taylor expanded in x around inf
Applied rewrites58.8%
if -2.80000000000000008e73 < z < 1.40000000000000001e158Initial program 94.2%
Taylor expanded in x around 0
associate-/r*N/A
associate-*r/N/A
associate-*r/N/A
div-subN/A
lower-/.f64N/A
distribute-lft-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f6486.4
Applied rewrites86.4%
Taylor expanded in y around inf
lower-*.f6446.8
Applied rewrites46.8%
Final simplification50.4%
(FPCore (x y z t) :precision binary64 (if (<= z -2.8e+73) x (if (<= z 1.4e+158) (* -0.3333333333333333 (/ y z)) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -2.8e+73) {
tmp = x;
} else if (z <= 1.4e+158) {
tmp = -0.3333333333333333 * (y / z);
} else {
tmp = 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, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (z <= (-2.8d+73)) then
tmp = x
else if (z <= 1.4d+158) then
tmp = (-0.3333333333333333d0) * (y / z)
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -2.8e+73) {
tmp = x;
} else if (z <= 1.4e+158) {
tmp = -0.3333333333333333 * (y / z);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -2.8e+73: tmp = x elif z <= 1.4e+158: tmp = -0.3333333333333333 * (y / z) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -2.8e+73) tmp = x; elseif (z <= 1.4e+158) tmp = Float64(-0.3333333333333333 * Float64(y / z)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -2.8e+73) tmp = x; elseif (z <= 1.4e+158) tmp = -0.3333333333333333 * (y / z); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -2.8e+73], x, If[LessEqual[z, 1.4e+158], N[(-0.3333333333333333 * N[(y / z), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.8 \cdot 10^{+73}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 1.4 \cdot 10^{+158}:\\
\;\;\;\;-0.3333333333333333 \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -2.80000000000000008e73 or 1.40000000000000001e158 < z Initial program 98.6%
Taylor expanded in x around inf
Applied rewrites58.8%
if -2.80000000000000008e73 < z < 1.40000000000000001e158Initial program 94.2%
Taylor expanded in y around inf
lower-*.f64N/A
lower-/.f6446.8
Applied rewrites46.8%
(FPCore (x y z t) :precision binary64 (- x (/ (* 0.3333333333333333 y) z)))
double code(double x, double y, double z, double t) {
return x - ((0.3333333333333333 * y) / z);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x - ((0.3333333333333333d0 * y) / z)
end function
public static double code(double x, double y, double z, double t) {
return x - ((0.3333333333333333 * y) / z);
}
def code(x, y, z, t): return x - ((0.3333333333333333 * y) / z)
function code(x, y, z, t) return Float64(x - Float64(Float64(0.3333333333333333 * y) / z)) end
function tmp = code(x, y, z, t) tmp = x - ((0.3333333333333333 * y) / z); end
code[x_, y_, z_, t_] := N[(x - N[(N[(0.3333333333333333 * y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \frac{0.3333333333333333 \cdot y}{z}
\end{array}
Initial program 95.5%
Taylor expanded in t around 0
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
lower-fma.f64N/A
lower-/.f6461.8
Applied rewrites61.8%
lift-/.f64N/A
lift-fma.f64N/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6461.8
Applied rewrites61.8%
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f6461.9
Applied rewrites61.9%
(FPCore (x y z t) :precision binary64 (- x (* (/ y z) 0.3333333333333333)))
double code(double x, double y, double z, double t) {
return x - ((y / z) * 0.3333333333333333);
}
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, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x - ((y / z) * 0.3333333333333333d0)
end function
public static double code(double x, double y, double z, double t) {
return x - ((y / z) * 0.3333333333333333);
}
def code(x, y, z, t): return x - ((y / z) * 0.3333333333333333)
function code(x, y, z, t) return Float64(x - Float64(Float64(y / z) * 0.3333333333333333)) end
function tmp = code(x, y, z, t) tmp = x - ((y / z) * 0.3333333333333333); end
code[x_, y_, z_, t_] := N[(x - N[(N[(y / z), $MachinePrecision] * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \frac{y}{z} \cdot 0.3333333333333333
\end{array}
Initial program 95.5%
Taylor expanded in t around 0
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
lower-fma.f64N/A
lower-/.f6461.8
Applied rewrites61.8%
lift-/.f64N/A
lift-fma.f64N/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6461.8
Applied rewrites61.8%
(FPCore (x y z t) :precision binary64 (fma -0.3333333333333333 (/ y z) x))
double code(double x, double y, double z, double t) {
return fma(-0.3333333333333333, (y / z), x);
}
function code(x, y, z, t) return fma(-0.3333333333333333, Float64(y / z), x) end
code[x_, y_, z_, t_] := N[(-0.3333333333333333 * N[(y / z), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(-0.3333333333333333, \frac{y}{z}, x\right)
\end{array}
Initial program 95.5%
Taylor expanded in t around 0
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
lower-fma.f64N/A
lower-/.f6461.8
Applied rewrites61.8%
(FPCore (x y z t) :precision binary64 x)
double code(double x, double y, double z, double t) {
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, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x
end function
public static double code(double x, double y, double z, double t) {
return x;
}
def code(x, y, z, t): return x
function code(x, y, z, t) return x end
function tmp = code(x, y, z, t) tmp = x; end
code[x_, y_, z_, t_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 95.5%
Taylor expanded in x around inf
Applied rewrites26.6%
(FPCore (x y z t) :precision binary64 (+ (- x (/ y (* z 3.0))) (/ (/ t (* z 3.0)) y)))
double code(double x, double y, double z, double t) {
return (x - (y / (z * 3.0))) + ((t / (z * 3.0)) / 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, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (x - (y / (z * 3.0d0))) + ((t / (z * 3.0d0)) / y)
end function
public static double code(double x, double y, double z, double t) {
return (x - (y / (z * 3.0))) + ((t / (z * 3.0)) / y);
}
def code(x, y, z, t): return (x - (y / (z * 3.0))) + ((t / (z * 3.0)) / y)
function code(x, y, z, t) return Float64(Float64(x - Float64(y / Float64(z * 3.0))) + Float64(Float64(t / Float64(z * 3.0)) / y)) end
function tmp = code(x, y, z, t) tmp = (x - (y / (z * 3.0))) + ((t / (z * 3.0)) / y); end
code[x_, y_, z_, t_] := N[(N[(x - N[(y / N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(t / N[(z * 3.0), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x - \frac{y}{z \cdot 3}\right) + \frac{\frac{t}{z \cdot 3}}{y}
\end{array}
herbie shell --seed 2025060
(FPCore (x y z t)
:name "Diagrams.Solve.Polynomial:cubForm from diagrams-solve-0.1, H"
:precision binary64
:alt
(! :herbie-platform default (+ (- x (/ y (* z 3))) (/ (/ t (* z 3)) y)))
(+ (- x (/ y (* z 3.0))) (/ t (* (* z 3.0) y))))