
(FPCore (x y z t a) :precision binary64 (+ x (/ (* y (- z t)) a)))
double code(double x, double y, double z, double t, double a) {
return x + ((y * (z - t)) / a);
}
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, a)
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), intent (in) :: a
code = x + ((y * (z - t)) / a)
end function
public static double code(double x, double y, double z, double t, double a) {
return x + ((y * (z - t)) / a);
}
def code(x, y, z, t, a): return x + ((y * (z - t)) / a)
function code(x, y, z, t, a) return Float64(x + Float64(Float64(y * Float64(z - t)) / a)) end
function tmp = code(x, y, z, t, a) tmp = x + ((y * (z - t)) / a); end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y \cdot \left(z - t\right)}{a}
\end{array}
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a) :precision binary64 (+ x (/ (* y (- z t)) a)))
double code(double x, double y, double z, double t, double a) {
return x + ((y * (z - t)) / a);
}
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, a)
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), intent (in) :: a
code = x + ((y * (z - t)) / a)
end function
public static double code(double x, double y, double z, double t, double a) {
return x + ((y * (z - t)) / a);
}
def code(x, y, z, t, a): return x + ((y * (z - t)) / a)
function code(x, y, z, t, a) return Float64(x + Float64(Float64(y * Float64(z - t)) / a)) end
function tmp = code(x, y, z, t, a) tmp = x + ((y * (z - t)) / a); end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y \cdot \left(z - t\right)}{a}
\end{array}
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (* y (- z t))) (t_2 (fma y (/ (- z t) a) x))) (if (<= t_1 -5e+304) t_2 (if (<= t_1 5e+281) (+ x (/ t_1 a)) t_2))))
double code(double x, double y, double z, double t, double a) {
double t_1 = y * (z - t);
double t_2 = fma(y, ((z - t) / a), x);
double tmp;
if (t_1 <= -5e+304) {
tmp = t_2;
} else if (t_1 <= 5e+281) {
tmp = x + (t_1 / a);
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(y * Float64(z - t)) t_2 = fma(y, Float64(Float64(z - t) / a), x) tmp = 0.0 if (t_1 <= -5e+304) tmp = t_2; elseif (t_1 <= 5e+281) tmp = Float64(x + Float64(t_1 / a)); else tmp = t_2; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(y * N[(N[(z - t), $MachinePrecision] / a), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+304], t$95$2, If[LessEqual[t$95$1, 5e+281], N[(x + N[(t$95$1 / a), $MachinePrecision]), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := y \cdot \left(z - t\right)\\
t_2 := \mathsf{fma}\left(y, \frac{z - t}{a}, x\right)\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+304}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+281}:\\
\;\;\;\;x + \frac{t\_1}{a}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (*.f64 y (-.f64 z t)) < -4.9999999999999997e304 or 5.00000000000000016e281 < (*.f64 y (-.f64 z t)) Initial program 93.2%
Applied rewrites93.1%
if -4.9999999999999997e304 < (*.f64 y (-.f64 z t)) < 5.00000000000000016e281Initial program 93.2%
(FPCore (x y z t a) :precision binary64 (if (<= z 6e+169) (fma y (/ (- z t) a) x) (+ x (/ (* y z) a))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= 6e+169) {
tmp = fma(y, ((z - t) / a), x);
} else {
tmp = x + ((y * z) / a);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= 6e+169) tmp = fma(y, Float64(Float64(z - t) / a), x); else tmp = Float64(x + Float64(Float64(y * z) / a)); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, 6e+169], N[(y * N[(N[(z - t), $MachinePrecision] / a), $MachinePrecision] + x), $MachinePrecision], N[(x + N[(N[(y * z), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 6 \cdot 10^{+169}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z - t}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;x + \frac{y \cdot z}{a}\\
\end{array}
\end{array}
if z < 5.9999999999999999e169Initial program 93.2%
Applied rewrites93.1%
if 5.9999999999999999e169 < z Initial program 93.2%
Taylor expanded in z around inf
Applied rewrites68.2%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (* y (/ (- z t) a))) (t_2 (/ (* y (- z t)) a)))
(if (<= t_2 (- INFINITY))
t_1
(if (<= t_2 -2e+96)
t_2
(if (<= t_2 4e+113)
(+ x (/ (* y z) a))
(if (<= t_2 2e+302) t_2 t_1))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = y * ((z - t) / a);
double t_2 = (y * (z - t)) / a;
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = t_1;
} else if (t_2 <= -2e+96) {
tmp = t_2;
} else if (t_2 <= 4e+113) {
tmp = x + ((y * z) / a);
} else if (t_2 <= 2e+302) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double x, double y, double z, double t, double a) {
double t_1 = y * ((z - t) / a);
double t_2 = (y * (z - t)) / a;
double tmp;
if (t_2 <= -Double.POSITIVE_INFINITY) {
tmp = t_1;
} else if (t_2 <= -2e+96) {
tmp = t_2;
} else if (t_2 <= 4e+113) {
tmp = x + ((y * z) / a);
} else if (t_2 <= 2e+302) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = y * ((z - t) / a) t_2 = (y * (z - t)) / a tmp = 0 if t_2 <= -math.inf: tmp = t_1 elif t_2 <= -2e+96: tmp = t_2 elif t_2 <= 4e+113: tmp = x + ((y * z) / a) elif t_2 <= 2e+302: tmp = t_2 else: tmp = t_1 return tmp
function code(x, y, z, t, a) t_1 = Float64(y * Float64(Float64(z - t) / a)) t_2 = Float64(Float64(y * Float64(z - t)) / a) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = t_1; elseif (t_2 <= -2e+96) tmp = t_2; elseif (t_2 <= 4e+113) tmp = Float64(x + Float64(Float64(y * z) / a)); elseif (t_2 <= 2e+302) tmp = t_2; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = y * ((z - t) / a); t_2 = (y * (z - t)) / a; tmp = 0.0; if (t_2 <= -Inf) tmp = t_1; elseif (t_2 <= -2e+96) tmp = t_2; elseif (t_2 <= 4e+113) tmp = x + ((y * z) / a); elseif (t_2 <= 2e+302) tmp = t_2; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(y * N[(N[(z - t), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], t$95$1, If[LessEqual[t$95$2, -2e+96], t$95$2, If[LessEqual[t$95$2, 4e+113], N[(x + N[(N[(y * z), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 2e+302], t$95$2, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := y \cdot \frac{z - t}{a}\\
t_2 := \frac{y \cdot \left(z - t\right)}{a}\\
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq -2 \cdot 10^{+96}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_2 \leq 4 \cdot 10^{+113}:\\
\;\;\;\;x + \frac{y \cdot z}{a}\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+302}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 (*.f64 y (-.f64 z t)) a) < -inf.0 or 2.0000000000000002e302 < (/.f64 (*.f64 y (-.f64 z t)) a) Initial program 93.2%
Applied rewrites93.2%
Taylor expanded in x around 0
Applied rewrites57.1%
Applied rewrites57.0%
if -inf.0 < (/.f64 (*.f64 y (-.f64 z t)) a) < -2.0000000000000001e96 or 4e113 < (/.f64 (*.f64 y (-.f64 z t)) a) < 2.0000000000000002e302Initial program 93.2%
Taylor expanded in x around 0
Applied rewrites57.1%
if -2.0000000000000001e96 < (/.f64 (*.f64 y (-.f64 z t)) a) < 4e113Initial program 93.2%
Taylor expanded in z around inf
Applied rewrites68.2%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (* y (/ (- z t) a))) (t_2 (/ (* y (- z t)) a)))
(if (<= t_2 (- INFINITY))
t_1
(if (<= t_2 -2e+96)
t_2
(if (<= t_2 4e+113) (fma y (/ z a) x) (if (<= t_2 2e+302) t_2 t_1))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = y * ((z - t) / a);
double t_2 = (y * (z - t)) / a;
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = t_1;
} else if (t_2 <= -2e+96) {
tmp = t_2;
} else if (t_2 <= 4e+113) {
tmp = fma(y, (z / a), x);
} else if (t_2 <= 2e+302) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(y * Float64(Float64(z - t) / a)) t_2 = Float64(Float64(y * Float64(z - t)) / a) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = t_1; elseif (t_2 <= -2e+96) tmp = t_2; elseif (t_2 <= 4e+113) tmp = fma(y, Float64(z / a), x); elseif (t_2 <= 2e+302) tmp = t_2; else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(y * N[(N[(z - t), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], t$95$1, If[LessEqual[t$95$2, -2e+96], t$95$2, If[LessEqual[t$95$2, 4e+113], N[(y * N[(z / a), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[t$95$2, 2e+302], t$95$2, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := y \cdot \frac{z - t}{a}\\
t_2 := \frac{y \cdot \left(z - t\right)}{a}\\
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq -2 \cdot 10^{+96}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_2 \leq 4 \cdot 10^{+113}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z}{a}, x\right)\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+302}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 (*.f64 y (-.f64 z t)) a) < -inf.0 or 2.0000000000000002e302 < (/.f64 (*.f64 y (-.f64 z t)) a) Initial program 93.2%
Applied rewrites93.2%
Taylor expanded in x around 0
Applied rewrites57.1%
Applied rewrites57.0%
if -inf.0 < (/.f64 (*.f64 y (-.f64 z t)) a) < -2.0000000000000001e96 or 4e113 < (/.f64 (*.f64 y (-.f64 z t)) a) < 2.0000000000000002e302Initial program 93.2%
Taylor expanded in x around 0
Applied rewrites57.1%
if -2.0000000000000001e96 < (/.f64 (*.f64 y (-.f64 z t)) a) < 4e113Initial program 93.2%
Applied rewrites93.1%
Taylor expanded in z around inf
Applied rewrites67.6%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (/ (* y (- z t)) a))) (if (<= t_1 -2e+96) t_1 (if (<= t_1 4e+113) (fma y (/ z a) x) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (y * (z - t)) / a;
double tmp;
if (t_1 <= -2e+96) {
tmp = t_1;
} else if (t_1 <= 4e+113) {
tmp = fma(y, (z / a), x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(Float64(y * Float64(z - t)) / a) tmp = 0.0 if (t_1 <= -2e+96) tmp = t_1; elseif (t_1 <= 4e+113) tmp = fma(y, Float64(z / a), x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]}, If[LessEqual[t$95$1, -2e+96], t$95$1, If[LessEqual[t$95$1, 4e+113], N[(y * N[(z / a), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{y \cdot \left(z - t\right)}{a}\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{+96}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_1 \leq 4 \cdot 10^{+113}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 (*.f64 y (-.f64 z t)) a) < -2.0000000000000001e96 or 4e113 < (/.f64 (*.f64 y (-.f64 z t)) a) Initial program 93.2%
Taylor expanded in x around 0
Applied rewrites57.1%
if -2.0000000000000001e96 < (/.f64 (*.f64 y (-.f64 z t)) a) < 4e113Initial program 93.2%
Applied rewrites93.1%
Taylor expanded in z around inf
Applied rewrites67.6%
(FPCore (x y z t a) :precision binary64 (fma y (/ z a) x))
double code(double x, double y, double z, double t, double a) {
return fma(y, (z / a), x);
}
function code(x, y, z, t, a) return fma(y, Float64(z / a), x) end
code[x_, y_, z_, t_, a_] := N[(y * N[(z / a), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y, \frac{z}{a}, x\right)
\end{array}
Initial program 93.2%
Applied rewrites93.1%
Taylor expanded in z around inf
Applied rewrites67.6%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (/ (* y (- z t)) a)) (t_2 (/ (* y z) a))) (if (<= t_1 -5e+15) t_2 (if (<= t_1 4e+113) (* x 1.0) t_2))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (y * (z - t)) / a;
double t_2 = (y * z) / a;
double tmp;
if (t_1 <= -5e+15) {
tmp = t_2;
} else if (t_1 <= 4e+113) {
tmp = x * 1.0;
} else {
tmp = t_2;
}
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, a)
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), intent (in) :: a
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = (y * (z - t)) / a
t_2 = (y * z) / a
if (t_1 <= (-5d+15)) then
tmp = t_2
else if (t_1 <= 4d+113) then
tmp = x * 1.0d0
else
tmp = t_2
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double t_1 = (y * (z - t)) / a;
double t_2 = (y * z) / a;
double tmp;
if (t_1 <= -5e+15) {
tmp = t_2;
} else if (t_1 <= 4e+113) {
tmp = x * 1.0;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = (y * (z - t)) / a t_2 = (y * z) / a tmp = 0 if t_1 <= -5e+15: tmp = t_2 elif t_1 <= 4e+113: tmp = x * 1.0 else: tmp = t_2 return tmp
function code(x, y, z, t, a) t_1 = Float64(Float64(y * Float64(z - t)) / a) t_2 = Float64(Float64(y * z) / a) tmp = 0.0 if (t_1 <= -5e+15) tmp = t_2; elseif (t_1 <= 4e+113) tmp = Float64(x * 1.0); else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = (y * (z - t)) / a; t_2 = (y * z) / a; tmp = 0.0; if (t_1 <= -5e+15) tmp = t_2; elseif (t_1 <= 4e+113) tmp = x * 1.0; else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]}, Block[{t$95$2 = N[(N[(y * z), $MachinePrecision] / a), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+15], t$95$2, If[LessEqual[t$95$1, 4e+113], N[(x * 1.0), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{y \cdot \left(z - t\right)}{a}\\
t_2 := \frac{y \cdot z}{a}\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+15}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 4 \cdot 10^{+113}:\\
\;\;\;\;x \cdot 1\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (/.f64 (*.f64 y (-.f64 z t)) a) < -5e15 or 4e113 < (/.f64 (*.f64 y (-.f64 z t)) a) Initial program 93.2%
Taylor expanded in z around inf
Applied rewrites31.9%
if -5e15 < (/.f64 (*.f64 y (-.f64 z t)) a) < 4e113Initial program 93.2%
Taylor expanded in x around inf
Applied rewrites83.7%
Taylor expanded in x around inf
Applied rewrites39.1%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (/ (* y (- z t)) a)) (t_2 (* y (/ z a)))) (if (<= t_1 -5e+15) t_2 (if (<= t_1 4e+113) (* x 1.0) t_2))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (y * (z - t)) / a;
double t_2 = y * (z / a);
double tmp;
if (t_1 <= -5e+15) {
tmp = t_2;
} else if (t_1 <= 4e+113) {
tmp = x * 1.0;
} else {
tmp = t_2;
}
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, a)
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), intent (in) :: a
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = (y * (z - t)) / a
t_2 = y * (z / a)
if (t_1 <= (-5d+15)) then
tmp = t_2
else if (t_1 <= 4d+113) then
tmp = x * 1.0d0
else
tmp = t_2
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double t_1 = (y * (z - t)) / a;
double t_2 = y * (z / a);
double tmp;
if (t_1 <= -5e+15) {
tmp = t_2;
} else if (t_1 <= 4e+113) {
tmp = x * 1.0;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = (y * (z - t)) / a t_2 = y * (z / a) tmp = 0 if t_1 <= -5e+15: tmp = t_2 elif t_1 <= 4e+113: tmp = x * 1.0 else: tmp = t_2 return tmp
function code(x, y, z, t, a) t_1 = Float64(Float64(y * Float64(z - t)) / a) t_2 = Float64(y * Float64(z / a)) tmp = 0.0 if (t_1 <= -5e+15) tmp = t_2; elseif (t_1 <= 4e+113) tmp = Float64(x * 1.0); else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = (y * (z - t)) / a; t_2 = y * (z / a); tmp = 0.0; if (t_1 <= -5e+15) tmp = t_2; elseif (t_1 <= 4e+113) tmp = x * 1.0; else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]}, Block[{t$95$2 = N[(y * N[(z / a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+15], t$95$2, If[LessEqual[t$95$1, 4e+113], N[(x * 1.0), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{y \cdot \left(z - t\right)}{a}\\
t_2 := y \cdot \frac{z}{a}\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+15}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 4 \cdot 10^{+113}:\\
\;\;\;\;x \cdot 1\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (/.f64 (*.f64 y (-.f64 z t)) a) < -5e15 or 4e113 < (/.f64 (*.f64 y (-.f64 z t)) a) Initial program 93.2%
Taylor expanded in z around inf
Applied rewrites31.9%
Applied rewrites31.5%
if -5e15 < (/.f64 (*.f64 y (-.f64 z t)) a) < 4e113Initial program 93.2%
Taylor expanded in x around inf
Applied rewrites83.7%
Taylor expanded in x around inf
Applied rewrites39.1%
(FPCore (x y z t a) :precision binary64 (* x 1.0))
double code(double x, double y, double z, double t, double a) {
return x * 1.0;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a)
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), intent (in) :: a
code = x * 1.0d0
end function
public static double code(double x, double y, double z, double t, double a) {
return x * 1.0;
}
def code(x, y, z, t, a): return x * 1.0
function code(x, y, z, t, a) return Float64(x * 1.0) end
function tmp = code(x, y, z, t, a) tmp = x * 1.0; end
code[x_, y_, z_, t_, a_] := N[(x * 1.0), $MachinePrecision]
\begin{array}{l}
\\
x \cdot 1
\end{array}
Initial program 93.2%
Taylor expanded in x around inf
Applied rewrites83.7%
Taylor expanded in x around inf
Applied rewrites39.1%
herbie shell --seed 2025161
(FPCore (x y z t a)
:name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, E"
:precision binary64
(+ x (/ (* y (- z t)) a)))