
(FPCore (x y z t a) :precision binary64 (+ x (/ (* (- y x) (- z t)) (- a t))))
double code(double x, double y, double z, double t, double a) {
return x + (((y - x) * (z - t)) / (a - t));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, 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 - x) * (z - t)) / (a - t))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + (((y - x) * (z - t)) / (a - t));
}
def code(x, y, z, t, a): return x + (((y - x) * (z - t)) / (a - t))
function code(x, y, z, t, a) return Float64(x + Float64(Float64(Float64(y - x) * Float64(z - t)) / Float64(a - t))) end
function tmp = code(x, y, z, t, a) tmp = x + (((y - x) * (z - t)) / (a - t)); end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(N[(y - x), $MachinePrecision] * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 20 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a) :precision binary64 (+ x (/ (* (- y x) (- z t)) (- a t))))
double code(double x, double y, double z, double t, double a) {
return x + (((y - x) * (z - t)) / (a - t));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, 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 - x) * (z - t)) / (a - t))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + (((y - x) * (z - t)) / (a - t));
}
def code(x, y, z, t, a): return x + (((y - x) * (z - t)) / (a - t))
function code(x, y, z, t, a) return Float64(x + Float64(Float64(Float64(y - x) * Float64(z - t)) / Float64(a - t))) end
function tmp = code(x, y, z, t, a) tmp = x + (((y - x) * (z - t)) / (a - t)); end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(N[(y - x), $MachinePrecision] * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}
\end{array}
(FPCore (x y z t a)
:precision binary64
(if (or (<= y -5.8e-15) (not (<= y 9.5e-97)))
(fma (- y x) (/ (- z t) (- a t)) x)
(*
(- x)
(-
(fma (/ (/ (* (- z t) y) x) (- a t)) -1.0 (/ z (- a t)))
(- (/ t (- a t)) -1.0)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((y <= -5.8e-15) || !(y <= 9.5e-97)) {
tmp = fma((y - x), ((z - t) / (a - t)), x);
} else {
tmp = -x * (fma(((((z - t) * y) / x) / (a - t)), -1.0, (z / (a - t))) - ((t / (a - t)) - -1.0));
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((y <= -5.8e-15) || !(y <= 9.5e-97)) tmp = fma(Float64(y - x), Float64(Float64(z - t) / Float64(a - t)), x); else tmp = Float64(Float64(-x) * Float64(fma(Float64(Float64(Float64(Float64(z - t) * y) / x) / Float64(a - t)), -1.0, Float64(z / Float64(a - t))) - Float64(Float64(t / Float64(a - t)) - -1.0))); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[y, -5.8e-15], N[Not[LessEqual[y, 9.5e-97]], $MachinePrecision]], N[(N[(y - x), $MachinePrecision] * N[(N[(z - t), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[((-x) * N[(N[(N[(N[(N[(N[(z - t), $MachinePrecision] * y), $MachinePrecision] / x), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision] * -1.0 + N[(z / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(t / N[(a - t), $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.8 \cdot 10^{-15} \lor \neg \left(y \leq 9.5 \cdot 10^{-97}\right):\\
\;\;\;\;\mathsf{fma}\left(y - x, \frac{z - t}{a - t}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(-x\right) \cdot \left(\mathsf{fma}\left(\frac{\frac{\left(z - t\right) \cdot y}{x}}{a - t}, -1, \frac{z}{a - t}\right) - \left(\frac{t}{a - t} - -1\right)\right)\\
\end{array}
\end{array}
if y < -5.80000000000000037e-15 or 9.5000000000000001e-97 < y Initial program 65.7%
lift-+.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
associate-/l*N/A
sub-divN/A
lower-fma.f64N/A
lift--.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6491.9
Applied rewrites91.9%
if -5.80000000000000037e-15 < y < 9.5000000000000001e-97Initial program 68.8%
Taylor expanded in x around -inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
Applied rewrites94.3%
Final simplification92.8%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (+ x (/ (* (- y x) (- z t)) (- a t)))))
(if (or (<= t_1 -2e-275) (not (<= t_1 0.0)))
(fma (- y x) (/ (- z t) (- a t)) x)
(+ (fma (/ (* (- y x) z) t) -1.0 y) (/ (* (- y x) a) t)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = x + (((y - x) * (z - t)) / (a - t));
double tmp;
if ((t_1 <= -2e-275) || !(t_1 <= 0.0)) {
tmp = fma((y - x), ((z - t) / (a - t)), x);
} else {
tmp = fma((((y - x) * z) / t), -1.0, y) + (((y - x) * a) / t);
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(x + Float64(Float64(Float64(y - x) * Float64(z - t)) / Float64(a - t))) tmp = 0.0 if ((t_1 <= -2e-275) || !(t_1 <= 0.0)) tmp = fma(Float64(y - x), Float64(Float64(z - t) / Float64(a - t)), x); else tmp = Float64(fma(Float64(Float64(Float64(y - x) * z) / t), -1.0, y) + Float64(Float64(Float64(y - x) * a) / t)); end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(x + N[(N[(N[(y - x), $MachinePrecision] * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -2e-275], N[Not[LessEqual[t$95$1, 0.0]], $MachinePrecision]], N[(N[(y - x), $MachinePrecision] * N[(N[(z - t), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[(N[(N[(N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision] / t), $MachinePrecision] * -1.0 + y), $MachinePrecision] + N[(N[(N[(y - x), $MachinePrecision] * a), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{-275} \lor \neg \left(t\_1 \leq 0\right):\\
\;\;\;\;\mathsf{fma}\left(y - x, \frac{z - t}{a - t}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\left(y - x\right) \cdot z}{t}, -1, y\right) + \frac{\left(y - x\right) \cdot a}{t}\\
\end{array}
\end{array}
if (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) < -1.99999999999999987e-275 or 0.0 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) Initial program 71.3%
lift-+.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
associate-/l*N/A
sub-divN/A
lower-fma.f64N/A
lift--.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6491.8
Applied rewrites91.8%
if -1.99999999999999987e-275 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) < 0.0Initial program 5.4%
lift-+.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
associate-/l*N/A
sub-divN/A
lower-fma.f64N/A
lift--.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f64N/A
lift--.f645.4
Applied rewrites5.4%
Taylor expanded in t around inf
associate-*r/N/A
+-commutativeN/A
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6499.8
Applied rewrites99.8%
Final simplification92.3%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (+ x (/ (* (- y x) (- z t)) (- a t)))))
(if (or (<= t_1 -2e-275) (not (<= t_1 0.0)))
(fma (- y x) (/ (- z t) (- a t)) x)
(fma (/ (* (- y x) (- z a)) t) -1.0 y))))
double code(double x, double y, double z, double t, double a) {
double t_1 = x + (((y - x) * (z - t)) / (a - t));
double tmp;
if ((t_1 <= -2e-275) || !(t_1 <= 0.0)) {
tmp = fma((y - x), ((z - t) / (a - t)), x);
} else {
tmp = fma((((y - x) * (z - a)) / t), -1.0, y);
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(x + Float64(Float64(Float64(y - x) * Float64(z - t)) / Float64(a - t))) tmp = 0.0 if ((t_1 <= -2e-275) || !(t_1 <= 0.0)) tmp = fma(Float64(y - x), Float64(Float64(z - t) / Float64(a - t)), x); else tmp = fma(Float64(Float64(Float64(y - x) * Float64(z - a)) / t), -1.0, y); end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(x + N[(N[(N[(y - x), $MachinePrecision] * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -2e-275], N[Not[LessEqual[t$95$1, 0.0]], $MachinePrecision]], N[(N[(y - x), $MachinePrecision] * N[(N[(z - t), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[(N[(N[(N[(y - x), $MachinePrecision] * N[(z - a), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision] * -1.0 + y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{-275} \lor \neg \left(t\_1 \leq 0\right):\\
\;\;\;\;\mathsf{fma}\left(y - x, \frac{z - t}{a - t}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\left(y - x\right) \cdot \left(z - a\right)}{t}, -1, y\right)\\
\end{array}
\end{array}
if (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) < -1.99999999999999987e-275 or 0.0 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) Initial program 71.3%
lift-+.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
associate-/l*N/A
sub-divN/A
lower-fma.f64N/A
lift--.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6491.8
Applied rewrites91.8%
if -1.99999999999999987e-275 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) < 0.0Initial program 5.4%
Taylor expanded in t around inf
associate--l+N/A
associate-*r/N/A
associate-*r/N/A
sub-divN/A
distribute-lft-out--N/A
associate-*r/N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites99.7%
Final simplification92.3%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (+ x (/ (* (- y x) (- z t)) (- a t)))))
(if (or (<= t_1 -2e-275) (not (<= t_1 0.0)))
(fma (- y x) (/ (- z t) (- a t)) x)
(fma (/ (- y x) t) a y))))
double code(double x, double y, double z, double t, double a) {
double t_1 = x + (((y - x) * (z - t)) / (a - t));
double tmp;
if ((t_1 <= -2e-275) || !(t_1 <= 0.0)) {
tmp = fma((y - x), ((z - t) / (a - t)), x);
} else {
tmp = fma(((y - x) / t), a, y);
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(x + Float64(Float64(Float64(y - x) * Float64(z - t)) / Float64(a - t))) tmp = 0.0 if ((t_1 <= -2e-275) || !(t_1 <= 0.0)) tmp = fma(Float64(y - x), Float64(Float64(z - t) / Float64(a - t)), x); else tmp = fma(Float64(Float64(y - x) / t), a, y); end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(x + N[(N[(N[(y - x), $MachinePrecision] * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -2e-275], N[Not[LessEqual[t$95$1, 0.0]], $MachinePrecision]], N[(N[(y - x), $MachinePrecision] * N[(N[(z - t), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[(N[(N[(y - x), $MachinePrecision] / t), $MachinePrecision] * a + y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{-275} \lor \neg \left(t\_1 \leq 0\right):\\
\;\;\;\;\mathsf{fma}\left(y - x, \frac{z - t}{a - t}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y - x}{t}, a, y\right)\\
\end{array}
\end{array}
if (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) < -1.99999999999999987e-275 or 0.0 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) Initial program 71.3%
lift-+.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
associate-/l*N/A
sub-divN/A
lower-fma.f64N/A
lift--.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6491.8
Applied rewrites91.8%
if -1.99999999999999987e-275 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) < 0.0Initial program 5.4%
Taylor expanded in t around inf
associate--l+N/A
associate-*r/N/A
associate-*r/N/A
sub-divN/A
distribute-lft-out--N/A
associate-*r/N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites99.7%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
sub-divN/A
*-commutativeN/A
lower-fma.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6465.9
Applied rewrites65.9%
Final simplification90.0%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma (- y x) (/ z a) x)))
(if (<= a -7e-54)
t_1
(if (<= a -1.35e-130)
(* (- z) (/ (- y x) t))
(if (<= a -4.8e-219)
y
(if (<= a 1.3e-114) (/ (* (- y x) z) (- t)) t_1))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma((y - x), (z / a), x);
double tmp;
if (a <= -7e-54) {
tmp = t_1;
} else if (a <= -1.35e-130) {
tmp = -z * ((y - x) / t);
} else if (a <= -4.8e-219) {
tmp = y;
} else if (a <= 1.3e-114) {
tmp = ((y - x) * z) / -t;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(y - x), Float64(z / a), x) tmp = 0.0 if (a <= -7e-54) tmp = t_1; elseif (a <= -1.35e-130) tmp = Float64(Float64(-z) * Float64(Float64(y - x) / t)); elseif (a <= -4.8e-219) tmp = y; elseif (a <= 1.3e-114) tmp = Float64(Float64(Float64(y - x) * z) / Float64(-t)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(y - x), $MachinePrecision] * N[(z / a), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[a, -7e-54], t$95$1, If[LessEqual[a, -1.35e-130], N[((-z) * N[(N[(y - x), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, -4.8e-219], y, If[LessEqual[a, 1.3e-114], N[(N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision] / (-t)), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(y - x, \frac{z}{a}, x\right)\\
\mathbf{if}\;a \leq -7 \cdot 10^{-54}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \leq -1.35 \cdot 10^{-130}:\\
\;\;\;\;\left(-z\right) \cdot \frac{y - x}{t}\\
\mathbf{elif}\;a \leq -4.8 \cdot 10^{-219}:\\
\;\;\;\;y\\
\mathbf{elif}\;a \leq 1.3 \cdot 10^{-114}:\\
\;\;\;\;\frac{\left(y - x\right) \cdot z}{-t}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if a < -6.99999999999999964e-54 or 1.30000000000000007e-114 < a Initial program 72.0%
lift-+.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
associate-/l*N/A
sub-divN/A
lower-fma.f64N/A
lift--.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6495.0
Applied rewrites95.0%
Taylor expanded in t around 0
lower-/.f6466.2
Applied rewrites66.2%
if -6.99999999999999964e-54 < a < -1.34999999999999996e-130Initial program 58.7%
Taylor expanded in z around inf
sub-divN/A
associate-/l*N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64N/A
lift--.f6446.0
Applied rewrites46.0%
Taylor expanded in t around 0
lower-/.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift--.f6416.1
Applied rewrites16.1%
Taylor expanded in t around inf
associate-/l*N/A
sub-divN/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6463.4
Applied rewrites63.4%
if -1.34999999999999996e-130 < a < -4.80000000000000028e-219Initial program 46.0%
Taylor expanded in t around inf
Applied rewrites63.5%
if -4.80000000000000028e-219 < a < 1.30000000000000007e-114Initial program 63.4%
Taylor expanded in z around inf
sub-divN/A
associate-/l*N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64N/A
lift--.f6462.4
Applied rewrites62.4%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6453.0
Applied rewrites53.0%
Final simplification62.5%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (* (- z) (/ (- y x) t))) (t_2 (fma (- y x) (/ z a) x)))
(if (<= a -7e-54)
t_2
(if (<= a -1.35e-130)
t_1
(if (<= a -1.45e-219) y (if (<= a 1.04e-109) t_1 t_2))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = -z * ((y - x) / t);
double t_2 = fma((y - x), (z / a), x);
double tmp;
if (a <= -7e-54) {
tmp = t_2;
} else if (a <= -1.35e-130) {
tmp = t_1;
} else if (a <= -1.45e-219) {
tmp = y;
} else if (a <= 1.04e-109) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(Float64(-z) * Float64(Float64(y - x) / t)) t_2 = fma(Float64(y - x), Float64(z / a), x) tmp = 0.0 if (a <= -7e-54) tmp = t_2; elseif (a <= -1.35e-130) tmp = t_1; elseif (a <= -1.45e-219) tmp = y; elseif (a <= 1.04e-109) tmp = t_1; else tmp = t_2; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[((-z) * N[(N[(y - x), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(y - x), $MachinePrecision] * N[(z / a), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[a, -7e-54], t$95$2, If[LessEqual[a, -1.35e-130], t$95$1, If[LessEqual[a, -1.45e-219], y, If[LessEqual[a, 1.04e-109], t$95$1, t$95$2]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(-z\right) \cdot \frac{y - x}{t}\\
t_2 := \mathsf{fma}\left(y - x, \frac{z}{a}, x\right)\\
\mathbf{if}\;a \leq -7 \cdot 10^{-54}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;a \leq -1.35 \cdot 10^{-130}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \leq -1.45 \cdot 10^{-219}:\\
\;\;\;\;y\\
\mathbf{elif}\;a \leq 1.04 \cdot 10^{-109}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if a < -6.99999999999999964e-54 or 1.03999999999999996e-109 < a Initial program 72.0%
lift-+.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
associate-/l*N/A
sub-divN/A
lower-fma.f64N/A
lift--.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6495.0
Applied rewrites95.0%
Taylor expanded in t around 0
lower-/.f6466.2
Applied rewrites66.2%
if -6.99999999999999964e-54 < a < -1.34999999999999996e-130 or -1.44999999999999992e-219 < a < 1.03999999999999996e-109Initial program 62.4%
Taylor expanded in z around inf
sub-divN/A
associate-/l*N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64N/A
lift--.f6459.1
Applied rewrites59.1%
Taylor expanded in t around 0
lower-/.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift--.f6416.6
Applied rewrites16.6%
Taylor expanded in t around inf
associate-/l*N/A
sub-divN/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6452.7
Applied rewrites52.7%
if -1.34999999999999996e-130 < a < -1.44999999999999992e-219Initial program 46.0%
Taylor expanded in t around inf
Applied rewrites63.5%
Final simplification61.8%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -8e+177) (not (<= z 1.5e+107))) (* (- y x) (/ z (- a t))) (fma y (/ (- z t) (- a t)) x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -8e+177) || !(z <= 1.5e+107)) {
tmp = (y - x) * (z / (a - t));
} else {
tmp = fma(y, ((z - t) / (a - t)), x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -8e+177) || !(z <= 1.5e+107)) tmp = Float64(Float64(y - x) * Float64(z / Float64(a - t))); else tmp = fma(y, Float64(Float64(z - t) / Float64(a - t)), x); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -8e+177], N[Not[LessEqual[z, 1.5e+107]], $MachinePrecision]], N[(N[(y - x), $MachinePrecision] * N[(z / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * N[(N[(z - t), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8 \cdot 10^{+177} \lor \neg \left(z \leq 1.5 \cdot 10^{+107}\right):\\
\;\;\;\;\left(y - x\right) \cdot \frac{z}{a - t}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z - t}{a - t}, x\right)\\
\end{array}
\end{array}
if z < -8.0000000000000001e177 or 1.50000000000000012e107 < z Initial program 65.8%
Taylor expanded in z around inf
sub-divN/A
associate-/l*N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64N/A
lift--.f6462.9
Applied rewrites62.9%
lift--.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6485.9
Applied rewrites85.9%
if -8.0000000000000001e177 < z < 1.50000000000000012e107Initial program 67.4%
lift-+.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
associate-/l*N/A
sub-divN/A
lower-fma.f64N/A
lift--.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6482.0
Applied rewrites82.0%
Taylor expanded in x around 0
Applied rewrites72.6%
Final simplification76.8%
(FPCore (x y z t a) :precision binary64 (if (or (<= a -9e-28) (not (<= a 6.8e-19))) (fma (- y x) (/ (- z t) a) x) (* y (/ (- z t) (- a t)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((a <= -9e-28) || !(a <= 6.8e-19)) {
tmp = fma((y - x), ((z - t) / a), x);
} else {
tmp = y * ((z - t) / (a - t));
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((a <= -9e-28) || !(a <= 6.8e-19)) tmp = fma(Float64(y - x), Float64(Float64(z - t) / a), x); else tmp = Float64(y * Float64(Float64(z - t) / Float64(a - t))); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[a, -9e-28], N[Not[LessEqual[a, 6.8e-19]], $MachinePrecision]], N[(N[(y - x), $MachinePrecision] * N[(N[(z - t), $MachinePrecision] / a), $MachinePrecision] + x), $MachinePrecision], N[(y * N[(N[(z - t), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -9 \cdot 10^{-28} \lor \neg \left(a \leq 6.8 \cdot 10^{-19}\right):\\
\;\;\;\;\mathsf{fma}\left(y - x, \frac{z - t}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{z - t}{a - t}\\
\end{array}
\end{array}
if a < -8.9999999999999996e-28 or 6.8000000000000004e-19 < a Initial program 73.5%
Taylor expanded in a around inf
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6483.7
Applied rewrites83.7%
if -8.9999999999999996e-28 < a < 6.8000000000000004e-19Initial program 60.2%
lift-+.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
associate-/l*N/A
sub-divN/A
lower-fma.f64N/A
lift--.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6474.9
Applied rewrites74.9%
Taylor expanded in z around -inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64N/A
inv-powN/A
lower-pow.f64N/A
lift--.f6465.2
Applied rewrites65.2%
Taylor expanded in y around inf
sub-divN/A
lower-*.f64N/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6466.4
Applied rewrites66.4%
Final simplification75.1%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma z (/ y a) x)))
(if (<= a -1.02e-25)
t_1
(if (<= a -6.8e-129) (* (/ (- z a) t) x) (if (<= a 2.4e-65) y t_1)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma(z, (y / a), x);
double tmp;
if (a <= -1.02e-25) {
tmp = t_1;
} else if (a <= -6.8e-129) {
tmp = ((z - a) / t) * x;
} else if (a <= 2.4e-65) {
tmp = y;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(z, Float64(y / a), x) tmp = 0.0 if (a <= -1.02e-25) tmp = t_1; elseif (a <= -6.8e-129) tmp = Float64(Float64(Float64(z - a) / t) * x); elseif (a <= 2.4e-65) tmp = y; else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(z * N[(y / a), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[a, -1.02e-25], t$95$1, If[LessEqual[a, -6.8e-129], N[(N[(N[(z - a), $MachinePrecision] / t), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[a, 2.4e-65], y, t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(z, \frac{y}{a}, x\right)\\
\mathbf{if}\;a \leq -1.02 \cdot 10^{-25}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \leq -6.8 \cdot 10^{-129}:\\
\;\;\;\;\frac{z - a}{t} \cdot x\\
\mathbf{elif}\;a \leq 2.4 \cdot 10^{-65}:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if a < -1.01999999999999998e-25 or 2.4000000000000002e-65 < a Initial program 72.0%
Taylor expanded in t around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6467.4
Applied rewrites67.4%
Taylor expanded in x around 0
Applied rewrites54.9%
if -1.01999999999999998e-25 < a < -6.80000000000000026e-129Initial program 60.1%
Taylor expanded in t around inf
associate--l+N/A
associate-*r/N/A
associate-*r/N/A
sub-divN/A
distribute-lft-out--N/A
associate-*r/N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites69.7%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6453.5
Applied rewrites53.5%
if -6.80000000000000026e-129 < a < 2.4000000000000002e-65Initial program 61.0%
Taylor expanded in t around inf
Applied rewrites41.2%
Final simplification49.6%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -1.3e+110) (not (<= z 8e-19))) (* (- y x) (/ z (- a t))) (* y (/ (- z t) (- a t)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -1.3e+110) || !(z <= 8e-19)) {
tmp = (y - x) * (z / (a - t));
} else {
tmp = y * ((z - t) / (a - t));
}
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) :: tmp
if ((z <= (-1.3d+110)) .or. (.not. (z <= 8d-19))) then
tmp = (y - x) * (z / (a - t))
else
tmp = y * ((z - t) / (a - t))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -1.3e+110) || !(z <= 8e-19)) {
tmp = (y - x) * (z / (a - t));
} else {
tmp = y * ((z - t) / (a - t));
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (z <= -1.3e+110) or not (z <= 8e-19): tmp = (y - x) * (z / (a - t)) else: tmp = y * ((z - t) / (a - t)) return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -1.3e+110) || !(z <= 8e-19)) tmp = Float64(Float64(y - x) * Float64(z / Float64(a - t))); else tmp = Float64(y * Float64(Float64(z - t) / Float64(a - t))); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((z <= -1.3e+110) || ~((z <= 8e-19))) tmp = (y - x) * (z / (a - t)); else tmp = y * ((z - t) / (a - t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -1.3e+110], N[Not[LessEqual[z, 8e-19]], $MachinePrecision]], N[(N[(y - x), $MachinePrecision] * N[(z / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * N[(N[(z - t), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.3 \cdot 10^{+110} \lor \neg \left(z \leq 8 \cdot 10^{-19}\right):\\
\;\;\;\;\left(y - x\right) \cdot \frac{z}{a - t}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{z - t}{a - t}\\
\end{array}
\end{array}
if z < -1.3e110 or 7.9999999999999998e-19 < z Initial program 68.2%
Taylor expanded in z around inf
sub-divN/A
associate-/l*N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64N/A
lift--.f6460.4
Applied rewrites60.4%
lift--.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6478.9
Applied rewrites78.9%
if -1.3e110 < z < 7.9999999999999998e-19Initial program 65.9%
lift-+.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
associate-/l*N/A
sub-divN/A
lower-fma.f64N/A
lift--.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6480.9
Applied rewrites80.9%
Taylor expanded in z around -inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64N/A
inv-powN/A
lower-pow.f64N/A
lift--.f6474.6
Applied rewrites74.6%
Taylor expanded in y around inf
sub-divN/A
lower-*.f64N/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6461.0
Applied rewrites61.0%
Final simplification68.7%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -4.3e-25) (not (<= z 3.5e-79))) (* (- y x) (/ z (- a t))) (* y (/ (- t) (- a t)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -4.3e-25) || !(z <= 3.5e-79)) {
tmp = (y - x) * (z / (a - t));
} else {
tmp = y * (-t / (a - t));
}
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) :: tmp
if ((z <= (-4.3d-25)) .or. (.not. (z <= 3.5d-79))) then
tmp = (y - x) * (z / (a - t))
else
tmp = y * (-t / (a - t))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -4.3e-25) || !(z <= 3.5e-79)) {
tmp = (y - x) * (z / (a - t));
} else {
tmp = y * (-t / (a - t));
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (z <= -4.3e-25) or not (z <= 3.5e-79): tmp = (y - x) * (z / (a - t)) else: tmp = y * (-t / (a - t)) return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -4.3e-25) || !(z <= 3.5e-79)) tmp = Float64(Float64(y - x) * Float64(z / Float64(a - t))); else tmp = Float64(y * Float64(Float64(-t) / Float64(a - t))); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((z <= -4.3e-25) || ~((z <= 3.5e-79))) tmp = (y - x) * (z / (a - t)); else tmp = y * (-t / (a - t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -4.3e-25], N[Not[LessEqual[z, 3.5e-79]], $MachinePrecision]], N[(N[(y - x), $MachinePrecision] * N[(z / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * N[((-t) / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.3 \cdot 10^{-25} \lor \neg \left(z \leq 3.5 \cdot 10^{-79}\right):\\
\;\;\;\;\left(y - x\right) \cdot \frac{z}{a - t}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{-t}{a - t}\\
\end{array}
\end{array}
if z < -4.29999999999999976e-25 or 3.5000000000000003e-79 < z Initial program 67.7%
Taylor expanded in z around inf
sub-divN/A
associate-/l*N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64N/A
lift--.f6457.4
Applied rewrites57.4%
lift--.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6471.7
Applied rewrites71.7%
if -4.29999999999999976e-25 < z < 3.5000000000000003e-79Initial program 65.7%
lift-+.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
associate-/l*N/A
sub-divN/A
lower-fma.f64N/A
lift--.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6479.2
Applied rewrites79.2%
Taylor expanded in z around -inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64N/A
inv-powN/A
lower-pow.f64N/A
lift--.f6472.4
Applied rewrites72.4%
Taylor expanded in y around inf
sub-divN/A
lower-*.f64N/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6460.9
Applied rewrites60.9%
Taylor expanded in z around 0
mul-1-negN/A
lower-neg.f6456.1
Applied rewrites56.1%
Final simplification65.3%
(FPCore (x y z t a) :precision binary64 (if (or (<= a -2.25e-29) (not (<= a 6.5e-74))) (fma (- y x) (/ z a) x) (* y (/ (- z t) (- t)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((a <= -2.25e-29) || !(a <= 6.5e-74)) {
tmp = fma((y - x), (z / a), x);
} else {
tmp = y * ((z - t) / -t);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((a <= -2.25e-29) || !(a <= 6.5e-74)) tmp = fma(Float64(y - x), Float64(z / a), x); else tmp = Float64(y * Float64(Float64(z - t) / Float64(-t))); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[a, -2.25e-29], N[Not[LessEqual[a, 6.5e-74]], $MachinePrecision]], N[(N[(y - x), $MachinePrecision] * N[(z / a), $MachinePrecision] + x), $MachinePrecision], N[(y * N[(N[(z - t), $MachinePrecision] / (-t)), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.25 \cdot 10^{-29} \lor \neg \left(a \leq 6.5 \cdot 10^{-74}\right):\\
\;\;\;\;\mathsf{fma}\left(y - x, \frac{z}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{z - t}{-t}\\
\end{array}
\end{array}
if a < -2.2499999999999999e-29 or 6.5000000000000002e-74 < a Initial program 72.7%
lift-+.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
associate-/l*N/A
sub-divN/A
lower-fma.f64N/A
lift--.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6495.9
Applied rewrites95.9%
Taylor expanded in t around 0
lower-/.f6469.0
Applied rewrites69.0%
if -2.2499999999999999e-29 < a < 6.5000000000000002e-74Initial program 59.5%
lift-+.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
associate-/l*N/A
sub-divN/A
lower-fma.f64N/A
lift--.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6473.5
Applied rewrites73.5%
Taylor expanded in z around -inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64N/A
inv-powN/A
lower-pow.f64N/A
lift--.f6463.5
Applied rewrites63.5%
Taylor expanded in y around inf
sub-divN/A
lower-*.f64N/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6466.5
Applied rewrites66.5%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6458.8
Applied rewrites58.8%
Final simplification64.5%
(FPCore (x y z t a) :precision binary64 (if (or (<= t -4.4e+117) (not (<= t 4.5e+55))) (* y (/ (- t) (- a t))) (fma (- y x) (/ z a) x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((t <= -4.4e+117) || !(t <= 4.5e+55)) {
tmp = y * (-t / (a - t));
} else {
tmp = fma((y - x), (z / a), x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((t <= -4.4e+117) || !(t <= 4.5e+55)) tmp = Float64(y * Float64(Float64(-t) / Float64(a - t))); else tmp = fma(Float64(y - x), Float64(z / a), x); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[t, -4.4e+117], N[Not[LessEqual[t, 4.5e+55]], $MachinePrecision]], N[(y * N[((-t) / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y - x), $MachinePrecision] * N[(z / a), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -4.4 \cdot 10^{+117} \lor \neg \left(t \leq 4.5 \cdot 10^{+55}\right):\\
\;\;\;\;y \cdot \frac{-t}{a - t}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y - x, \frac{z}{a}, x\right)\\
\end{array}
\end{array}
if t < -4.40000000000000028e117 or 4.49999999999999998e55 < t Initial program 39.0%
lift-+.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
associate-/l*N/A
sub-divN/A
lower-fma.f64N/A
lift--.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6474.3
Applied rewrites74.3%
Taylor expanded in z around -inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64N/A
inv-powN/A
lower-pow.f64N/A
lift--.f6465.3
Applied rewrites65.3%
Taylor expanded in y around inf
sub-divN/A
lower-*.f64N/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6463.8
Applied rewrites63.8%
Taylor expanded in z around 0
mul-1-negN/A
lower-neg.f6455.1
Applied rewrites55.1%
if -4.40000000000000028e117 < t < 4.49999999999999998e55Initial program 84.5%
lift-+.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
associate-/l*N/A
sub-divN/A
lower-fma.f64N/A
lift--.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6493.4
Applied rewrites93.4%
Taylor expanded in t around 0
lower-/.f6464.3
Applied rewrites64.3%
Final simplification60.8%
(FPCore (x y z t a) :precision binary64 (if (or (<= a -2.55e-12) (not (<= a 2.7e-65))) (fma z (/ y a) x) (fma (/ (- y x) t) a y)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((a <= -2.55e-12) || !(a <= 2.7e-65)) {
tmp = fma(z, (y / a), x);
} else {
tmp = fma(((y - x) / t), a, y);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((a <= -2.55e-12) || !(a <= 2.7e-65)) tmp = fma(z, Float64(y / a), x); else tmp = fma(Float64(Float64(y - x) / t), a, y); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[a, -2.55e-12], N[Not[LessEqual[a, 2.7e-65]], $MachinePrecision]], N[(z * N[(y / a), $MachinePrecision] + x), $MachinePrecision], N[(N[(N[(y - x), $MachinePrecision] / t), $MachinePrecision] * a + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.55 \cdot 10^{-12} \lor \neg \left(a \leq 2.7 \cdot 10^{-65}\right):\\
\;\;\;\;\mathsf{fma}\left(z, \frac{y}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y - x}{t}, a, y\right)\\
\end{array}
\end{array}
if a < -2.54999999999999984e-12 or 2.6999999999999999e-65 < a Initial program 71.8%
Taylor expanded in t around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6467.2
Applied rewrites67.2%
Taylor expanded in x around 0
Applied rewrites55.3%
if -2.54999999999999984e-12 < a < 2.6999999999999999e-65Initial program 61.2%
Taylor expanded in t around inf
associate--l+N/A
associate-*r/N/A
associate-*r/N/A
sub-divN/A
distribute-lft-out--N/A
associate-*r/N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites76.9%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
sub-divN/A
*-commutativeN/A
lower-fma.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6442.0
Applied rewrites42.0%
Final simplification49.2%
(FPCore (x y z t a) :precision binary64 (if (<= t -1.1e+136) y (if (<= t 3.6e+120) (fma (- y x) (/ z a) x) (fma (/ (- y x) t) a y))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= -1.1e+136) {
tmp = y;
} else if (t <= 3.6e+120) {
tmp = fma((y - x), (z / a), x);
} else {
tmp = fma(((y - x) / t), a, y);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (t <= -1.1e+136) tmp = y; elseif (t <= 3.6e+120) tmp = fma(Float64(y - x), Float64(z / a), x); else tmp = fma(Float64(Float64(y - x) / t), a, y); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, -1.1e+136], y, If[LessEqual[t, 3.6e+120], N[(N[(y - x), $MachinePrecision] * N[(z / a), $MachinePrecision] + x), $MachinePrecision], N[(N[(N[(y - x), $MachinePrecision] / t), $MachinePrecision] * a + y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.1 \cdot 10^{+136}:\\
\;\;\;\;y\\
\mathbf{elif}\;t \leq 3.6 \cdot 10^{+120}:\\
\;\;\;\;\mathsf{fma}\left(y - x, \frac{z}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y - x}{t}, a, y\right)\\
\end{array}
\end{array}
if t < -1.1e136Initial program 24.8%
Taylor expanded in t around inf
Applied rewrites70.8%
if -1.1e136 < t < 3.60000000000000016e120Initial program 81.1%
lift-+.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
associate-/l*N/A
sub-divN/A
lower-fma.f64N/A
lift--.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6492.4
Applied rewrites92.4%
Taylor expanded in t around 0
lower-/.f6459.5
Applied rewrites59.5%
if 3.60000000000000016e120 < t Initial program 37.4%
Taylor expanded in t around inf
associate--l+N/A
associate-*r/N/A
associate-*r/N/A
sub-divN/A
distribute-lft-out--N/A
associate-*r/N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites60.3%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
sub-divN/A
*-commutativeN/A
lower-fma.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6447.2
Applied rewrites47.2%
Final simplification58.6%
(FPCore (x y z t a) :precision binary64 (if (<= t -1.1e+136) y (if (<= t 2.8e+120) (fma z (/ (- y x) a) x) (fma (/ (- y x) t) a y))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= -1.1e+136) {
tmp = y;
} else if (t <= 2.8e+120) {
tmp = fma(z, ((y - x) / a), x);
} else {
tmp = fma(((y - x) / t), a, y);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (t <= -1.1e+136) tmp = y; elseif (t <= 2.8e+120) tmp = fma(z, Float64(Float64(y - x) / a), x); else tmp = fma(Float64(Float64(y - x) / t), a, y); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, -1.1e+136], y, If[LessEqual[t, 2.8e+120], N[(z * N[(N[(y - x), $MachinePrecision] / a), $MachinePrecision] + x), $MachinePrecision], N[(N[(N[(y - x), $MachinePrecision] / t), $MachinePrecision] * a + y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.1 \cdot 10^{+136}:\\
\;\;\;\;y\\
\mathbf{elif}\;t \leq 2.8 \cdot 10^{+120}:\\
\;\;\;\;\mathsf{fma}\left(z, \frac{y - x}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y - x}{t}, a, y\right)\\
\end{array}
\end{array}
if t < -1.1e136Initial program 24.8%
Taylor expanded in t around inf
Applied rewrites70.8%
if -1.1e136 < t < 2.8000000000000001e120Initial program 81.1%
Taylor expanded in t around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6458.2
Applied rewrites58.2%
if 2.8000000000000001e120 < t Initial program 37.4%
Taylor expanded in t around inf
associate--l+N/A
associate-*r/N/A
associate-*r/N/A
sub-divN/A
distribute-lft-out--N/A
associate-*r/N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites60.3%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
sub-divN/A
*-commutativeN/A
lower-fma.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6447.2
Applied rewrites47.2%
Final simplification57.6%
(FPCore (x y z t a) :precision binary64 (if (<= t -1.8e+67) y (if (<= t 4.7e+55) (fma z (/ y a) x) y)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= -1.8e+67) {
tmp = y;
} else if (t <= 4.7e+55) {
tmp = fma(z, (y / a), x);
} else {
tmp = y;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (t <= -1.8e+67) tmp = y; elseif (t <= 4.7e+55) tmp = fma(z, Float64(y / a), x); else tmp = y; end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, -1.8e+67], y, If[LessEqual[t, 4.7e+55], N[(z * N[(y / a), $MachinePrecision] + x), $MachinePrecision], y]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.8 \cdot 10^{+67}:\\
\;\;\;\;y\\
\mathbf{elif}\;t \leq 4.7 \cdot 10^{+55}:\\
\;\;\;\;\mathsf{fma}\left(z, \frac{y}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if t < -1.7999999999999999e67 or 4.7000000000000001e55 < t Initial program 40.6%
Taylor expanded in t around inf
Applied rewrites46.6%
if -1.7999999999999999e67 < t < 4.7000000000000001e55Initial program 86.1%
Taylor expanded in t around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6463.8
Applied rewrites63.8%
Taylor expanded in x around 0
Applied rewrites49.0%
Final simplification48.0%
(FPCore (x y z t a) :precision binary64 (if (<= a -5e+98) x (if (<= a -1700000.0) (+ x y) (if (<= a 8e-9) y x))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -5e+98) {
tmp = x;
} else if (a <= -1700000.0) {
tmp = x + y;
} else if (a <= 8e-9) {
tmp = y;
} 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) :: tmp
if (a <= (-5d+98)) then
tmp = x
else if (a <= (-1700000.0d0)) then
tmp = x + y
else if (a <= 8d-9) then
tmp = y
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -5e+98) {
tmp = x;
} else if (a <= -1700000.0) {
tmp = x + y;
} else if (a <= 8e-9) {
tmp = y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if a <= -5e+98: tmp = x elif a <= -1700000.0: tmp = x + y elif a <= 8e-9: tmp = y else: tmp = x return tmp
function code(x, y, z, t, a) tmp = 0.0 if (a <= -5e+98) tmp = x; elseif (a <= -1700000.0) tmp = Float64(x + y); elseif (a <= 8e-9) tmp = y; else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (a <= -5e+98) tmp = x; elseif (a <= -1700000.0) tmp = x + y; elseif (a <= 8e-9) tmp = y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[a, -5e+98], x, If[LessEqual[a, -1700000.0], N[(x + y), $MachinePrecision], If[LessEqual[a, 8e-9], y, x]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -5 \cdot 10^{+98}:\\
\;\;\;\;x\\
\mathbf{elif}\;a \leq -1700000:\\
\;\;\;\;x + y\\
\mathbf{elif}\;a \leq 8 \cdot 10^{-9}:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if a < -4.9999999999999998e98 or 8.0000000000000005e-9 < a Initial program 68.0%
Taylor expanded in a around inf
Applied rewrites45.7%
if -4.9999999999999998e98 < a < -1.7e6Initial program 91.9%
Taylor expanded in t around inf
lift--.f6423.3
Applied rewrites23.3%
Taylor expanded in x around 0
Applied rewrites47.6%
if -1.7e6 < a < 8.0000000000000005e-9Initial program 61.6%
Taylor expanded in t around inf
Applied rewrites35.6%
Final simplification40.6%
(FPCore (x y z t a) :precision binary64 (if (<= a -24000000.0) x (if (<= a 8e-9) y x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -24000000.0) {
tmp = x;
} else if (a <= 8e-9) {
tmp = y;
} 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) :: tmp
if (a <= (-24000000.0d0)) then
tmp = x
else if (a <= 8d-9) then
tmp = y
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -24000000.0) {
tmp = x;
} else if (a <= 8e-9) {
tmp = y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if a <= -24000000.0: tmp = x elif a <= 8e-9: tmp = y else: tmp = x return tmp
function code(x, y, z, t, a) tmp = 0.0 if (a <= -24000000.0) tmp = x; elseif (a <= 8e-9) tmp = y; else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (a <= -24000000.0) tmp = x; elseif (a <= 8e-9) tmp = y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[a, -24000000.0], x, If[LessEqual[a, 8e-9], y, x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -24000000:\\
\;\;\;\;x\\
\mathbf{elif}\;a \leq 8 \cdot 10^{-9}:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if a < -2.4e7 or 8.0000000000000005e-9 < a Initial program 72.7%
Taylor expanded in a around inf
Applied rewrites42.1%
if -2.4e7 < a < 8.0000000000000005e-9Initial program 61.6%
Taylor expanded in t around inf
Applied rewrites35.6%
Final simplification38.7%
(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 66.9%
Taylor expanded in a around inf
Applied rewrites22.5%
Final simplification22.5%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (+ x (* (/ (- y x) 1.0) (/ (- z t) (- a t))))))
(if (< a -1.6153062845442575e-142)
t_1
(if (< a 3.774403170083174e-182) (- y (* (/ z t) (- y x))) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = x + (((y - x) / 1.0) * ((z - t) / (a - t)));
double tmp;
if (a < -1.6153062845442575e-142) {
tmp = t_1;
} else if (a < 3.774403170083174e-182) {
tmp = y - ((z / t) * (y - x));
} else {
tmp = t_1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, 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 = x + (((y - x) / 1.0d0) * ((z - t) / (a - t)))
if (a < (-1.6153062845442575d-142)) then
tmp = t_1
else if (a < 3.774403170083174d-182) then
tmp = y - ((z / t) * (y - x))
else
tmp = 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 = x + (((y - x) / 1.0) * ((z - t) / (a - t)));
double tmp;
if (a < -1.6153062845442575e-142) {
tmp = t_1;
} else if (a < 3.774403170083174e-182) {
tmp = y - ((z / t) * (y - x));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = x + (((y - x) / 1.0) * ((z - t) / (a - t))) tmp = 0 if a < -1.6153062845442575e-142: tmp = t_1 elif a < 3.774403170083174e-182: tmp = y - ((z / t) * (y - x)) else: tmp = t_1 return tmp
function code(x, y, z, t, a) t_1 = Float64(x + Float64(Float64(Float64(y - x) / 1.0) * Float64(Float64(z - t) / Float64(a - t)))) tmp = 0.0 if (a < -1.6153062845442575e-142) tmp = t_1; elseif (a < 3.774403170083174e-182) tmp = Float64(y - Float64(Float64(z / t) * Float64(y - x))); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = x + (((y - x) / 1.0) * ((z - t) / (a - t))); tmp = 0.0; if (a < -1.6153062845442575e-142) tmp = t_1; elseif (a < 3.774403170083174e-182) tmp = y - ((z / t) * (y - x)); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(x + N[(N[(N[(y - x), $MachinePrecision] / 1.0), $MachinePrecision] * N[(N[(z - t), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Less[a, -1.6153062845442575e-142], t$95$1, If[Less[a, 3.774403170083174e-182], N[(y - N[(N[(z / t), $MachinePrecision] * N[(y - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x + \frac{y - x}{1} \cdot \frac{z - t}{a - t}\\
\mathbf{if}\;a < -1.6153062845442575 \cdot 10^{-142}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a < 3.774403170083174 \cdot 10^{-182}:\\
\;\;\;\;y - \frac{z}{t} \cdot \left(y - x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
herbie shell --seed 2025043
(FPCore (x y z t a)
:name "Graphics.Rendering.Chart.Axis.Types:linMap from Chart-1.5.3"
:precision binary64
:alt
(! :herbie-platform default (if (< a -646122513817703/4000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (+ x (* (/ (- y x) 1) (/ (- z t) (- a t)))) (if (< a 1887201585041587/50000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (- y (* (/ z t) (- y x))) (+ x (* (/ (- y x) 1) (/ (- z t) (- a t)))))))
(+ x (/ (* (- y x) (- z t)) (- a t))))