
(FPCore (x y z t a) :precision binary64 (+ x (/ (* (- y z) (- t x)) (- a z))))
double code(double x, double y, double z, double t, double a) {
return x + (((y - z) * (t - x)) / (a - z));
}
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 - x)) / (a - z))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + (((y - z) * (t - x)) / (a - z));
}
def code(x, y, z, t, a): return x + (((y - z) * (t - x)) / (a - z))
function code(x, y, z, t, a) return Float64(x + Float64(Float64(Float64(y - z) * Float64(t - x)) / Float64(a - z))) end
function tmp = code(x, y, z, t, a) tmp = x + (((y - z) * (t - x)) / (a - z)); end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(N[(y - z), $MachinePrecision] * N[(t - x), $MachinePrecision]), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a) :precision binary64 (+ x (/ (* (- y z) (- t x)) (- a z))))
double code(double x, double y, double z, double t, double a) {
return x + (((y - z) * (t - x)) / (a - z));
}
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 - x)) / (a - z))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + (((y - z) * (t - x)) / (a - z));
}
def code(x, y, z, t, a): return x + (((y - z) * (t - x)) / (a - z))
function code(x, y, z, t, a) return Float64(x + Float64(Float64(Float64(y - z) * Float64(t - x)) / Float64(a - z))) end
function tmp = code(x, y, z, t, a) tmp = x + (((y - z) * (t - x)) / (a - z)); end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(N[(y - z), $MachinePrecision] * N[(t - x), $MachinePrecision]), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}
\end{array}
(FPCore (x y z t a)
:precision binary64
(if (or (<= t -4.1e-44) (not (<= t 6.5e+67)))
(fma (- y z) (/ (- t x) (- a z)) x)
(*
(- x)
(-
(fma (/ (/ (* (- y z) t) x) (- a z)) -1.0 (/ y (- a z)))
(- (/ z (- a z)) -1.0)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((t <= -4.1e-44) || !(t <= 6.5e+67)) {
tmp = fma((y - z), ((t - x) / (a - z)), x);
} else {
tmp = -x * (fma(((((y - z) * t) / x) / (a - z)), -1.0, (y / (a - z))) - ((z / (a - z)) - -1.0));
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((t <= -4.1e-44) || !(t <= 6.5e+67)) tmp = fma(Float64(y - z), Float64(Float64(t - x) / Float64(a - z)), x); else tmp = Float64(Float64(-x) * Float64(fma(Float64(Float64(Float64(Float64(y - z) * t) / x) / Float64(a - z)), -1.0, Float64(y / Float64(a - z))) - Float64(Float64(z / Float64(a - z)) - -1.0))); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[t, -4.1e-44], N[Not[LessEqual[t, 6.5e+67]], $MachinePrecision]], N[(N[(y - z), $MachinePrecision] * N[(N[(t - x), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[((-x) * N[(N[(N[(N[(N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision] / x), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision] * -1.0 + N[(y / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(z / N[(a - z), $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -4.1 \cdot 10^{-44} \lor \neg \left(t \leq 6.5 \cdot 10^{+67}\right):\\
\;\;\;\;\mathsf{fma}\left(y - z, \frac{t - x}{a - z}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(-x\right) \cdot \left(\mathsf{fma}\left(\frac{\frac{\left(y - z\right) \cdot t}{x}}{a - z}, -1, \frac{y}{a - z}\right) - \left(\frac{z}{a - z} - -1\right)\right)\\
\end{array}
\end{array}
if t < -4.09999999999999992e-44 or 6.4999999999999995e67 < t Initial program 63.6%
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--.f6487.7
Applied rewrites87.7%
if -4.09999999999999992e-44 < t < 6.4999999999999995e67Initial program 66.4%
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 rewrites87.7%
Final simplification87.7%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (* t (/ (- y z) (- a z)))) (t_2 (fma (- t x) (/ (- y z) a) x)))
(if (<= a -6e+37)
t_2
(if (<= a -1.95e-61)
t_1
(if (<= a -1.2e-285)
(* y (/ (- t x) (- a z)))
(if (<= a 1.08e+86) t_1 t_2))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = t * ((y - z) / (a - z));
double t_2 = fma((t - x), ((y - z) / a), x);
double tmp;
if (a <= -6e+37) {
tmp = t_2;
} else if (a <= -1.95e-61) {
tmp = t_1;
} else if (a <= -1.2e-285) {
tmp = y * ((t - x) / (a - z));
} else if (a <= 1.08e+86) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(t * Float64(Float64(y - z) / Float64(a - z))) t_2 = fma(Float64(t - x), Float64(Float64(y - z) / a), x) tmp = 0.0 if (a <= -6e+37) tmp = t_2; elseif (a <= -1.95e-61) tmp = t_1; elseif (a <= -1.2e-285) tmp = Float64(y * Float64(Float64(t - x) / Float64(a - z))); elseif (a <= 1.08e+86) tmp = t_1; else tmp = t_2; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(t * N[(N[(y - z), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(t - x), $MachinePrecision] * N[(N[(y - z), $MachinePrecision] / a), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[a, -6e+37], t$95$2, If[LessEqual[a, -1.95e-61], t$95$1, If[LessEqual[a, -1.2e-285], N[(y * N[(N[(t - x), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 1.08e+86], t$95$1, t$95$2]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := t \cdot \frac{y - z}{a - z}\\
t_2 := \mathsf{fma}\left(t - x, \frac{y - z}{a}, x\right)\\
\mathbf{if}\;a \leq -6 \cdot 10^{+37}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;a \leq -1.95 \cdot 10^{-61}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \leq -1.2 \cdot 10^{-285}:\\
\;\;\;\;y \cdot \frac{t - x}{a - z}\\
\mathbf{elif}\;a \leq 1.08 \cdot 10^{+86}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if a < -6.00000000000000043e37 or 1.07999999999999993e86 < a Initial program 65.8%
Taylor expanded in a around inf
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6490.4
Applied rewrites90.4%
if -6.00000000000000043e37 < a < -1.95000000000000016e-61 or -1.2e-285 < a < 1.07999999999999993e86Initial program 63.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--.f6470.5
Applied rewrites70.5%
Taylor expanded in t around inf
lower-*.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6468.0
Applied rewrites68.0%
if -1.95000000000000016e-61 < a < -1.2e-285Initial program 67.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--.f6474.6
Applied rewrites74.6%
Taylor expanded in y around inf
sub-divN/A
lower-*.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift--.f6461.3
Applied rewrites61.3%
Final simplification74.9%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (* t (/ (- y z) (- a z)))) (t_2 (fma y (/ (- t x) a) x)))
(if (<= a -1.6e+45)
t_2
(if (<= a -1.95e-61)
t_1
(if (<= a -1.2e-285)
(* y (/ (- t x) (- a z)))
(if (<= a 3e+86) t_1 t_2))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = t * ((y - z) / (a - z));
double t_2 = fma(y, ((t - x) / a), x);
double tmp;
if (a <= -1.6e+45) {
tmp = t_2;
} else if (a <= -1.95e-61) {
tmp = t_1;
} else if (a <= -1.2e-285) {
tmp = y * ((t - x) / (a - z));
} else if (a <= 3e+86) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(t * Float64(Float64(y - z) / Float64(a - z))) t_2 = fma(y, Float64(Float64(t - x) / a), x) tmp = 0.0 if (a <= -1.6e+45) tmp = t_2; elseif (a <= -1.95e-61) tmp = t_1; elseif (a <= -1.2e-285) tmp = Float64(y * Float64(Float64(t - x) / Float64(a - z))); elseif (a <= 3e+86) tmp = t_1; else tmp = t_2; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(t * N[(N[(y - z), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(y * N[(N[(t - x), $MachinePrecision] / a), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[a, -1.6e+45], t$95$2, If[LessEqual[a, -1.95e-61], t$95$1, If[LessEqual[a, -1.2e-285], N[(y * N[(N[(t - x), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 3e+86], t$95$1, t$95$2]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := t \cdot \frac{y - z}{a - z}\\
t_2 := \mathsf{fma}\left(y, \frac{t - x}{a}, x\right)\\
\mathbf{if}\;a \leq -1.6 \cdot 10^{+45}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;a \leq -1.95 \cdot 10^{-61}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \leq -1.2 \cdot 10^{-285}:\\
\;\;\;\;y \cdot \frac{t - x}{a - z}\\
\mathbf{elif}\;a \leq 3 \cdot 10^{+86}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if a < -1.6000000000000001e45 or 2.99999999999999977e86 < a Initial program 65.8%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6481.5
Applied rewrites81.5%
if -1.6000000000000001e45 < a < -1.95000000000000016e-61 or -1.2e-285 < a < 2.99999999999999977e86Initial program 63.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--.f6470.5
Applied rewrites70.5%
Taylor expanded in t around inf
lower-*.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6468.0
Applied rewrites68.0%
if -1.95000000000000016e-61 < a < -1.2e-285Initial program 67.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--.f6474.6
Applied rewrites74.6%
Taylor expanded in y around inf
sub-divN/A
lower-*.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift--.f6461.3
Applied rewrites61.3%
Final simplification71.6%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -2.1e+147) (not (<= z 2.2e+125))) (fma (fma -1.0 y a) (/ (- t x) z) t) (fma (- y z) (/ (- t x) (- a z)) x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -2.1e+147) || !(z <= 2.2e+125)) {
tmp = fma(fma(-1.0, y, a), ((t - x) / z), t);
} else {
tmp = fma((y - z), ((t - x) / (a - z)), x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -2.1e+147) || !(z <= 2.2e+125)) tmp = fma(fma(-1.0, y, a), Float64(Float64(t - x) / z), t); else tmp = fma(Float64(y - z), Float64(Float64(t - x) / Float64(a - z)), x); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -2.1e+147], N[Not[LessEqual[z, 2.2e+125]], $MachinePrecision]], N[(N[(-1.0 * y + a), $MachinePrecision] * N[(N[(t - x), $MachinePrecision] / z), $MachinePrecision] + t), $MachinePrecision], N[(N[(y - z), $MachinePrecision] * N[(N[(t - x), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.1 \cdot 10^{+147} \lor \neg \left(z \leq 2.2 \cdot 10^{+125}\right):\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-1, y, a\right), \frac{t - x}{z}, t\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y - z, \frac{t - x}{a - z}, x\right)\\
\end{array}
\end{array}
if z < -2.10000000000000006e147 or 2.19999999999999991e125 < z Initial program 24.2%
lift--.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
associate-/l*N/A
flip--N/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
lower--.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lift--.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lift--.f642.1
Applied rewrites2.1%
Taylor expanded in z around inf
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
mul-1-negN/A
+-commutativeN/A
mul-1-negN/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6486.6
Applied rewrites86.6%
if -2.10000000000000006e147 < z < 2.19999999999999991e125Initial program 78.6%
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--.f6487.7
Applied rewrites87.7%
Final simplification87.4%
(FPCore (x y z t a) :precision binary64 (if (or (<= a -1.2e+38) (not (<= a 60000.0))) (fma (- t x) (/ (- y z) a) x) (fma (fma -1.0 y a) (/ (- t x) z) t)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((a <= -1.2e+38) || !(a <= 60000.0)) {
tmp = fma((t - x), ((y - z) / a), x);
} else {
tmp = fma(fma(-1.0, y, a), ((t - x) / z), t);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((a <= -1.2e+38) || !(a <= 60000.0)) tmp = fma(Float64(t - x), Float64(Float64(y - z) / a), x); else tmp = fma(fma(-1.0, y, a), Float64(Float64(t - x) / z), t); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[a, -1.2e+38], N[Not[LessEqual[a, 60000.0]], $MachinePrecision]], N[(N[(t - x), $MachinePrecision] * N[(N[(y - z), $MachinePrecision] / a), $MachinePrecision] + x), $MachinePrecision], N[(N[(-1.0 * y + a), $MachinePrecision] * N[(N[(t - x), $MachinePrecision] / z), $MachinePrecision] + t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.2 \cdot 10^{+38} \lor \neg \left(a \leq 60000\right):\\
\;\;\;\;\mathsf{fma}\left(t - x, \frac{y - z}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-1, y, a\right), \frac{t - x}{z}, t\right)\\
\end{array}
\end{array}
if a < -1.20000000000000009e38 or 6e4 < a Initial program 66.3%
Taylor expanded in a around inf
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6485.0
Applied rewrites85.0%
if -1.20000000000000009e38 < a < 6e4Initial program 64.0%
lift--.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
associate-/l*N/A
flip--N/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
lower--.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lift--.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lift--.f6447.5
Applied rewrites47.5%
Taylor expanded in z around inf
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
mul-1-negN/A
+-commutativeN/A
mul-1-negN/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6475.6
Applied rewrites75.6%
Final simplification79.7%
(FPCore (x y z t a) :precision binary64 (if (or (<= a -1.6e+45) (not (<= a 3e+86))) (fma y (/ (- t x) a) x) (* t (/ (- y z) (- a z)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((a <= -1.6e+45) || !(a <= 3e+86)) {
tmp = fma(y, ((t - x) / a), x);
} else {
tmp = t * ((y - z) / (a - z));
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((a <= -1.6e+45) || !(a <= 3e+86)) tmp = fma(y, Float64(Float64(t - x) / a), x); else tmp = Float64(t * Float64(Float64(y - z) / Float64(a - z))); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[a, -1.6e+45], N[Not[LessEqual[a, 3e+86]], $MachinePrecision]], N[(y * N[(N[(t - x), $MachinePrecision] / a), $MachinePrecision] + x), $MachinePrecision], N[(t * N[(N[(y - z), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.6 \cdot 10^{+45} \lor \neg \left(a \leq 3 \cdot 10^{+86}\right):\\
\;\;\;\;\mathsf{fma}\left(y, \frac{t - x}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;t \cdot \frac{y - z}{a - z}\\
\end{array}
\end{array}
if a < -1.6000000000000001e45 or 2.99999999999999977e86 < a Initial program 65.8%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6481.5
Applied rewrites81.5%
if -1.6000000000000001e45 < a < 2.99999999999999977e86Initial program 64.6%
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--.f6471.9
Applied rewrites71.9%
Taylor expanded in t around inf
lower-*.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6460.5
Applied rewrites60.5%
Final simplification68.3%
(FPCore (x y z t a) :precision binary64 (if (or (<= a -1.15e-5) (not (<= a 2.5e-32))) (fma y (/ (- t x) a) x) (/ (* (- t x) y) (- a z))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((a <= -1.15e-5) || !(a <= 2.5e-32)) {
tmp = fma(y, ((t - x) / a), x);
} else {
tmp = ((t - x) * y) / (a - z);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((a <= -1.15e-5) || !(a <= 2.5e-32)) tmp = fma(y, Float64(Float64(t - x) / a), x); else tmp = Float64(Float64(Float64(t - x) * y) / Float64(a - z)); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[a, -1.15e-5], N[Not[LessEqual[a, 2.5e-32]], $MachinePrecision]], N[(y * N[(N[(t - x), $MachinePrecision] / a), $MachinePrecision] + x), $MachinePrecision], N[(N[(N[(t - x), $MachinePrecision] * y), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.15 \cdot 10^{-5} \lor \neg \left(a \leq 2.5 \cdot 10^{-32}\right):\\
\;\;\;\;\mathsf{fma}\left(y, \frac{t - x}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(t - x\right) \cdot y}{a - z}\\
\end{array}
\end{array}
if a < -1.15e-5 or 2.5e-32 < a Initial program 65.3%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6473.7
Applied rewrites73.7%
if -1.15e-5 < a < 2.5e-32Initial program 64.7%
Taylor expanded in y around inf
sub-divN/A
associate-/l*N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64N/A
lift--.f6454.8
Applied rewrites54.8%
Final simplification64.3%
(FPCore (x y z t a) :precision binary64 (if (<= z -3.5e+91) t (if (<= z 2.5e+61) (fma y (/ (- t x) a) x) t)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -3.5e+91) {
tmp = t;
} else if (z <= 2.5e+61) {
tmp = fma(y, ((t - x) / a), x);
} else {
tmp = t;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -3.5e+91) tmp = t; elseif (z <= 2.5e+61) tmp = fma(y, Float64(Float64(t - x) / a), x); else tmp = t; end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -3.5e+91], t, If[LessEqual[z, 2.5e+61], N[(y * N[(N[(t - x), $MachinePrecision] / a), $MachinePrecision] + x), $MachinePrecision], t]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.5 \cdot 10^{+91}:\\
\;\;\;\;t\\
\mathbf{elif}\;z \leq 2.5 \cdot 10^{+61}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{t - x}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\\
\end{array}
\end{array}
if z < -3.50000000000000001e91 or 2.50000000000000009e61 < z Initial program 33.3%
Taylor expanded in z around inf
Applied rewrites48.8%
if -3.50000000000000001e91 < z < 2.50000000000000009e61Initial program 82.2%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6466.9
Applied rewrites66.9%
Final simplification60.5%
(FPCore (x y z t a) :precision binary64 (if (<= z -3.1e+91) t (if (<= z 1.6e+61) (fma y (/ t a) x) t)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -3.1e+91) {
tmp = t;
} else if (z <= 1.6e+61) {
tmp = fma(y, (t / a), x);
} else {
tmp = t;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -3.1e+91) tmp = t; elseif (z <= 1.6e+61) tmp = fma(y, Float64(t / a), x); else tmp = t; end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -3.1e+91], t, If[LessEqual[z, 1.6e+61], N[(y * N[(t / a), $MachinePrecision] + x), $MachinePrecision], t]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.1 \cdot 10^{+91}:\\
\;\;\;\;t\\
\mathbf{elif}\;z \leq 1.6 \cdot 10^{+61}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{t}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\\
\end{array}
\end{array}
if z < -3.09999999999999998e91 or 1.5999999999999999e61 < z Initial program 33.3%
Taylor expanded in z around inf
Applied rewrites48.8%
if -3.09999999999999998e91 < z < 1.5999999999999999e61Initial program 82.2%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6466.9
Applied rewrites66.9%
Taylor expanded in x around 0
Applied rewrites59.2%
Final simplification55.5%
(FPCore (x y z t a) :precision binary64 (if (<= a -1.06e+33) x (if (<= a -1.2e-285) (* x (/ y z)) (if (<= a 1.08e+86) t x))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -1.06e+33) {
tmp = x;
} else if (a <= -1.2e-285) {
tmp = x * (y / z);
} else if (a <= 1.08e+86) {
tmp = t;
} 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 <= (-1.06d+33)) then
tmp = x
else if (a <= (-1.2d-285)) then
tmp = x * (y / z)
else if (a <= 1.08d+86) then
tmp = t
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 <= -1.06e+33) {
tmp = x;
} else if (a <= -1.2e-285) {
tmp = x * (y / z);
} else if (a <= 1.08e+86) {
tmp = t;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if a <= -1.06e+33: tmp = x elif a <= -1.2e-285: tmp = x * (y / z) elif a <= 1.08e+86: tmp = t else: tmp = x return tmp
function code(x, y, z, t, a) tmp = 0.0 if (a <= -1.06e+33) tmp = x; elseif (a <= -1.2e-285) tmp = Float64(x * Float64(y / z)); elseif (a <= 1.08e+86) tmp = t; else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (a <= -1.06e+33) tmp = x; elseif (a <= -1.2e-285) tmp = x * (y / z); elseif (a <= 1.08e+86) tmp = t; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[a, -1.06e+33], x, If[LessEqual[a, -1.2e-285], N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 1.08e+86], t, x]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.06 \cdot 10^{+33}:\\
\;\;\;\;x\\
\mathbf{elif}\;a \leq -1.2 \cdot 10^{-285}:\\
\;\;\;\;x \cdot \frac{y}{z}\\
\mathbf{elif}\;a \leq 1.08 \cdot 10^{+86}:\\
\;\;\;\;t\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if a < -1.06e33 or 1.07999999999999993e86 < a Initial program 64.5%
Taylor expanded in a around inf
Applied rewrites58.3%
if -1.06e33 < a < -1.2e-285Initial program 67.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--.f6477.0
Applied rewrites77.0%
Taylor expanded in x around inf
lower-*.f64N/A
lower-+.f64N/A
sub-divN/A
mul-1-negN/A
lower-neg.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6439.4
Applied rewrites39.4%
Taylor expanded in a around 0
lower-/.f6434.9
Applied rewrites34.9%
if -1.2e-285 < a < 1.07999999999999993e86Initial program 63.5%
Taylor expanded in z around inf
Applied rewrites39.4%
Final simplification45.2%
(FPCore (x y z t a) :precision binary64 (if (<= a -2.9e+52) x (if (<= a -1.8e-98) (* t (/ y a)) (if (<= a 1.08e+86) t x))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -2.9e+52) {
tmp = x;
} else if (a <= -1.8e-98) {
tmp = t * (y / a);
} else if (a <= 1.08e+86) {
tmp = t;
} 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 <= (-2.9d+52)) then
tmp = x
else if (a <= (-1.8d-98)) then
tmp = t * (y / a)
else if (a <= 1.08d+86) then
tmp = t
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 <= -2.9e+52) {
tmp = x;
} else if (a <= -1.8e-98) {
tmp = t * (y / a);
} else if (a <= 1.08e+86) {
tmp = t;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if a <= -2.9e+52: tmp = x elif a <= -1.8e-98: tmp = t * (y / a) elif a <= 1.08e+86: tmp = t else: tmp = x return tmp
function code(x, y, z, t, a) tmp = 0.0 if (a <= -2.9e+52) tmp = x; elseif (a <= -1.8e-98) tmp = Float64(t * Float64(y / a)); elseif (a <= 1.08e+86) tmp = t; else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (a <= -2.9e+52) tmp = x; elseif (a <= -1.8e-98) tmp = t * (y / a); elseif (a <= 1.08e+86) tmp = t; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[a, -2.9e+52], x, If[LessEqual[a, -1.8e-98], N[(t * N[(y / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 1.08e+86], t, x]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.9 \cdot 10^{+52}:\\
\;\;\;\;x\\
\mathbf{elif}\;a \leq -1.8 \cdot 10^{-98}:\\
\;\;\;\;t \cdot \frac{y}{a}\\
\mathbf{elif}\;a \leq 1.08 \cdot 10^{+86}:\\
\;\;\;\;t\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if a < -2.9e52 or 1.07999999999999993e86 < a Initial program 65.8%
Taylor expanded in a around inf
Applied rewrites59.5%
if -2.9e52 < a < -1.8000000000000001e-98Initial program 67.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--.f6477.9
Applied rewrites77.9%
Taylor expanded in y around inf
sub-divN/A
lower-*.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift--.f6458.6
Applied rewrites58.6%
Taylor expanded in x around 0
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift--.f6439.8
Applied rewrites39.8%
Taylor expanded in z around 0
lower-/.f6430.5
Applied rewrites30.5%
if -1.8000000000000001e-98 < a < 1.07999999999999993e86Initial program 63.8%
Taylor expanded in z around inf
Applied rewrites35.8%
Final simplification43.9%
(FPCore (x y z t a) :precision binary64 (if (<= a -6e+44) x (if (<= a -1.8e-98) (/ (* t y) a) (if (<= a 1.08e+86) t x))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -6e+44) {
tmp = x;
} else if (a <= -1.8e-98) {
tmp = (t * y) / a;
} else if (a <= 1.08e+86) {
tmp = t;
} 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 <= (-6d+44)) then
tmp = x
else if (a <= (-1.8d-98)) then
tmp = (t * y) / a
else if (a <= 1.08d+86) then
tmp = t
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 <= -6e+44) {
tmp = x;
} else if (a <= -1.8e-98) {
tmp = (t * y) / a;
} else if (a <= 1.08e+86) {
tmp = t;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if a <= -6e+44: tmp = x elif a <= -1.8e-98: tmp = (t * y) / a elif a <= 1.08e+86: tmp = t else: tmp = x return tmp
function code(x, y, z, t, a) tmp = 0.0 if (a <= -6e+44) tmp = x; elseif (a <= -1.8e-98) tmp = Float64(Float64(t * y) / a); elseif (a <= 1.08e+86) tmp = t; else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (a <= -6e+44) tmp = x; elseif (a <= -1.8e-98) tmp = (t * y) / a; elseif (a <= 1.08e+86) tmp = t; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[a, -6e+44], x, If[LessEqual[a, -1.8e-98], N[(N[(t * y), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[a, 1.08e+86], t, x]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -6 \cdot 10^{+44}:\\
\;\;\;\;x\\
\mathbf{elif}\;a \leq -1.8 \cdot 10^{-98}:\\
\;\;\;\;\frac{t \cdot y}{a}\\
\mathbf{elif}\;a \leq 1.08 \cdot 10^{+86}:\\
\;\;\;\;t\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if a < -5.99999999999999974e44 or 1.07999999999999993e86 < a Initial program 65.8%
Taylor expanded in a around inf
Applied rewrites59.5%
if -5.99999999999999974e44 < a < -1.8000000000000001e-98Initial program 67.7%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6448.7
Applied rewrites48.7%
Taylor expanded in x around 0
lower-/.f64N/A
lower-*.f6430.5
Applied rewrites30.5%
if -1.8000000000000001e-98 < a < 1.07999999999999993e86Initial program 63.8%
Taylor expanded in z around inf
Applied rewrites35.8%
Final simplification43.9%
(FPCore (x y z t a) :precision binary64 (if (<= a -2.6e+52) x (if (<= a 1.08e+86) t x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -2.6e+52) {
tmp = x;
} else if (a <= 1.08e+86) {
tmp = t;
} 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 <= (-2.6d+52)) then
tmp = x
else if (a <= 1.08d+86) then
tmp = t
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 <= -2.6e+52) {
tmp = x;
} else if (a <= 1.08e+86) {
tmp = t;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if a <= -2.6e+52: tmp = x elif a <= 1.08e+86: tmp = t else: tmp = x return tmp
function code(x, y, z, t, a) tmp = 0.0 if (a <= -2.6e+52) tmp = x; elseif (a <= 1.08e+86) tmp = t; else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (a <= -2.6e+52) tmp = x; elseif (a <= 1.08e+86) tmp = t; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[a, -2.6e+52], x, If[LessEqual[a, 1.08e+86], t, x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.6 \cdot 10^{+52}:\\
\;\;\;\;x\\
\mathbf{elif}\;a \leq 1.08 \cdot 10^{+86}:\\
\;\;\;\;t\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if a < -2.6e52 or 1.07999999999999993e86 < a Initial program 65.8%
Taylor expanded in a around inf
Applied rewrites59.5%
if -2.6e52 < a < 1.07999999999999993e86Initial program 64.6%
Taylor expanded in z around inf
Applied rewrites32.2%
Final simplification42.3%
(FPCore (x y z t a) :precision binary64 t)
double code(double x, double y, double z, double t, double a) {
return 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 = t
end function
public static double code(double x, double y, double z, double t, double a) {
return t;
}
def code(x, y, z, t, a): return t
function code(x, y, z, t, a) return t end
function tmp = code(x, y, z, t, a) tmp = t; end
code[x_, y_, z_, t_, a_] := t
\begin{array}{l}
\\
t
\end{array}
Initial program 65.0%
Taylor expanded in z around inf
Applied rewrites23.3%
Final simplification23.3%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (- t (* (/ y z) (- t x)))))
(if (< z -1.2536131056095036e+188)
t_1
(if (< z 4.446702369113811e+64)
(+ x (/ (- y z) (/ (- a z) (- t x))))
t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = t - ((y / z) * (t - x));
double tmp;
if (z < -1.2536131056095036e+188) {
tmp = t_1;
} else if (z < 4.446702369113811e+64) {
tmp = x + ((y - z) / ((a - z) / (t - 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 = t - ((y / z) * (t - x))
if (z < (-1.2536131056095036d+188)) then
tmp = t_1
else if (z < 4.446702369113811d+64) then
tmp = x + ((y - z) / ((a - z) / (t - 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 = t - ((y / z) * (t - x));
double tmp;
if (z < -1.2536131056095036e+188) {
tmp = t_1;
} else if (z < 4.446702369113811e+64) {
tmp = x + ((y - z) / ((a - z) / (t - x)));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = t - ((y / z) * (t - x)) tmp = 0 if z < -1.2536131056095036e+188: tmp = t_1 elif z < 4.446702369113811e+64: tmp = x + ((y - z) / ((a - z) / (t - x))) else: tmp = t_1 return tmp
function code(x, y, z, t, a) t_1 = Float64(t - Float64(Float64(y / z) * Float64(t - x))) tmp = 0.0 if (z < -1.2536131056095036e+188) tmp = t_1; elseif (z < 4.446702369113811e+64) tmp = Float64(x + Float64(Float64(y - z) / Float64(Float64(a - z) / Float64(t - x)))); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = t - ((y / z) * (t - x)); tmp = 0.0; if (z < -1.2536131056095036e+188) tmp = t_1; elseif (z < 4.446702369113811e+64) tmp = x + ((y - z) / ((a - z) / (t - x))); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(t - N[(N[(y / z), $MachinePrecision] * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Less[z, -1.2536131056095036e+188], t$95$1, If[Less[z, 4.446702369113811e+64], N[(x + N[(N[(y - z), $MachinePrecision] / N[(N[(a - z), $MachinePrecision] / N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := t - \frac{y}{z} \cdot \left(t - x\right)\\
\mathbf{if}\;z < -1.2536131056095036 \cdot 10^{+188}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z < 4.446702369113811 \cdot 10^{+64}:\\
\;\;\;\;x + \frac{y - z}{\frac{a - z}{t - x}}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
herbie shell --seed 2025064
(FPCore (x y z t a)
:name "Graphics.Rendering.Chart.Axis.Types:invLinMap from Chart-1.5.3"
:precision binary64
:alt
(! :herbie-platform default (if (< z -125361310560950360000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (- t (* (/ y z) (- t x))) (if (< z 44467023691138110000000000000000000000000000000000000000000000000) (+ x (/ (- y z) (/ (- a z) (- t x)))) (- t (* (/ y z) (- t x))))))
(+ x (/ (* (- y z) (- t x)) (- a z))))