
(FPCore (x y z t) :precision binary64 (+ x (/ (* (- y x) z) t)))
double code(double x, double y, double z, double t) {
return x + (((y - x) * z) / t);
}
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 - x) * z) / t)
end function
public static double code(double x, double y, double z, double t) {
return x + (((y - x) * z) / t);
}
def code(x, y, z, t): return x + (((y - x) * z) / t)
function code(x, y, z, t) return Float64(x + Float64(Float64(Float64(y - x) * z) / t)) end
function tmp = code(x, y, z, t) tmp = x + (((y - x) * z) / t); end
code[x_, y_, z_, t_] := N[(x + N[(N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{\left(y - x\right) \cdot z}{t}
\end{array}
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (+ x (/ (* (- y x) z) t)))
double code(double x, double y, double z, double t) {
return x + (((y - x) * z) / t);
}
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 - x) * z) / t)
end function
public static double code(double x, double y, double z, double t) {
return x + (((y - x) * z) / t);
}
def code(x, y, z, t): return x + (((y - x) * z) / t)
function code(x, y, z, t) return Float64(x + Float64(Float64(Float64(y - x) * z) / t)) end
function tmp = code(x, y, z, t) tmp = x + (((y - x) * z) / t); end
code[x_, y_, z_, t_] := N[(x + N[(N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{\left(y - x\right) \cdot z}{t}
\end{array}
(FPCore (x y z t) :precision binary64 (fma (/ z t) (- y x) x))
double code(double x, double y, double z, double t) {
return fma((z / t), (y - x), x);
}
function code(x, y, z, t) return fma(Float64(z / t), Float64(y - x), x) end
code[x_, y_, z_, t_] := N[(N[(z / t), $MachinePrecision] * N[(y - x), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{z}{t}, y - x, x\right)
\end{array}
Initial program 93.1%
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6497.6
Applied rewrites97.6%
(FPCore (x y z t) :precision binary64 (if (<= x -0.0037) (* (/ (- t z) t) x) (if (<= x 1.8e+52) (fma (/ y t) z x) (* (- 1.0 (/ z t)) x))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -0.0037) {
tmp = ((t - z) / t) * x;
} else if (x <= 1.8e+52) {
tmp = fma((y / t), z, x);
} else {
tmp = (1.0 - (z / t)) * x;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (x <= -0.0037) tmp = Float64(Float64(Float64(t - z) / t) * x); elseif (x <= 1.8e+52) tmp = fma(Float64(y / t), z, x); else tmp = Float64(Float64(1.0 - Float64(z / t)) * x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[x, -0.0037], N[(N[(N[(t - z), $MachinePrecision] / t), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[x, 1.8e+52], N[(N[(y / t), $MachinePrecision] * z + x), $MachinePrecision], N[(N[(1.0 - N[(z / t), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.0037:\\
\;\;\;\;\frac{t - z}{t} \cdot x\\
\mathbf{elif}\;x \leq 1.8 \cdot 10^{+52}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{t}, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 - \frac{z}{t}\right) \cdot x\\
\end{array}
\end{array}
if x < -0.0037000000000000002Initial program 91.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
cancel-sign-subN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-/.f6486.6
Applied rewrites86.6%
Taylor expanded in t around 0
lower-/.f64N/A
lower--.f6486.5
Applied rewrites86.5%
if -0.0037000000000000002 < x < 1.8e52Initial program 94.8%
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
sub-divN/A
*-commutativeN/A
lower-fma.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6494.5
Applied rewrites94.5%
Taylor expanded in x around 0
lower-/.f6481.6
Applied rewrites81.6%
if 1.8e52 < x Initial program 91.2%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
cancel-sign-subN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-/.f6489.9
Applied rewrites89.9%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* (/ (- t z) t) x))) (if (<= x -0.0037) t_1 (if (<= x 1.8e+52) (fma (/ y t) z x) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = ((t - z) / t) * x;
double tmp;
if (x <= -0.0037) {
tmp = t_1;
} else if (x <= 1.8e+52) {
tmp = fma((y / t), z, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(Float64(t - z) / t) * x) tmp = 0.0 if (x <= -0.0037) tmp = t_1; elseif (x <= 1.8e+52) tmp = fma(Float64(y / t), z, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(N[(t - z), $MachinePrecision] / t), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[x, -0.0037], t$95$1, If[LessEqual[x, 1.8e+52], N[(N[(y / t), $MachinePrecision] * z + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{t - z}{t} \cdot x\\
\mathbf{if}\;x \leq -0.0037:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 1.8 \cdot 10^{+52}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{t}, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -0.0037000000000000002 or 1.8e52 < x Initial program 91.1%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
cancel-sign-subN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-/.f6488.0
Applied rewrites88.0%
Taylor expanded in t around 0
lower-/.f64N/A
lower--.f6488.0
Applied rewrites88.0%
if -0.0037000000000000002 < x < 1.8e52Initial program 94.8%
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
sub-divN/A
*-commutativeN/A
lower-fma.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6494.5
Applied rewrites94.5%
Taylor expanded in x around 0
lower-/.f6481.6
Applied rewrites81.6%
(FPCore (x y z t) :precision binary64 (if (<= x -5.8e+285) (/ (* (- x) z) t) (fma y (/ z t) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -5.8e+285) {
tmp = (-x * z) / t;
} else {
tmp = fma(y, (z / t), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (x <= -5.8e+285) tmp = Float64(Float64(Float64(-x) * z) / t); else tmp = fma(y, Float64(z / t), x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[x, -5.8e+285], N[(N[((-x) * z), $MachinePrecision] / t), $MachinePrecision], N[(y * N[(z / t), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.8 \cdot 10^{+285}:\\
\;\;\;\;\frac{\left(-x\right) \cdot z}{t}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z}{t}, x\right)\\
\end{array}
\end{array}
if x < -5.80000000000000036e285Initial program 89.5%
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f64100.0
Applied rewrites100.0%
Taylor expanded in y around 0
associate-*l/N/A
*-commutativeN/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-outN/A
associate-*r/N/A
distribute-frac-neg2N/A
mul-1-negN/A
frac-2negN/A
lower--.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-/.f6498.1
Applied rewrites98.1%
Taylor expanded in z around inf
associate-*r/N/A
lower-/.f64N/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6453.9
Applied rewrites53.9%
if -5.80000000000000036e285 < x Initial program 93.1%
Taylor expanded in x around 0
Applied rewrites73.2%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
lift-/.f6476.6
Applied rewrites76.6%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* y (/ z t))))
(if (<= t -650000000000.0)
x
(if (<= t 7.4e-242)
t_1
(if (<= t 2600.0) (/ (* (- x) z) t) (if (<= t 1.65e+53) t_1 x))))))
double code(double x, double y, double z, double t) {
double t_1 = y * (z / t);
double tmp;
if (t <= -650000000000.0) {
tmp = x;
} else if (t <= 7.4e-242) {
tmp = t_1;
} else if (t <= 2600.0) {
tmp = (-x * z) / t;
} else if (t <= 1.65e+53) {
tmp = t_1;
} 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) :: t_1
real(8) :: tmp
t_1 = y * (z / t)
if (t <= (-650000000000.0d0)) then
tmp = x
else if (t <= 7.4d-242) then
tmp = t_1
else if (t <= 2600.0d0) then
tmp = (-x * z) / t
else if (t <= 1.65d+53) then
tmp = t_1
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = y * (z / t);
double tmp;
if (t <= -650000000000.0) {
tmp = x;
} else if (t <= 7.4e-242) {
tmp = t_1;
} else if (t <= 2600.0) {
tmp = (-x * z) / t;
} else if (t <= 1.65e+53) {
tmp = t_1;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): t_1 = y * (z / t) tmp = 0 if t <= -650000000000.0: tmp = x elif t <= 7.4e-242: tmp = t_1 elif t <= 2600.0: tmp = (-x * z) / t elif t <= 1.65e+53: tmp = t_1 else: tmp = x return tmp
function code(x, y, z, t) t_1 = Float64(y * Float64(z / t)) tmp = 0.0 if (t <= -650000000000.0) tmp = x; elseif (t <= 7.4e-242) tmp = t_1; elseif (t <= 2600.0) tmp = Float64(Float64(Float64(-x) * z) / t); elseif (t <= 1.65e+53) tmp = t_1; else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = y * (z / t); tmp = 0.0; if (t <= -650000000000.0) tmp = x; elseif (t <= 7.4e-242) tmp = t_1; elseif (t <= 2600.0) tmp = (-x * z) / t; elseif (t <= 1.65e+53) tmp = t_1; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t, -650000000000.0], x, If[LessEqual[t, 7.4e-242], t$95$1, If[LessEqual[t, 2600.0], N[(N[((-x) * z), $MachinePrecision] / t), $MachinePrecision], If[LessEqual[t, 1.65e+53], t$95$1, x]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := y \cdot \frac{z}{t}\\
\mathbf{if}\;t \leq -650000000000:\\
\;\;\;\;x\\
\mathbf{elif}\;t \leq 7.4 \cdot 10^{-242}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 2600:\\
\;\;\;\;\frac{\left(-x\right) \cdot z}{t}\\
\mathbf{elif}\;t \leq 1.65 \cdot 10^{+53}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if t < -6.5e11 or 1.6500000000000001e53 < t Initial program 86.1%
Taylor expanded in z around 0
Applied rewrites61.3%
if -6.5e11 < t < 7.39999999999999994e-242 or 2600 < t < 1.6500000000000001e53Initial program 98.4%
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6497.0
Applied rewrites97.0%
Taylor expanded in x around 0
associate-*l/N/A
*-commutativeN/A
+-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lift-/.f6450.1
Applied rewrites50.1%
if 7.39999999999999994e-242 < t < 2600Initial program 99.1%
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6497.0
Applied rewrites97.0%
Taylor expanded in y around 0
associate-*l/N/A
*-commutativeN/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-outN/A
associate-*r/N/A
distribute-frac-neg2N/A
mul-1-negN/A
frac-2negN/A
lower--.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-/.f6459.3
Applied rewrites59.3%
Taylor expanded in z around inf
associate-*r/N/A
lower-/.f64N/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6439.2
Applied rewrites39.2%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* y (/ z t)))) (if (<= y -4.5e+100) t_1 (if (<= y 3.25e-153) x t_1))))
double code(double x, double y, double z, double t) {
double t_1 = y * (z / t);
double tmp;
if (y <= -4.5e+100) {
tmp = t_1;
} else if (y <= 3.25e-153) {
tmp = x;
} 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 = y * (z / t)
if (y <= (-4.5d+100)) then
tmp = t_1
else if (y <= 3.25d-153) then
tmp = x
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 = y * (z / t);
double tmp;
if (y <= -4.5e+100) {
tmp = t_1;
} else if (y <= 3.25e-153) {
tmp = x;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = y * (z / t) tmp = 0 if y <= -4.5e+100: tmp = t_1 elif y <= 3.25e-153: tmp = x else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(y * Float64(z / t)) tmp = 0.0 if (y <= -4.5e+100) tmp = t_1; elseif (y <= 3.25e-153) tmp = x; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = y * (z / t); tmp = 0.0; if (y <= -4.5e+100) tmp = t_1; elseif (y <= 3.25e-153) tmp = x; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -4.5e+100], t$95$1, If[LessEqual[y, 3.25e-153], x, t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := y \cdot \frac{z}{t}\\
\mathbf{if}\;y \leq -4.5 \cdot 10^{+100}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 3.25 \cdot 10^{-153}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -4.50000000000000036e100 or 3.25000000000000016e-153 < y Initial program 91.6%
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6497.9
Applied rewrites97.9%
Taylor expanded in x around 0
associate-*l/N/A
*-commutativeN/A
+-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lift-/.f6455.5
Applied rewrites55.5%
if -4.50000000000000036e100 < y < 3.25000000000000016e-153Initial program 94.9%
Taylor expanded in z around 0
Applied rewrites45.9%
(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 93.1%
Taylor expanded in z around 0
Applied rewrites38.4%
herbie shell --seed 2025115
(FPCore (x y z t)
:name "Numeric.Histogram:binBounds from Chart-1.5.3"
:precision binary64
(+ x (/ (* (- y x) z) t)))