
(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}
Sampling outcomes in binary64 precision:
Herbie found 12 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))))
(if (or (<= t_1 -4e+238) (not (<= t_1 5e+70)))
(fma (/ (- z t) a) y x)
(+ x (/ t_1 a)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = y * (z - t);
double tmp;
if ((t_1 <= -4e+238) || !(t_1 <= 5e+70)) {
tmp = fma(((z - t) / a), y, x);
} else {
tmp = x + (t_1 / a);
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(y * Float64(z - t)) tmp = 0.0 if ((t_1 <= -4e+238) || !(t_1 <= 5e+70)) tmp = fma(Float64(Float64(z - t) / a), y, x); else tmp = Float64(x + Float64(t_1 / a)); end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -4e+238], N[Not[LessEqual[t$95$1, 5e+70]], $MachinePrecision]], N[(N[(N[(z - t), $MachinePrecision] / a), $MachinePrecision] * y + x), $MachinePrecision], N[(x + N[(t$95$1 / a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := y \cdot \left(z - t\right)\\
\mathbf{if}\;t\_1 \leq -4 \cdot 10^{+238} \lor \neg \left(t\_1 \leq 5 \cdot 10^{+70}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{z - t}{a}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;x + \frac{t\_1}{a}\\
\end{array}
\end{array}
if (*.f64 y (-.f64 z t)) < -4.0000000000000002e238 or 5.0000000000000002e70 < (*.f64 y (-.f64 z 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--.f6499.9
Applied rewrites99.9%
if -4.0000000000000002e238 < (*.f64 y (-.f64 z t)) < 5.0000000000000002e70Initial program 99.9%
Final simplification99.9%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (/ (* y (- z t)) a)))
(if (<= t_1 (- INFINITY))
(* (/ (- z t) a) y)
(if (or (<= t_1 -2e+76) (not (<= t_1 4e+121)))
(/ (* (- z t) y) a)
(- x (* y (/ t a)))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (y * (z - t)) / a;
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = ((z - t) / a) * y;
} else if ((t_1 <= -2e+76) || !(t_1 <= 4e+121)) {
tmp = ((z - t) * y) / a;
} else {
tmp = x - (y * (t / a));
}
return tmp;
}
public static double code(double x, double y, double z, double t, double a) {
double t_1 = (y * (z - t)) / a;
double tmp;
if (t_1 <= -Double.POSITIVE_INFINITY) {
tmp = ((z - t) / a) * y;
} else if ((t_1 <= -2e+76) || !(t_1 <= 4e+121)) {
tmp = ((z - t) * y) / a;
} else {
tmp = x - (y * (t / a));
}
return tmp;
}
def code(x, y, z, t, a): t_1 = (y * (z - t)) / a tmp = 0 if t_1 <= -math.inf: tmp = ((z - t) / a) * y elif (t_1 <= -2e+76) or not (t_1 <= 4e+121): tmp = ((z - t) * y) / a else: tmp = x - (y * (t / a)) return tmp
function code(x, y, z, t, a) t_1 = Float64(Float64(y * Float64(z - t)) / a) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(Float64(Float64(z - t) / a) * y); elseif ((t_1 <= -2e+76) || !(t_1 <= 4e+121)) tmp = Float64(Float64(Float64(z - t) * y) / a); else tmp = Float64(x - Float64(y * Float64(t / a))); end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = (y * (z - t)) / a; tmp = 0.0; if (t_1 <= -Inf) tmp = ((z - t) / a) * y; elseif ((t_1 <= -2e+76) || ~((t_1 <= 4e+121))) tmp = ((z - t) * y) / a; else tmp = x - (y * (t / a)); 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]}, If[LessEqual[t$95$1, (-Infinity)], N[(N[(N[(z - t), $MachinePrecision] / a), $MachinePrecision] * y), $MachinePrecision], If[Or[LessEqual[t$95$1, -2e+76], N[Not[LessEqual[t$95$1, 4e+121]], $MachinePrecision]], N[(N[(N[(z - t), $MachinePrecision] * y), $MachinePrecision] / a), $MachinePrecision], N[(x - N[(y * N[(t / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{y \cdot \left(z - t\right)}{a}\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;\frac{z - t}{a} \cdot y\\
\mathbf{elif}\;t\_1 \leq -2 \cdot 10^{+76} \lor \neg \left(t\_1 \leq 4 \cdot 10^{+121}\right):\\
\;\;\;\;\frac{\left(z - t\right) \cdot y}{a}\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \frac{t}{a}\\
\end{array}
\end{array}
if (/.f64 (*.f64 y (-.f64 z t)) a) < -inf.0Initial program 80.6%
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--.f6499.9
Applied rewrites99.9%
Taylor expanded in z around inf
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
associate-*l/N/A
lower-*.f64N/A
lift-/.f6473.3
Applied rewrites73.3%
Taylor expanded in x around 0
associate-/l*N/A
*-commutativeN/A
+-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6480.6
Applied rewrites80.6%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lift--.f6495.5
Applied rewrites95.5%
if -inf.0 < (/.f64 (*.f64 y (-.f64 z t)) a) < -2.0000000000000001e76 or 4.00000000000000015e121 < (/.f64 (*.f64 y (-.f64 z t)) a) Initial program 95.1%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6488.0
Applied rewrites88.0%
if -2.0000000000000001e76 < (/.f64 (*.f64 y (-.f64 z t)) a) < 4.00000000000000015e121Initial program 99.9%
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-/.f6488.4
Applied rewrites88.4%
Final simplification89.5%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (/ (* y (- z t)) a)))
(if (or (<= t_1 -2e+76) (not (<= t_1 4e+121)))
(/ (* (- z t) y) a)
(- x (* y (/ t a))))))
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+76) || !(t_1 <= 4e+121)) {
tmp = ((z - t) * y) / a;
} else {
tmp = x - (y * (t / a));
}
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 = (y * (z - t)) / a
if ((t_1 <= (-2d+76)) .or. (.not. (t_1 <= 4d+121))) then
tmp = ((z - t) * y) / a
else
tmp = x - (y * (t / a))
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 tmp;
if ((t_1 <= -2e+76) || !(t_1 <= 4e+121)) {
tmp = ((z - t) * y) / a;
} else {
tmp = x - (y * (t / a));
}
return tmp;
}
def code(x, y, z, t, a): t_1 = (y * (z - t)) / a tmp = 0 if (t_1 <= -2e+76) or not (t_1 <= 4e+121): tmp = ((z - t) * y) / a else: tmp = x - (y * (t / a)) 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+76) || !(t_1 <= 4e+121)) tmp = Float64(Float64(Float64(z - t) * y) / a); else tmp = Float64(x - Float64(y * Float64(t / a))); end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = (y * (z - t)) / a; tmp = 0.0; if ((t_1 <= -2e+76) || ~((t_1 <= 4e+121))) tmp = ((z - t) * y) / a; else tmp = x - (y * (t / a)); 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]}, If[Or[LessEqual[t$95$1, -2e+76], N[Not[LessEqual[t$95$1, 4e+121]], $MachinePrecision]], N[(N[(N[(z - t), $MachinePrecision] * y), $MachinePrecision] / a), $MachinePrecision], N[(x - N[(y * N[(t / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{y \cdot \left(z - t\right)}{a}\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{+76} \lor \neg \left(t\_1 \leq 4 \cdot 10^{+121}\right):\\
\;\;\;\;\frac{\left(z - t\right) \cdot y}{a}\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \frac{t}{a}\\
\end{array}
\end{array}
if (/.f64 (*.f64 y (-.f64 z t)) a) < -2.0000000000000001e76 or 4.00000000000000015e121 < (/.f64 (*.f64 y (-.f64 z t)) a) Initial program 90.7%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6485.8
Applied rewrites85.8%
if -2.0000000000000001e76 < (/.f64 (*.f64 y (-.f64 z t)) a) < 4.00000000000000015e121Initial program 99.9%
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-/.f6488.4
Applied rewrites88.4%
Final simplification86.9%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (/ (* y (- z t)) a))) (if (or (<= t_1 -1e+184) (not (<= t_1 2e+276))) (* (/ y a) z) x)))
double code(double x, double y, double z, double t, double a) {
double t_1 = (y * (z - t)) / a;
double tmp;
if ((t_1 <= -1e+184) || !(t_1 <= 2e+276)) {
tmp = (y / a) * z;
} else {
tmp = x;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, 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 = (y * (z - t)) / a
if ((t_1 <= (-1d+184)) .or. (.not. (t_1 <= 2d+276))) then
tmp = (y / a) * z
else
tmp = x
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 tmp;
if ((t_1 <= -1e+184) || !(t_1 <= 2e+276)) {
tmp = (y / a) * z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = (y * (z - t)) / a tmp = 0 if (t_1 <= -1e+184) or not (t_1 <= 2e+276): tmp = (y / a) * z else: tmp = x return tmp
function code(x, y, z, t, a) t_1 = Float64(Float64(y * Float64(z - t)) / a) tmp = 0.0 if ((t_1 <= -1e+184) || !(t_1 <= 2e+276)) tmp = Float64(Float64(y / a) * z); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = (y * (z - t)) / a; tmp = 0.0; if ((t_1 <= -1e+184) || ~((t_1 <= 2e+276))) tmp = (y / a) * z; else tmp = x; 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]}, If[Or[LessEqual[t$95$1, -1e+184], N[Not[LessEqual[t$95$1, 2e+276]], $MachinePrecision]], N[(N[(y / a), $MachinePrecision] * z), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{y \cdot \left(z - t\right)}{a}\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+184} \lor \neg \left(t\_1 \leq 2 \cdot 10^{+276}\right):\\
\;\;\;\;\frac{y}{a} \cdot z\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if (/.f64 (*.f64 y (-.f64 z t)) a) < -1.00000000000000002e184 or 2.0000000000000001e276 < (/.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
associate-/l*N/A
sub-divN/A
*-commutativeN/A
lower-fma.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6491.8
Applied rewrites91.8%
Taylor expanded in z around inf
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
associate-*l/N/A
lower-*.f64N/A
lift-/.f6460.3
Applied rewrites60.3%
if -1.00000000000000002e184 < (/.f64 (*.f64 y (-.f64 z t)) a) < 2.0000000000000001e276Initial program 99.9%
Taylor expanded in x around inf
Applied rewrites64.7%
Final simplification62.7%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (/ (* y (- z t)) a))) (if (<= t_1 -1e+184) (* (/ y a) z) (if (<= t_1 2e+154) x (/ (* y z) a)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (y * (z - t)) / a;
double tmp;
if (t_1 <= -1e+184) {
tmp = (y / a) * z;
} else if (t_1 <= 2e+154) {
tmp = x;
} else {
tmp = (y * z) / a;
}
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 = (y * (z - t)) / a
if (t_1 <= (-1d+184)) then
tmp = (y / a) * z
else if (t_1 <= 2d+154) then
tmp = x
else
tmp = (y * z) / a
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 tmp;
if (t_1 <= -1e+184) {
tmp = (y / a) * z;
} else if (t_1 <= 2e+154) {
tmp = x;
} else {
tmp = (y * z) / a;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = (y * (z - t)) / a tmp = 0 if t_1 <= -1e+184: tmp = (y / a) * z elif t_1 <= 2e+154: tmp = x else: tmp = (y * z) / a return tmp
function code(x, y, z, t, a) t_1 = Float64(Float64(y * Float64(z - t)) / a) tmp = 0.0 if (t_1 <= -1e+184) tmp = Float64(Float64(y / a) * z); elseif (t_1 <= 2e+154) tmp = x; else tmp = Float64(Float64(y * z) / a); end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = (y * (z - t)) / a; tmp = 0.0; if (t_1 <= -1e+184) tmp = (y / a) * z; elseif (t_1 <= 2e+154) tmp = x; else tmp = (y * z) / a; 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]}, If[LessEqual[t$95$1, -1e+184], N[(N[(y / a), $MachinePrecision] * z), $MachinePrecision], If[LessEqual[t$95$1, 2e+154], x, N[(N[(y * z), $MachinePrecision] / a), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{y \cdot \left(z - t\right)}{a}\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+184}:\\
\;\;\;\;\frac{y}{a} \cdot z\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+154}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{y \cdot z}{a}\\
\end{array}
\end{array}
if (/.f64 (*.f64 y (-.f64 z t)) a) < -1.00000000000000002e184Initial program 85.4%
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--.f6490.4
Applied rewrites90.4%
Taylor expanded in z around inf
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
associate-*l/N/A
lower-*.f64N/A
lift-/.f6463.5
Applied rewrites63.5%
if -1.00000000000000002e184 < (/.f64 (*.f64 y (-.f64 z t)) a) < 2.00000000000000007e154Initial program 99.9%
Taylor expanded in x around inf
Applied rewrites69.2%
if 2.00000000000000007e154 < (/.f64 (*.f64 y (-.f64 z t)) a) Initial program 92.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--.f6490.2
Applied rewrites90.2%
Taylor expanded in z around inf
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
associate-*l/N/A
lower-*.f64N/A
lift-/.f6448.7
Applied rewrites48.7%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f6449.8
Applied rewrites49.8%
Final simplification62.8%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (/ (* y (- z t)) a))) (if (<= t_1 -1e+184) (* (/ y a) z) (if (<= t_1 5e+172) x (* (/ z a) y)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (y * (z - t)) / a;
double tmp;
if (t_1 <= -1e+184) {
tmp = (y / a) * z;
} else if (t_1 <= 5e+172) {
tmp = x;
} else {
tmp = (z / a) * y;
}
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 = (y * (z - t)) / a
if (t_1 <= (-1d+184)) then
tmp = (y / a) * z
else if (t_1 <= 5d+172) then
tmp = x
else
tmp = (z / a) * y
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 tmp;
if (t_1 <= -1e+184) {
tmp = (y / a) * z;
} else if (t_1 <= 5e+172) {
tmp = x;
} else {
tmp = (z / a) * y;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = (y * (z - t)) / a tmp = 0 if t_1 <= -1e+184: tmp = (y / a) * z elif t_1 <= 5e+172: tmp = x else: tmp = (z / a) * y return tmp
function code(x, y, z, t, a) t_1 = Float64(Float64(y * Float64(z - t)) / a) tmp = 0.0 if (t_1 <= -1e+184) tmp = Float64(Float64(y / a) * z); elseif (t_1 <= 5e+172) tmp = x; else tmp = Float64(Float64(z / a) * y); end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = (y * (z - t)) / a; tmp = 0.0; if (t_1 <= -1e+184) tmp = (y / a) * z; elseif (t_1 <= 5e+172) tmp = x; else tmp = (z / a) * y; 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]}, If[LessEqual[t$95$1, -1e+184], N[(N[(y / a), $MachinePrecision] * z), $MachinePrecision], If[LessEqual[t$95$1, 5e+172], x, N[(N[(z / a), $MachinePrecision] * y), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{y \cdot \left(z - t\right)}{a}\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+184}:\\
\;\;\;\;\frac{y}{a} \cdot z\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+172}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{z}{a} \cdot y\\
\end{array}
\end{array}
if (/.f64 (*.f64 y (-.f64 z t)) a) < -1.00000000000000002e184Initial program 85.4%
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--.f6490.4
Applied rewrites90.4%
Taylor expanded in z around inf
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
associate-*l/N/A
lower-*.f64N/A
lift-/.f6463.5
Applied rewrites63.5%
if -1.00000000000000002e184 < (/.f64 (*.f64 y (-.f64 z t)) a) < 5.0000000000000001e172Initial program 99.9%
Taylor expanded in x around inf
Applied rewrites68.1%
if 5.0000000000000001e172 < (/.f64 (*.f64 y (-.f64 z t)) a) Initial program 92.4%
Taylor expanded in z around inf
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6450.7
Applied rewrites50.7%
Final simplification62.8%
(FPCore (x y z t a) :precision binary64 (if (<= z -10000000000.0) (fma (/ y a) z x) (if (<= z 1.9e+54) (- x (* y (/ t a))) (fma (/ z a) y x))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -10000000000.0) {
tmp = fma((y / a), z, x);
} else if (z <= 1.9e+54) {
tmp = x - (y * (t / a));
} else {
tmp = fma((z / a), y, x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -10000000000.0) tmp = fma(Float64(y / a), z, x); elseif (z <= 1.9e+54) tmp = Float64(x - Float64(y * Float64(t / a))); else tmp = fma(Float64(z / a), y, x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -10000000000.0], N[(N[(y / a), $MachinePrecision] * z + x), $MachinePrecision], If[LessEqual[z, 1.9e+54], N[(x - N[(y * N[(t / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(z / a), $MachinePrecision] * y + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -10000000000:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a}, z, x\right)\\
\mathbf{elif}\;z \leq 1.9 \cdot 10^{+54}:\\
\;\;\;\;x - y \cdot \frac{t}{a}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{a}, y, x\right)\\
\end{array}
\end{array}
if z < -1e10Initial program 96.4%
Taylor expanded in t around 0
+-commutativeN/A
associate-*l/N/A
lower-fma.f64N/A
lower-/.f6491.1
Applied rewrites91.1%
if -1e10 < z < 1.9000000000000001e54Initial program 96.0%
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.3
Applied rewrites82.3%
if 1.9000000000000001e54 < z Initial program 89.4%
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--.f6496.4
Applied rewrites96.4%
Taylor expanded in z around inf
lower-/.f6487.5
Applied rewrites87.5%
Final simplification85.2%
(FPCore (x y z t a) :precision binary64 (if (or (<= t -1.15e+119) (not (<= t 9.4e+86))) (* (/ (- y) a) t) (fma (/ y a) z x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((t <= -1.15e+119) || !(t <= 9.4e+86)) {
tmp = (-y / a) * t;
} else {
tmp = fma((y / a), z, x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((t <= -1.15e+119) || !(t <= 9.4e+86)) tmp = Float64(Float64(Float64(-y) / a) * t); else tmp = fma(Float64(y / a), z, x); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[t, -1.15e+119], N[Not[LessEqual[t, 9.4e+86]], $MachinePrecision]], N[(N[((-y) / a), $MachinePrecision] * t), $MachinePrecision], N[(N[(y / a), $MachinePrecision] * z + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.15 \cdot 10^{+119} \lor \neg \left(t \leq 9.4 \cdot 10^{+86}\right):\\
\;\;\;\;\frac{-y}{a} \cdot t\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a}, z, x\right)\\
\end{array}
\end{array}
if t < -1.15e119 or 9.4000000000000004e86 < t Initial program 90.0%
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.f6466.4
Applied rewrites66.4%
if -1.15e119 < t < 9.4000000000000004e86Initial program 97.1%
Taylor expanded in t around 0
+-commutativeN/A
associate-*l/N/A
lower-fma.f64N/A
lower-/.f6482.3
Applied rewrites82.3%
Final simplification76.9%
(FPCore (x y z t a) :precision binary64 (if (<= t 6.4e+87) (fma (/ y a) z x) (* (/ (- t) a) y)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= 6.4e+87) {
tmp = fma((y / a), z, x);
} else {
tmp = (-t / a) * y;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (t <= 6.4e+87) tmp = fma(Float64(y / a), z, x); else tmp = Float64(Float64(Float64(-t) / a) * y); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, 6.4e+87], N[(N[(y / a), $MachinePrecision] * z + x), $MachinePrecision], N[(N[((-t) / a), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq 6.4 \cdot 10^{+87}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a}, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{-t}{a} \cdot y\\
\end{array}
\end{array}
if t < 6.4000000000000001e87Initial program 96.1%
Taylor expanded in t around 0
+-commutativeN/A
associate-*l/N/A
lower-fma.f64N/A
lower-/.f6475.9
Applied rewrites75.9%
if 6.4000000000000001e87 < t 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--.f6488.0
Applied rewrites88.0%
Taylor expanded in t around inf
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
associate-*r/N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6456.3
Applied rewrites56.3%
Final simplification71.7%
(FPCore (x y z t a) :precision binary64 (fma (/ (- z t) a) y x))
double code(double x, double y, double z, double t, double a) {
return fma(((z - t) / a), y, x);
}
function code(x, y, z, t, a) return fma(Float64(Float64(z - t) / a), y, x) end
code[x_, y_, z_, t_, a_] := N[(N[(N[(z - t), $MachinePrecision] / a), $MachinePrecision] * y + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{z - t}{a}, y, x\right)
\end{array}
Initial program 94.7%
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--.f6492.1
Applied rewrites92.1%
(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 94.7%
Taylor expanded in t around 0
+-commutativeN/A
associate-*l/N/A
lower-fma.f64N/A
lower-/.f6468.9
Applied rewrites68.9%
Final simplification68.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 94.7%
Taylor expanded in x around inf
Applied rewrites38.6%
Final simplification38.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 2025037
(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)))