
(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 8 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 (- z t) (/ y a) x)))
(if (<= t_1 (- INFINITY))
t_2
(if (<= t_1 1e+93) (+ x (/ (- (* z y) (* t y)) 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((z - t), (y / a), x);
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = t_2;
} else if (t_1 <= 1e+93) {
tmp = x + (((z * y) - (t * y)) / a);
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(y * Float64(z - t)) t_2 = fma(Float64(z - t), Float64(y / a), x) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = t_2; elseif (t_1 <= 1e+93) tmp = Float64(x + Float64(Float64(Float64(z * y) - Float64(t * y)) / 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[(N[(z - t), $MachinePrecision] * N[(y / a), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], t$95$2, If[LessEqual[t$95$1, 1e+93], N[(x + N[(N[(N[(z * y), $MachinePrecision] - N[(t * y), $MachinePrecision]), $MachinePrecision] / 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(z - t, \frac{y}{a}, x\right)\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 10^{+93}:\\
\;\;\;\;x + \frac{z \cdot y - t \cdot y}{a}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (*.f64 y (-.f64 z t)) < -inf.0 or 1.00000000000000004e93 < (*.f64 y (-.f64 z t)) Initial program 82.3%
lift-*.f64N/A
lift--.f64N/A
negate-subN/A
mul-1-negN/A
distribute-rgt-inN/A
*-commutativeN/A
mul-1-negN/A
fp-cancel-sub-signN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6478.4
Applied rewrites78.4%
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
+-commutativeN/A
distribute-rgt-out--N/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lift--.f64N/A
lift-/.f6498.8
Applied rewrites98.8%
if -inf.0 < (*.f64 y (-.f64 z t)) < 1.00000000000000004e93Initial program 99.3%
lift-*.f64N/A
lift--.f64N/A
negate-subN/A
mul-1-negN/A
distribute-rgt-inN/A
*-commutativeN/A
mul-1-negN/A
fp-cancel-sub-signN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6499.3
Applied rewrites99.3%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (* y (- z t))) (t_2 (fma (- z t) (/ y a) x))) (if (<= t_1 (- INFINITY)) t_2 (if (<= t_1 1e+93) (+ 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((z - t), (y / a), x);
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = t_2;
} else if (t_1 <= 1e+93) {
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(Float64(z - t), Float64(y / a), x) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = t_2; elseif (t_1 <= 1e+93) 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[(N[(z - t), $MachinePrecision] * N[(y / a), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], t$95$2, If[LessEqual[t$95$1, 1e+93], 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(z - t, \frac{y}{a}, x\right)\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 10^{+93}:\\
\;\;\;\;x + \frac{t\_1}{a}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (*.f64 y (-.f64 z t)) < -inf.0 or 1.00000000000000004e93 < (*.f64 y (-.f64 z t)) Initial program 82.3%
lift-*.f64N/A
lift--.f64N/A
negate-subN/A
mul-1-negN/A
distribute-rgt-inN/A
*-commutativeN/A
mul-1-negN/A
fp-cancel-sub-signN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6478.4
Applied rewrites78.4%
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
+-commutativeN/A
distribute-rgt-out--N/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lift--.f64N/A
lift-/.f6498.8
Applied rewrites98.8%
if -inf.0 < (*.f64 y (-.f64 z t)) < 1.00000000000000004e93Initial program 99.3%
(FPCore (x y z t a) :precision binary64 (fma (- z t) (/ y a) x))
double code(double x, double y, double z, double t, double a) {
return fma((z - t), (y / a), x);
}
function code(x, y, z, t, a) return fma(Float64(z - t), Float64(y / a), x) end
code[x_, y_, z_, t_, a_] := N[(N[(z - t), $MachinePrecision] * N[(y / a), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(z - t, \frac{y}{a}, x\right)
\end{array}
Initial program 93.3%
lift-*.f64N/A
lift--.f64N/A
negate-subN/A
mul-1-negN/A
distribute-rgt-inN/A
*-commutativeN/A
mul-1-negN/A
fp-cancel-sub-signN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6491.9
Applied rewrites91.9%
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
+-commutativeN/A
distribute-rgt-out--N/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lift--.f64N/A
lift-/.f6496.8
Applied rewrites96.8%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (- x (/ (* t y) a)))) (if (<= t -6.2e+43) t_1 (if (<= t 2e+63) (fma (/ y a) z x) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = x - ((t * y) / a);
double tmp;
if (t <= -6.2e+43) {
tmp = t_1;
} else if (t <= 2e+63) {
tmp = fma((y / a), z, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(x - Float64(Float64(t * y) / a)) tmp = 0.0 if (t <= -6.2e+43) tmp = t_1; elseif (t <= 2e+63) tmp = fma(Float64(y / a), z, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(x - N[(N[(t * y), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t, -6.2e+43], t$95$1, If[LessEqual[t, 2e+63], N[(N[(y / a), $MachinePrecision] * z + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x - \frac{t \cdot y}{a}\\
\mathbf{if}\;t \leq -6.2 \cdot 10^{+43}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 2 \cdot 10^{+63}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a}, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -6.2000000000000003e43 or 2.00000000000000012e63 < t Initial program 89.9%
Taylor expanded in z around 0
mul-1-negN/A
negate-subN/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6478.9
Applied rewrites78.9%
if -6.2000000000000003e43 < t < 2.00000000000000012e63Initial program 95.6%
Taylor expanded in t around 0
+-commutativeN/A
associate-*l/N/A
lower-fma.f64N/A
lower-/.f6485.9
Applied rewrites85.9%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (/ (* (- t) y) a))) (if (<= t -1.8e+212) t_1 (if (<= t 6.8e+253) (fma (/ y a) z x) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (-t * y) / a;
double tmp;
if (t <= -1.8e+212) {
tmp = t_1;
} else if (t <= 6.8e+253) {
tmp = fma((y / a), z, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(Float64(Float64(-t) * y) / a) tmp = 0.0 if (t <= -1.8e+212) tmp = t_1; elseif (t <= 6.8e+253) tmp = fma(Float64(y / a), z, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[((-t) * y), $MachinePrecision] / a), $MachinePrecision]}, If[LessEqual[t, -1.8e+212], t$95$1, If[LessEqual[t, 6.8e+253], N[(N[(y / a), $MachinePrecision] * z + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\left(-t\right) \cdot y}{a}\\
\mathbf{if}\;t \leq -1.8 \cdot 10^{+212}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 6.8 \cdot 10^{+253}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a}, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -1.8e212 or 6.80000000000000035e253 < t Initial program 87.8%
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
+-commutativeN/A
associate-/l*N/A
sub-divN/A
*-commutativeN/A
lower-fma.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6488.7
Applied rewrites88.7%
Taylor expanded in t around inf
associate-*r/N/A
lower-/.f64N/A
associate-*r*N/A
mul-1-negN/A
lift-neg.f64N/A
lower-*.f6465.8
Applied rewrites65.8%
if -1.8e212 < t < 6.80000000000000035e253Initial program 93.9%
Taylor expanded in t around 0
+-commutativeN/A
associate-*l/N/A
lower-fma.f64N/A
lower-/.f6475.5
Applied rewrites75.5%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (/ (* y (- z t)) a)) (t_2 (* (/ y a) z))) (if (<= t_1 -1e+36) t_2 (if (<= t_1 1e+27) x 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 / a) * z;
double tmp;
if (t_1 <= -1e+36) {
tmp = t_2;
} else if (t_1 <= 1e+27) {
tmp = x;
} 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 / a) * z
if (t_1 <= (-1d+36)) then
tmp = t_2
else if (t_1 <= 1d+27) then
tmp = x
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 / a) * z;
double tmp;
if (t_1 <= -1e+36) {
tmp = t_2;
} else if (t_1 <= 1e+27) {
tmp = x;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = (y * (z - t)) / a t_2 = (y / a) * z tmp = 0 if t_1 <= -1e+36: tmp = t_2 elif t_1 <= 1e+27: tmp = x 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 / a) * z) tmp = 0.0 if (t_1 <= -1e+36) tmp = t_2; elseif (t_1 <= 1e+27) tmp = x; 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 / a) * z; tmp = 0.0; if (t_1 <= -1e+36) tmp = t_2; elseif (t_1 <= 1e+27) tmp = x; 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 / a), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[t$95$1, -1e+36], t$95$2, If[LessEqual[t$95$1, 1e+27], x, t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{y \cdot \left(z - t\right)}{a}\\
t_2 := \frac{y}{a} \cdot z\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+36}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 10^{+27}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (/.f64 (*.f64 y (-.f64 z t)) a) < -1.00000000000000004e36 or 1e27 < (/.f64 (*.f64 y (-.f64 z t)) a) Initial program 89.5%
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
+-commutativeN/A
associate-/l*N/A
sub-divN/A
*-commutativeN/A
lower-fma.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6489.2
Applied rewrites89.2%
Taylor expanded in z around inf
associate-/l*N/A
lower-*.f64N/A
lower-/.f6443.2
Applied rewrites43.2%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
associate-*l/N/A
lower-*.f64N/A
lift-/.f6448.3
Applied rewrites48.3%
if -1.00000000000000004e36 < (/.f64 (*.f64 y (-.f64 z t)) a) < 1e27Initial program 99.0%
Taylor expanded in x around inf
Applied rewrites75.9%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (/ (* y (- z t)) a)) (t_2 (* y (/ z a)))) (if (<= t_1 -1e+36) t_2 (if (<= t_1 1e+27) x 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 <= -1e+36) {
tmp = t_2;
} else if (t_1 <= 1e+27) {
tmp = x;
} 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 <= (-1d+36)) then
tmp = t_2
else if (t_1 <= 1d+27) then
tmp = x
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 <= -1e+36) {
tmp = t_2;
} else if (t_1 <= 1e+27) {
tmp = x;
} 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 <= -1e+36: tmp = t_2 elif t_1 <= 1e+27: tmp = x 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 <= -1e+36) tmp = t_2; elseif (t_1 <= 1e+27) tmp = x; 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 <= -1e+36) tmp = t_2; elseif (t_1 <= 1e+27) tmp = x; 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, -1e+36], t$95$2, If[LessEqual[t$95$1, 1e+27], x, 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 -1 \cdot 10^{+36}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 10^{+27}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (/.f64 (*.f64 y (-.f64 z t)) a) < -1.00000000000000004e36 or 1e27 < (/.f64 (*.f64 y (-.f64 z t)) a) Initial program 89.5%
Taylor expanded in z around inf
associate-/l*N/A
lower-*.f64N/A
lower-/.f6443.2
Applied rewrites43.2%
if -1.00000000000000004e36 < (/.f64 (*.f64 y (-.f64 z t)) a) < 1e27Initial program 99.0%
Taylor expanded in x around inf
Applied rewrites75.9%
(FPCore (x y z t a) :precision binary64 x)
double code(double x, double y, double z, double t, double a) {
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, 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
end function
public static double code(double x, double y, double z, double t, double a) {
return x;
}
def code(x, y, z, t, a): return x
function code(x, y, z, t, a) return x end
function tmp = code(x, y, z, t, a) tmp = x; end
code[x_, y_, z_, t_, a_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 93.3%
Taylor expanded in x around inf
Applied rewrites39.0%
herbie shell --seed 2025119
(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)))