
(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 11 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 (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.4%
lift-+.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lift--.f64N/A
lower-/.f6497.4
Applied rewrites97.4%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (* (/ (- z t) a) y))
(t_2 (/ (* (- z t) y) a))
(t_3 (/ (* y (- z t)) a)))
(if (<= t_3 (- INFINITY))
t_1
(if (<= t_3 -2e+142)
t_2
(if (<= t_3 5e+55)
(fma (- t) (/ y a) x)
(if (<= t_3 5e+288) t_2 t_1))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = ((z - t) / a) * y;
double t_2 = ((z - t) * y) / a;
double t_3 = (y * (z - t)) / a;
double tmp;
if (t_3 <= -((double) INFINITY)) {
tmp = t_1;
} else if (t_3 <= -2e+142) {
tmp = t_2;
} else if (t_3 <= 5e+55) {
tmp = fma(-t, (y / a), x);
} else if (t_3 <= 5e+288) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(Float64(Float64(z - t) / a) * y) t_2 = Float64(Float64(Float64(z - t) * y) / a) t_3 = Float64(Float64(y * Float64(z - t)) / a) tmp = 0.0 if (t_3 <= Float64(-Inf)) tmp = t_1; elseif (t_3 <= -2e+142) tmp = t_2; elseif (t_3 <= 5e+55) tmp = fma(Float64(-t), Float64(y / a), x); elseif (t_3 <= 5e+288) tmp = t_2; else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(N[(z - t), $MachinePrecision] / a), $MachinePrecision] * y), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(z - t), $MachinePrecision] * y), $MachinePrecision] / a), $MachinePrecision]}, Block[{t$95$3 = N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]}, If[LessEqual[t$95$3, (-Infinity)], t$95$1, If[LessEqual[t$95$3, -2e+142], t$95$2, If[LessEqual[t$95$3, 5e+55], N[((-t) * N[(y / a), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[t$95$3, 5e+288], t$95$2, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{z - t}{a} \cdot y\\
t_2 := \frac{\left(z - t\right) \cdot y}{a}\\
t_3 := \frac{y \cdot \left(z - t\right)}{a}\\
\mathbf{if}\;t\_3 \leq -\infty:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_3 \leq -2 \cdot 10^{+142}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_3 \leq 5 \cdot 10^{+55}:\\
\;\;\;\;\mathsf{fma}\left(-t, \frac{y}{a}, x\right)\\
\mathbf{elif}\;t\_3 \leq 5 \cdot 10^{+288}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 (*.f64 y (-.f64 z t)) a) < -inf.0 or 5.0000000000000003e288 < (/.f64 (*.f64 y (-.f64 z t)) a) Initial program 81.0%
lift-+.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lift--.f64N/A
lower-/.f6499.7
Applied rewrites99.7%
Taylor expanded in x around 0
associate-*r/N/A
associate-*l/N/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
lift--.f6495.4
Applied rewrites95.4%
if -inf.0 < (/.f64 (*.f64 y (-.f64 z t)) a) < -2.0000000000000001e142 or 5.00000000000000046e55 < (/.f64 (*.f64 y (-.f64 z t)) a) < 5.0000000000000003e288Initial program 99.7%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6477.5
Applied rewrites77.5%
if -2.0000000000000001e142 < (/.f64 (*.f64 y (-.f64 z t)) a) < 5.00000000000000046e55Initial program 99.2%
lift-+.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lift--.f64N/A
lower-/.f6497.0
Applied rewrites97.0%
Taylor expanded in z around 0
mul-1-negN/A
lower-neg.f6482.9
Applied rewrites82.9%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (* (/ (- z t) a) y))
(t_2 (/ (* (- z t) y) a))
(t_3 (/ (* y (- z t)) a)))
(if (<= t_3 (- INFINITY))
t_1
(if (<= t_3 -1e+144)
t_2
(if (<= t_3 5e+55) (- x (/ (* y t) a)) (if (<= t_3 5e+288) t_2 t_1))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = ((z - t) / a) * y;
double t_2 = ((z - t) * y) / a;
double t_3 = (y * (z - t)) / a;
double tmp;
if (t_3 <= -((double) INFINITY)) {
tmp = t_1;
} else if (t_3 <= -1e+144) {
tmp = t_2;
} else if (t_3 <= 5e+55) {
tmp = x - ((y * t) / a);
} else if (t_3 <= 5e+288) {
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 = ((z - t) / a) * y;
double t_2 = ((z - t) * y) / a;
double t_3 = (y * (z - t)) / a;
double tmp;
if (t_3 <= -Double.POSITIVE_INFINITY) {
tmp = t_1;
} else if (t_3 <= -1e+144) {
tmp = t_2;
} else if (t_3 <= 5e+55) {
tmp = x - ((y * t) / a);
} else if (t_3 <= 5e+288) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = ((z - t) / a) * y t_2 = ((z - t) * y) / a t_3 = (y * (z - t)) / a tmp = 0 if t_3 <= -math.inf: tmp = t_1 elif t_3 <= -1e+144: tmp = t_2 elif t_3 <= 5e+55: tmp = x - ((y * t) / a) elif t_3 <= 5e+288: tmp = t_2 else: tmp = t_1 return tmp
function code(x, y, z, t, a) t_1 = Float64(Float64(Float64(z - t) / a) * y) t_2 = Float64(Float64(Float64(z - t) * y) / a) t_3 = Float64(Float64(y * Float64(z - t)) / a) tmp = 0.0 if (t_3 <= Float64(-Inf)) tmp = t_1; elseif (t_3 <= -1e+144) tmp = t_2; elseif (t_3 <= 5e+55) tmp = Float64(x - Float64(Float64(y * t) / a)); elseif (t_3 <= 5e+288) tmp = t_2; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = ((z - t) / a) * y; t_2 = ((z - t) * y) / a; t_3 = (y * (z - t)) / a; tmp = 0.0; if (t_3 <= -Inf) tmp = t_1; elseif (t_3 <= -1e+144) tmp = t_2; elseif (t_3 <= 5e+55) tmp = x - ((y * t) / a); elseif (t_3 <= 5e+288) tmp = t_2; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(N[(z - t), $MachinePrecision] / a), $MachinePrecision] * y), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(z - t), $MachinePrecision] * y), $MachinePrecision] / a), $MachinePrecision]}, Block[{t$95$3 = N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]}, If[LessEqual[t$95$3, (-Infinity)], t$95$1, If[LessEqual[t$95$3, -1e+144], t$95$2, If[LessEqual[t$95$3, 5e+55], N[(x - N[(N[(y * t), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 5e+288], t$95$2, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{z - t}{a} \cdot y\\
t_2 := \frac{\left(z - t\right) \cdot y}{a}\\
t_3 := \frac{y \cdot \left(z - t\right)}{a}\\
\mathbf{if}\;t\_3 \leq -\infty:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_3 \leq -1 \cdot 10^{+144}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_3 \leq 5 \cdot 10^{+55}:\\
\;\;\;\;x - \frac{y \cdot t}{a}\\
\mathbf{elif}\;t\_3 \leq 5 \cdot 10^{+288}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 (*.f64 y (-.f64 z t)) a) < -inf.0 or 5.0000000000000003e288 < (/.f64 (*.f64 y (-.f64 z t)) a) Initial program 81.0%
lift-+.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lift--.f64N/A
lower-/.f6499.7
Applied rewrites99.7%
Taylor expanded in x around 0
associate-*r/N/A
associate-*l/N/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
lift--.f6495.4
Applied rewrites95.4%
if -inf.0 < (/.f64 (*.f64 y (-.f64 z t)) a) < -1.00000000000000002e144 or 5.00000000000000046e55 < (/.f64 (*.f64 y (-.f64 z t)) a) < 5.0000000000000003e288Initial program 99.7%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6477.6
Applied rewrites77.6%
if -1.00000000000000002e144 < (/.f64 (*.f64 y (-.f64 z t)) a) < 5.00000000000000046e55Initial program 99.2%
Taylor expanded in z around 0
cancel-sign-subN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6482.7
Applied rewrites82.7%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6484.0
Applied rewrites84.0%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (/ (* y (- z t)) a)) (t_2 (* (/ (- z t) a) y))) (if (<= t_1 -5e+233) t_2 (if (<= t_1 5e+55) (- x (/ (* y t) a)) t_2))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (y * (z - t)) / a;
double t_2 = ((z - t) / a) * y;
double tmp;
if (t_1 <= -5e+233) {
tmp = t_2;
} else if (t_1 <= 5e+55) {
tmp = x - ((y * t) / a);
} 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 = ((z - t) / a) * y
if (t_1 <= (-5d+233)) then
tmp = t_2
else if (t_1 <= 5d+55) then
tmp = x - ((y * t) / a)
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 = ((z - t) / a) * y;
double tmp;
if (t_1 <= -5e+233) {
tmp = t_2;
} else if (t_1 <= 5e+55) {
tmp = x - ((y * t) / a);
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = (y * (z - t)) / a t_2 = ((z - t) / a) * y tmp = 0 if t_1 <= -5e+233: tmp = t_2 elif t_1 <= 5e+55: tmp = x - ((y * t) / a) 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(Float64(z - t) / a) * y) tmp = 0.0 if (t_1 <= -5e+233) tmp = t_2; elseif (t_1 <= 5e+55) tmp = Float64(x - Float64(Float64(y * t) / a)); 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 = ((z - t) / a) * y; tmp = 0.0; if (t_1 <= -5e+233) tmp = t_2; elseif (t_1 <= 5e+55) tmp = x - ((y * t) / a); 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[(N[(z - t), $MachinePrecision] / a), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+233], t$95$2, If[LessEqual[t$95$1, 5e+55], N[(x - N[(N[(y * t), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{y \cdot \left(z - t\right)}{a}\\
t_2 := \frac{z - t}{a} \cdot y\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+233}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+55}:\\
\;\;\;\;x - \frac{y \cdot t}{a}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (/.f64 (*.f64 y (-.f64 z t)) a) < -5.00000000000000009e233 or 5.00000000000000046e55 < (/.f64 (*.f64 y (-.f64 z t)) a) Initial program 86.7%
lift-+.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lift--.f64N/A
lower-/.f6497.9
Applied rewrites97.9%
Taylor expanded in x around 0
associate-*r/N/A
associate-*l/N/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
lift--.f6483.8
Applied rewrites83.8%
if -5.00000000000000009e233 < (/.f64 (*.f64 y (-.f64 z t)) a) < 5.00000000000000046e55Initial program 99.3%
Taylor expanded in z around 0
cancel-sign-subN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6479.5
Applied rewrites79.5%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6481.8
Applied rewrites81.8%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (/ (* y (- z t)) a)) (t_2 (* (/ (- z t) a) y))) (if (<= t_1 -2e+126) t_2 (if (<= t_1 5e+55) (- x (* y (/ t a))) t_2))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (y * (z - t)) / a;
double t_2 = ((z - t) / a) * y;
double tmp;
if (t_1 <= -2e+126) {
tmp = t_2;
} else if (t_1 <= 5e+55) {
tmp = x - (y * (t / a));
} 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 = ((z - t) / a) * y
if (t_1 <= (-2d+126)) then
tmp = t_2
else if (t_1 <= 5d+55) then
tmp = x - (y * (t / a))
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 = ((z - t) / a) * y;
double tmp;
if (t_1 <= -2e+126) {
tmp = t_2;
} else if (t_1 <= 5e+55) {
tmp = x - (y * (t / a));
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = (y * (z - t)) / a t_2 = ((z - t) / a) * y tmp = 0 if t_1 <= -2e+126: tmp = t_2 elif t_1 <= 5e+55: tmp = x - (y * (t / a)) 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(Float64(z - t) / a) * y) tmp = 0.0 if (t_1 <= -2e+126) tmp = t_2; elseif (t_1 <= 5e+55) tmp = Float64(x - Float64(y * Float64(t / a))); 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 = ((z - t) / a) * y; tmp = 0.0; if (t_1 <= -2e+126) tmp = t_2; elseif (t_1 <= 5e+55) tmp = x - (y * (t / a)); 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[(N[(z - t), $MachinePrecision] / a), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[t$95$1, -2e+126], t$95$2, If[LessEqual[t$95$1, 5e+55], N[(x - N[(y * N[(t / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{y \cdot \left(z - t\right)}{a}\\
t_2 := \frac{z - t}{a} \cdot y\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{+126}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+55}:\\
\;\;\;\;x - y \cdot \frac{t}{a}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (/.f64 (*.f64 y (-.f64 z t)) a) < -1.99999999999999985e126 or 5.00000000000000046e55 < (/.f64 (*.f64 y (-.f64 z t)) a) Initial program 88.1%
lift-+.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lift--.f64N/A
lower-/.f6497.7
Applied rewrites97.7%
Taylor expanded in x around 0
associate-*r/N/A
associate-*l/N/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
lift--.f6480.9
Applied rewrites80.9%
if -1.99999999999999985e126 < (/.f64 (*.f64 y (-.f64 z t)) a) < 5.00000000000000046e55Initial program 99.2%
Taylor expanded in z around 0
cancel-sign-subN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6483.4
Applied rewrites83.4%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (/ (* y (- z t)) a)) (t_2 (* (/ y a) z))) (if (<= t_1 -5e+134) t_2 (if (<= t_1 5e+55) 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 <= -5e+134) {
tmp = t_2;
} else if (t_1 <= 5e+55) {
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 <= (-5d+134)) then
tmp = t_2
else if (t_1 <= 5d+55) 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 <= -5e+134) {
tmp = t_2;
} else if (t_1 <= 5e+55) {
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 <= -5e+134: tmp = t_2 elif t_1 <= 5e+55: 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 <= -5e+134) tmp = t_2; elseif (t_1 <= 5e+55) 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 <= -5e+134) tmp = t_2; elseif (t_1 <= 5e+55) 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, -5e+134], t$95$2, If[LessEqual[t$95$1, 5e+55], 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 -5 \cdot 10^{+134}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+55}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (/.f64 (*.f64 y (-.f64 z t)) a) < -4.99999999999999981e134 or 5.00000000000000046e55 < (/.f64 (*.f64 y (-.f64 z t)) a) Initial program 88.0%
lift-+.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lift--.f64N/A
lower-/.f6497.7
Applied rewrites97.7%
Taylor expanded in z around inf
associate-*r/N/A
associate-*l/N/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
associate-*l/N/A
lower-*.f64N/A
lift-/.f6450.9
Applied rewrites50.9%
if -4.99999999999999981e134 < (/.f64 (*.f64 y (-.f64 z t)) a) < 5.00000000000000046e55Initial program 99.2%
Taylor expanded in x around inf
Applied rewrites69.0%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (* y (- z t))) (t_2 (* (/ (- z t) a) y))) (if (<= t_1 -1e+65) t_2 (if (<= t_1 2e+77) (fma (/ y a) z x) t_2))))
double code(double x, double y, double z, double t, double a) {
double t_1 = y * (z - t);
double t_2 = ((z - t) / a) * y;
double tmp;
if (t_1 <= -1e+65) {
tmp = t_2;
} else if (t_1 <= 2e+77) {
tmp = fma((y / a), z, x);
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(y * Float64(z - t)) t_2 = Float64(Float64(Float64(z - t) / a) * y) tmp = 0.0 if (t_1 <= -1e+65) tmp = t_2; elseif (t_1 <= 2e+77) tmp = fma(Float64(y / a), z, x); 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[(N[(z - t), $MachinePrecision] / a), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[t$95$1, -1e+65], t$95$2, If[LessEqual[t$95$1, 2e+77], N[(N[(y / a), $MachinePrecision] * z + x), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := y \cdot \left(z - t\right)\\
t_2 := \frac{z - t}{a} \cdot y\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+65}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+77}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a}, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (*.f64 y (-.f64 z t)) < -9.9999999999999999e64 or 1.99999999999999997e77 < (*.f64 y (-.f64 z t)) Initial program 88.7%
lift-+.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lift--.f64N/A
lower-/.f6498.2
Applied rewrites98.2%
Taylor expanded in x around 0
associate-*r/N/A
associate-*l/N/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
lift--.f6479.2
Applied rewrites79.2%
if -9.9999999999999999e64 < (*.f64 y (-.f64 z t)) < 1.99999999999999997e77Initial program 99.2%
Taylor expanded in t around 0
+-commutativeN/A
associate-*l/N/A
lower-fma.f64N/A
lower-/.f6479.7
Applied rewrites79.7%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (* (/ y a) (- t)))) (if (<= t -2.05e+86) t_1 (if (<= t 2.8e+91) (fma (/ y a) z x) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (y / a) * -t;
double tmp;
if (t <= -2.05e+86) {
tmp = t_1;
} else if (t <= 2.8e+91) {
tmp = fma((y / a), z, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(Float64(y / a) * Float64(-t)) tmp = 0.0 if (t <= -2.05e+86) tmp = t_1; elseif (t <= 2.8e+91) 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[(y / a), $MachinePrecision] * (-t)), $MachinePrecision]}, If[LessEqual[t, -2.05e+86], t$95$1, If[LessEqual[t, 2.8e+91], N[(N[(y / a), $MachinePrecision] * z + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{y}{a} \cdot \left(-t\right)\\
\mathbf{if}\;t \leq -2.05 \cdot 10^{+86}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 2.8 \cdot 10^{+91}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a}, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -2.05e86 or 2.7999999999999999e91 < t Initial program 90.8%
Taylor expanded in t around inf
*-commutativeN/A
associate-*l/N/A
associate-*l*N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6461.7
Applied rewrites61.7%
if -2.05e86 < t < 2.7999999999999999e91Initial program 94.9%
Taylor expanded in t around 0
+-commutativeN/A
associate-*l/N/A
lower-fma.f64N/A
lower-/.f6485.1
Applied rewrites85.1%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (* (- y) (/ t a)))) (if (<= t -8.5e+214) t_1 (if (<= t 3e+92) (fma (/ y a) z x) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = -y * (t / a);
double tmp;
if (t <= -8.5e+214) {
tmp = t_1;
} else if (t <= 3e+92) {
tmp = fma((y / a), z, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(Float64(-y) * Float64(t / a)) tmp = 0.0 if (t <= -8.5e+214) tmp = t_1; elseif (t <= 3e+92) 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[((-y) * N[(t / a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t, -8.5e+214], t$95$1, If[LessEqual[t, 3e+92], N[(N[(y / a), $MachinePrecision] * z + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(-y\right) \cdot \frac{t}{a}\\
\mathbf{if}\;t \leq -8.5 \cdot 10^{+214}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 3 \cdot 10^{+92}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a}, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -8.50000000000000045e214 or 3.00000000000000013e92 < t Initial program 90.9%
lift-+.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lift--.f64N/A
lower-/.f6497.2
Applied rewrites97.2%
Taylor expanded in t around inf
associate-*r/N/A
associate-*l/N/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
mul-1-negN/A
*-commutativeN/A
associate-*r/N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
lift-/.f6459.6
Applied rewrites59.6%
if -8.50000000000000045e214 < t < 3.00000000000000013e92Initial program 94.3%
Taylor expanded in t around 0
+-commutativeN/A
associate-*l/N/A
lower-fma.f64N/A
lower-/.f6480.5
Applied rewrites80.5%
(FPCore (x y z t a) :precision binary64 (fma (/ y a) z x))
double code(double x, double y, double z, double t, double a) {
return fma((y / a), z, x);
}
function code(x, y, z, t, a) return fma(Float64(y / a), z, x) end
code[x_, y_, z_, t_, a_] := N[(N[(y / a), $MachinePrecision] * z + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{y}{a}, z, x\right)
\end{array}
Initial program 93.4%
Taylor expanded in t around 0
+-commutativeN/A
associate-*l/N/A
lower-fma.f64N/A
lower-/.f6471.3
Applied rewrites71.3%
(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.4%
Taylor expanded in x around inf
Applied rewrites39.6%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (/ a (- z t))))
(if (< y -1.0761266216389975e-10)
(+ x (/ 1.0 (/ t_1 y)))
(if (< y 2.894426862792089e-49)
(+ x (/ (* y (- z t)) a))
(+ x (/ y t_1))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = a / (z - t);
double tmp;
if (y < -1.0761266216389975e-10) {
tmp = x + (1.0 / (t_1 / y));
} else if (y < 2.894426862792089e-49) {
tmp = x + ((y * (z - t)) / a);
} else {
tmp = x + (y / 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, 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) :: tmp
t_1 = a / (z - t)
if (y < (-1.0761266216389975d-10)) then
tmp = x + (1.0d0 / (t_1 / y))
else if (y < 2.894426862792089d-49) then
tmp = x + ((y * (z - t)) / a)
else
tmp = x + (y / t_1)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double t_1 = a / (z - t);
double tmp;
if (y < -1.0761266216389975e-10) {
tmp = x + (1.0 / (t_1 / y));
} else if (y < 2.894426862792089e-49) {
tmp = x + ((y * (z - t)) / a);
} else {
tmp = x + (y / t_1);
}
return tmp;
}
def code(x, y, z, t, a): t_1 = a / (z - t) tmp = 0 if y < -1.0761266216389975e-10: tmp = x + (1.0 / (t_1 / y)) elif y < 2.894426862792089e-49: tmp = x + ((y * (z - t)) / a) else: tmp = x + (y / t_1) return tmp
function code(x, y, z, t, a) t_1 = Float64(a / Float64(z - t)) tmp = 0.0 if (y < -1.0761266216389975e-10) tmp = Float64(x + Float64(1.0 / Float64(t_1 / y))); elseif (y < 2.894426862792089e-49) tmp = Float64(x + Float64(Float64(y * Float64(z - t)) / a)); else tmp = Float64(x + Float64(y / t_1)); end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = a / (z - t); tmp = 0.0; if (y < -1.0761266216389975e-10) tmp = x + (1.0 / (t_1 / y)); elseif (y < 2.894426862792089e-49) tmp = x + ((y * (z - t)) / a); else tmp = x + (y / t_1); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(a / N[(z - t), $MachinePrecision]), $MachinePrecision]}, If[Less[y, -1.0761266216389975e-10], N[(x + N[(1.0 / N[(t$95$1 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Less[y, 2.894426862792089e-49], N[(x + N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(x + N[(y / t$95$1), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{a}{z - t}\\
\mathbf{if}\;y < -1.0761266216389975 \cdot 10^{-10}:\\
\;\;\;\;x + \frac{1}{\frac{t\_1}{y}}\\
\mathbf{elif}\;y < 2.894426862792089 \cdot 10^{-49}:\\
\;\;\;\;x + \frac{y \cdot \left(z - t\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{y}{t\_1}\\
\end{array}
\end{array}
herbie shell --seed 2025091
(FPCore (x y z t a)
:name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, E"
:precision binary64
:alt
(! :herbie-platform default (if (< y -430450648655599/4000000000000000000000000) (+ x (/ 1 (/ (/ a (- z t)) y))) (if (< y 2894426862792089/10000000000000000000000000000000000000000000000000000000000000000) (+ x (/ (* y (- z t)) a)) (+ x (/ y (/ a (- z t)))))))
(+ x (/ (* y (- z t)) a)))