
(FPCore (x y z t) :precision binary64 (+ x (/ (* y (- z x)) t)))
double code(double x, double y, double z, double t) {
return x + ((y * (z - x)) / 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 * (z - x)) / t)
end function
public static double code(double x, double y, double z, double t) {
return x + ((y * (z - x)) / t);
}
def code(x, y, z, t): return x + ((y * (z - x)) / t)
function code(x, y, z, t) return Float64(x + Float64(Float64(y * Float64(z - x)) / t)) end
function tmp = code(x, y, z, t) tmp = x + ((y * (z - x)) / t); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y \cdot \left(z - x\right)}{t}
\end{array}
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (+ x (/ (* y (- z x)) t)))
double code(double x, double y, double z, double t) {
return x + ((y * (z - x)) / 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 * (z - x)) / t)
end function
public static double code(double x, double y, double z, double t) {
return x + ((y * (z - x)) / t);
}
def code(x, y, z, t): return x + ((y * (z - x)) / t)
function code(x, y, z, t) return Float64(x + Float64(Float64(y * Float64(z - x)) / t)) end
function tmp = code(x, y, z, t) tmp = x + ((y * (z - x)) / t); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y \cdot \left(z - x\right)}{t}
\end{array}
(FPCore (x y z t) :precision binary64 (let* ((t_1 (fma (/ (- z x) t) y x)) (t_2 (+ x (/ (* y (- z x)) t)))) (if (<= t_2 (- INFINITY)) t_1 (if (<= t_2 5e+293) t_2 t_1))))
double code(double x, double y, double z, double t) {
double t_1 = fma(((z - x) / t), y, x);
double t_2 = x + ((y * (z - x)) / t);
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = t_1;
} else if (t_2 <= 5e+293) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = fma(Float64(Float64(z - x) / t), y, x) t_2 = Float64(x + Float64(Float64(y * Float64(z - x)) / t)) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = t_1; elseif (t_2 <= 5e+293) tmp = t_2; else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(N[(z - x), $MachinePrecision] / t), $MachinePrecision] * y + x), $MachinePrecision]}, Block[{t$95$2 = N[(x + N[(N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], t$95$1, If[LessEqual[t$95$2, 5e+293], t$95$2, t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{z - x}{t}, y, x\right)\\
t_2 := x + \frac{y \cdot \left(z - x\right)}{t}\\
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+293}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (+.f64 x (/.f64 (*.f64 y (-.f64 z x)) t)) < -inf.0 or 5.00000000000000033e293 < (+.f64 x (/.f64 (*.f64 y (-.f64 z x)) t)) Initial program 80.3%
Applied rewrites98.9%
if -inf.0 < (+.f64 x (/.f64 (*.f64 y (-.f64 z x)) t)) < 5.00000000000000033e293Initial program 98.8%
(FPCore (x y z t) :precision binary64 (fma (/ (- z x) t) y x))
double code(double x, double y, double z, double t) {
return fma(((z - x) / t), y, x);
}
function code(x, y, z, t) return fma(Float64(Float64(z - x) / t), y, x) end
code[x_, y_, z_, t_] := N[(N[(N[(z - x), $MachinePrecision] / t), $MachinePrecision] * y + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{z - x}{t}, y, x\right)
\end{array}
Initial program 92.8%
Applied rewrites92.8%
(FPCore (x y z t) :precision binary64 (if (<= x -4e+50) (- x (* (/ y t) x)) (if (<= x 1.6e+101) (fma z (/ y t) x) (* (- 1.0 (/ y t)) x))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -4e+50) {
tmp = x - ((y / t) * x);
} else if (x <= 1.6e+101) {
tmp = fma(z, (y / t), x);
} else {
tmp = (1.0 - (y / t)) * x;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (x <= -4e+50) tmp = Float64(x - Float64(Float64(y / t) * x)); elseif (x <= 1.6e+101) tmp = fma(z, Float64(y / t), x); else tmp = Float64(Float64(1.0 - Float64(y / t)) * x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[x, -4e+50], N[(x - N[(N[(y / t), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.6e+101], N[(z * N[(y / t), $MachinePrecision] + x), $MachinePrecision], N[(N[(1.0 - N[(y / t), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4 \cdot 10^{+50}:\\
\;\;\;\;x - \frac{y}{t} \cdot x\\
\mathbf{elif}\;x \leq 1.6 \cdot 10^{+101}:\\
\;\;\;\;\mathsf{fma}\left(z, \frac{y}{t}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 - \frac{y}{t}\right) \cdot x\\
\end{array}
\end{array}
if x < -4.0000000000000003e50Initial program 89.4%
Taylor expanded in x around inf
+-commutativeN/A
distribute-rgt-inN/A
associate-*l*N/A
associate-*l/N/A
*-commutativeN/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
mul-1-negN/A
associate-/l*N/A
distribute-lft-neg-inN/A
distribute-lft-out--N/A
mul-1-negN/A
associate-*r*N/A
mul-1-negN/A
distribute-lft-neg-outN/A
distribute-lft-out--N/A
Applied rewrites88.7%
lift-*.f64N/A
lift--.f64N/A
lift-/.f64N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
distribute-lft1-inN/A
lower-fma.f64N/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6488.7
Applied rewrites88.7%
lift-fma.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
mul-1-negN/A
mul-1-negN/A
fp-cancel-sub-signN/A
associate-*l/N/A
*-commutativeN/A
lower--.f64N/A
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lift-/.f6488.7
Applied rewrites88.7%
if -4.0000000000000003e50 < x < 1.60000000000000003e101Initial program 94.9%
Taylor expanded in x around 0
Applied rewrites79.9%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lift-/.f6482.6
Applied rewrites82.6%
if 1.60000000000000003e101 < x Initial program 88.9%
Taylor expanded in x around inf
+-commutativeN/A
distribute-rgt-inN/A
associate-*l*N/A
associate-*l/N/A
*-commutativeN/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
mul-1-negN/A
associate-/l*N/A
distribute-lft-neg-inN/A
distribute-lft-out--N/A
mul-1-negN/A
associate-*r*N/A
mul-1-negN/A
distribute-lft-neg-outN/A
distribute-lft-out--N/A
Applied rewrites92.0%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* (- 1.0 (/ y t)) x))) (if (<= x -4e+50) t_1 (if (<= x 1.6e+101) (fma z (/ y t) x) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = (1.0 - (y / t)) * x;
double tmp;
if (x <= -4e+50) {
tmp = t_1;
} else if (x <= 1.6e+101) {
tmp = fma(z, (y / t), x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(1.0 - Float64(y / t)) * x) tmp = 0.0 if (x <= -4e+50) tmp = t_1; elseif (x <= 1.6e+101) tmp = fma(z, Float64(y / t), x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(1.0 - N[(y / t), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[x, -4e+50], t$95$1, If[LessEqual[x, 1.6e+101], N[(z * N[(y / t), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(1 - \frac{y}{t}\right) \cdot x\\
\mathbf{if}\;x \leq -4 \cdot 10^{+50}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 1.6 \cdot 10^{+101}:\\
\;\;\;\;\mathsf{fma}\left(z, \frac{y}{t}, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -4.0000000000000003e50 or 1.60000000000000003e101 < x Initial program 89.2%
Taylor expanded in x around inf
+-commutativeN/A
distribute-rgt-inN/A
associate-*l*N/A
associate-*l/N/A
*-commutativeN/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
mul-1-negN/A
associate-/l*N/A
distribute-lft-neg-inN/A
distribute-lft-out--N/A
mul-1-negN/A
associate-*r*N/A
mul-1-negN/A
distribute-lft-neg-outN/A
distribute-lft-out--N/A
Applied rewrites90.2%
if -4.0000000000000003e50 < x < 1.60000000000000003e101Initial program 94.9%
Taylor expanded in x around 0
Applied rewrites79.9%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lift-/.f6482.6
Applied rewrites82.6%
(FPCore (x y z t) :precision binary64 (if (<= y -1.45e+241) (* (- y) (/ x t)) (fma z (/ y t) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.45e+241) {
tmp = -y * (x / t);
} else {
tmp = fma(z, (y / t), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= -1.45e+241) tmp = Float64(Float64(-y) * Float64(x / t)); else tmp = fma(z, Float64(y / t), x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -1.45e+241], N[((-y) * N[(x / t), $MachinePrecision]), $MachinePrecision], N[(z * N[(y / t), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.45 \cdot 10^{+241}:\\
\;\;\;\;\left(-y\right) \cdot \frac{x}{t}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, \frac{y}{t}, x\right)\\
\end{array}
\end{array}
if y < -1.4500000000000001e241Initial program 82.0%
Taylor expanded in x around inf
+-commutativeN/A
distribute-rgt-inN/A
associate-*l*N/A
associate-*l/N/A
*-commutativeN/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
mul-1-negN/A
associate-/l*N/A
distribute-lft-neg-inN/A
distribute-lft-out--N/A
mul-1-negN/A
associate-*r*N/A
mul-1-negN/A
distribute-lft-neg-outN/A
distribute-lft-out--N/A
Applied rewrites59.0%
Taylor expanded in y around inf
associate-*r/N/A
mul-1-negN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
associate-*r/N/A
mul-1-negN/A
associate-*r/N/A
associate-*r*N/A
*-commutativeN/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
lift-/.f6452.8
Applied rewrites52.8%
if -1.4500000000000001e241 < y Initial program 93.4%
Taylor expanded in x around 0
Applied rewrites73.7%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lift-/.f6476.9
Applied rewrites76.9%
(FPCore (x y z t) :precision binary64 (if (<= t -0.021) x (if (<= t 8.4e+113) (* (/ y t) z) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -0.021) {
tmp = x;
} else if (t <= 8.4e+113) {
tmp = (y / t) * 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 (t <= (-0.021d0)) then
tmp = x
else if (t <= 8.4d+113) then
tmp = (y / t) * 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 (t <= -0.021) {
tmp = x;
} else if (t <= 8.4e+113) {
tmp = (y / t) * z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= -0.021: tmp = x elif t <= 8.4e+113: tmp = (y / t) * z else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= -0.021) tmp = x; elseif (t <= 8.4e+113) tmp = Float64(Float64(y / t) * z); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= -0.021) tmp = x; elseif (t <= 8.4e+113) tmp = (y / t) * z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, -0.021], x, If[LessEqual[t, 8.4e+113], N[(N[(y / t), $MachinePrecision] * z), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -0.021:\\
\;\;\;\;x\\
\mathbf{elif}\;t \leq 8.4 \cdot 10^{+113}:\\
\;\;\;\;\frac{y}{t} \cdot z\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if t < -0.0210000000000000013 or 8.3999999999999996e113 < t Initial program 85.5%
Taylor expanded in y around 0
Applied rewrites60.2%
if -0.0210000000000000013 < t < 8.3999999999999996e113Initial program 97.7%
Applied rewrites89.4%
Taylor expanded in x around 0
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6443.7
Applied rewrites43.7%
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
associate-/l*N/A
associate-*l/N/A
lower-*.f64N/A
lift-/.f6449.1
Applied rewrites49.1%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* (/ z t) y))) (if (<= y -2.9e-83) t_1 (if (<= y 1.5e+37) x t_1))))
double code(double x, double y, double z, double t) {
double t_1 = (z / t) * y;
double tmp;
if (y <= -2.9e-83) {
tmp = t_1;
} else if (y <= 1.5e+37) {
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 = (z / t) * y
if (y <= (-2.9d-83)) then
tmp = t_1
else if (y <= 1.5d+37) 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 = (z / t) * y;
double tmp;
if (y <= -2.9e-83) {
tmp = t_1;
} else if (y <= 1.5e+37) {
tmp = x;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = (z / t) * y tmp = 0 if y <= -2.9e-83: tmp = t_1 elif y <= 1.5e+37: tmp = x else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(Float64(z / t) * y) tmp = 0.0 if (y <= -2.9e-83) tmp = t_1; elseif (y <= 1.5e+37) tmp = x; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (z / t) * y; tmp = 0.0; if (y <= -2.9e-83) tmp = t_1; elseif (y <= 1.5e+37) tmp = x; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(z / t), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[y, -2.9e-83], t$95$1, If[LessEqual[y, 1.5e+37], x, t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{z}{t} \cdot y\\
\mathbf{if}\;y \leq -2.9 \cdot 10^{-83}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 1.5 \cdot 10^{+37}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -2.8999999999999999e-83 or 1.50000000000000011e37 < y Initial program 88.2%
Taylor expanded in x around 0
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6448.2
Applied rewrites48.2%
if -2.8999999999999999e-83 < y < 1.50000000000000011e37Initial program 98.3%
Taylor expanded in y around 0
Applied rewrites59.3%
(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 92.8%
Taylor expanded in y around 0
Applied rewrites37.7%
herbie shell --seed 2025130
(FPCore (x y z t)
:name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, D"
:precision binary64
(+ x (/ (* y (- z x)) t)))