
(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 (<= z -1.4e+170) (not (<= z 9e+152))) (fma -1.0 (* (- t x) (/ (- y a) 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 <= -1.4e+170) || !(z <= 9e+152)) {
tmp = fma(-1.0, ((t - x) * ((y - a) / 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 <= -1.4e+170) || !(z <= 9e+152)) tmp = fma(-1.0, Float64(Float64(t - x) * Float64(Float64(y - a) / 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, -1.4e+170], N[Not[LessEqual[z, 9e+152]], $MachinePrecision]], N[(-1.0 * N[(N[(t - x), $MachinePrecision] * N[(N[(y - a), $MachinePrecision] / z), $MachinePrecision]), $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 -1.4 \cdot 10^{+170} \lor \neg \left(z \leq 9 \cdot 10^{+152}\right):\\
\;\;\;\;\mathsf{fma}\left(-1, \left(t - x\right) \cdot \frac{y - a}{z}, t\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y - z, \frac{t - x}{a - z}, x\right)\\
\end{array}
\end{array}
if z < -1.40000000000000008e170 or 9.0000000000000002e152 < z Initial program 28.8%
lift-+.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
associate-/l*N/A
sub-divN/A
lower-*.f64N/A
lift--.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6443.4
Applied rewrites43.4%
Taylor expanded in z around -inf
+-commutativeN/A
associate-*r/N/A
+-commutativeN/A
distribute-rgt-out--N/A
lower-fma.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift--.f6493.2
Applied rewrites93.2%
if -1.40000000000000008e170 < z < 9.0000000000000002e152Initial program 82.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--.f6489.8
Applied rewrites89.8%
Final simplification90.7%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma (- y z) (/ t (- a z)) x))
(t_2 (/ (- t x) z))
(t_3 (fma t_2 a t)))
(if (<= z -1.65e+170)
t_3
(if (<= z -5e-150)
t_1
(if (<= z 5.8e-109)
(fma (- t x) (/ (- y z) a) x)
(if (<= z 2.9e+175) t_1 (if (<= z 1.42e+237) (* (- y) t_2) t_3)))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma((y - z), (t / (a - z)), x);
double t_2 = (t - x) / z;
double t_3 = fma(t_2, a, t);
double tmp;
if (z <= -1.65e+170) {
tmp = t_3;
} else if (z <= -5e-150) {
tmp = t_1;
} else if (z <= 5.8e-109) {
tmp = fma((t - x), ((y - z) / a), x);
} else if (z <= 2.9e+175) {
tmp = t_1;
} else if (z <= 1.42e+237) {
tmp = -y * t_2;
} else {
tmp = t_3;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(y - z), Float64(t / Float64(a - z)), x) t_2 = Float64(Float64(t - x) / z) t_3 = fma(t_2, a, t) tmp = 0.0 if (z <= -1.65e+170) tmp = t_3; elseif (z <= -5e-150) tmp = t_1; elseif (z <= 5.8e-109) tmp = fma(Float64(t - x), Float64(Float64(y - z) / a), x); elseif (z <= 2.9e+175) tmp = t_1; elseif (z <= 1.42e+237) tmp = Float64(Float64(-y) * t_2); else tmp = t_3; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(y - z), $MachinePrecision] * N[(t / N[(a - z), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]}, Block[{t$95$2 = N[(N[(t - x), $MachinePrecision] / z), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 * a + t), $MachinePrecision]}, If[LessEqual[z, -1.65e+170], t$95$3, If[LessEqual[z, -5e-150], t$95$1, If[LessEqual[z, 5.8e-109], N[(N[(t - x), $MachinePrecision] * N[(N[(y - z), $MachinePrecision] / a), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[z, 2.9e+175], t$95$1, If[LessEqual[z, 1.42e+237], N[((-y) * t$95$2), $MachinePrecision], t$95$3]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(y - z, \frac{t}{a - z}, x\right)\\
t_2 := \frac{t - x}{z}\\
t_3 := \mathsf{fma}\left(t\_2, a, t\right)\\
\mathbf{if}\;z \leq -1.65 \cdot 10^{+170}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;z \leq -5 \cdot 10^{-150}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 5.8 \cdot 10^{-109}:\\
\;\;\;\;\mathsf{fma}\left(t - x, \frac{y - z}{a}, x\right)\\
\mathbf{elif}\;z \leq 2.9 \cdot 10^{+175}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 1.42 \cdot 10^{+237}:\\
\;\;\;\;\left(-y\right) \cdot t\_2\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\end{array}
\end{array}
if z < -1.65000000000000012e170 or 1.42000000000000004e237 < z Initial program 26.7%
Taylor expanded in z 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.6%
Taylor expanded in x around inf
lower-*.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6432.8
Applied rewrites32.8%
Taylor expanded in y around 0
+-commutativeN/A
associate-/l*N/A
sub-divN/A
*-commutativeN/A
lower-fma.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6473.4
Applied rewrites73.4%
if -1.65000000000000012e170 < z < -4.9999999999999999e-150 or 5.8e-109 < z < 2.9e175Initial program 76.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--.f6488.7
Applied rewrites88.7%
Taylor expanded in x around 0
Applied rewrites76.8%
if -4.9999999999999999e-150 < z < 5.8e-109Initial program 92.8%
Taylor expanded in a around inf
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6495.1
Applied rewrites95.1%
if 2.9e175 < z < 1.42000000000000004e237Initial program 26.1%
Taylor expanded in z 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 rewrites56.1%
Taylor expanded in x around inf
lower-*.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6455.1
Applied rewrites55.1%
Taylor expanded in y around inf
associate-/l*N/A
sub-divN/A
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6470.9
Applied rewrites70.9%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (/ (- t x) z)) (t_2 (fma t_1 a t)))
(if (<= z -5e+82)
t_2
(if (<= z 3.6e+81)
(fma y (/ (- t x) a) x)
(if (<= z 2.9e+175)
(* t (/ (- z) (- a z)))
(if (<= z 1.42e+237) (* (- y) t_1) t_2))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (t - x) / z;
double t_2 = fma(t_1, a, t);
double tmp;
if (z <= -5e+82) {
tmp = t_2;
} else if (z <= 3.6e+81) {
tmp = fma(y, ((t - x) / a), x);
} else if (z <= 2.9e+175) {
tmp = t * (-z / (a - z));
} else if (z <= 1.42e+237) {
tmp = -y * t_1;
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(Float64(t - x) / z) t_2 = fma(t_1, a, t) tmp = 0.0 if (z <= -5e+82) tmp = t_2; elseif (z <= 3.6e+81) tmp = fma(y, Float64(Float64(t - x) / a), x); elseif (z <= 2.9e+175) tmp = Float64(t * Float64(Float64(-z) / Float64(a - z))); elseif (z <= 1.42e+237) tmp = Float64(Float64(-y) * t_1); else tmp = t_2; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(t - x), $MachinePrecision] / z), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * a + t), $MachinePrecision]}, If[LessEqual[z, -5e+82], t$95$2, If[LessEqual[z, 3.6e+81], N[(y * N[(N[(t - x), $MachinePrecision] / a), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[z, 2.9e+175], N[(t * N[((-z) / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.42e+237], N[((-y) * t$95$1), $MachinePrecision], t$95$2]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{t - x}{z}\\
t_2 := \mathsf{fma}\left(t\_1, a, t\right)\\
\mathbf{if}\;z \leq -5 \cdot 10^{+82}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;z \leq 3.6 \cdot 10^{+81}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{t - x}{a}, x\right)\\
\mathbf{elif}\;z \leq 2.9 \cdot 10^{+175}:\\
\;\;\;\;t \cdot \frac{-z}{a - z}\\
\mathbf{elif}\;z \leq 1.42 \cdot 10^{+237}:\\
\;\;\;\;\left(-y\right) \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if z < -5.00000000000000015e82 or 1.42000000000000004e237 < z Initial program 32.5%
Taylor expanded in z 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 rewrites62.7%
Taylor expanded in x around inf
lower-*.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6429.3
Applied rewrites29.3%
Taylor expanded in y around 0
+-commutativeN/A
associate-/l*N/A
sub-divN/A
*-commutativeN/A
lower-fma.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6462.3
Applied rewrites62.3%
if -5.00000000000000015e82 < z < 3.60000000000000005e81Initial program 90.9%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6464.5
Applied rewrites64.5%
if 3.60000000000000005e81 < z < 2.9e175Initial program 52.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--.f6477.0
Applied rewrites77.0%
Taylor expanded in t around inf
lower-*.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6472.6
Applied rewrites72.6%
Taylor expanded in y around 0
mul-1-negN/A
lower-neg.f6461.6
Applied rewrites61.6%
if 2.9e175 < z < 1.42000000000000004e237Initial program 26.1%
Taylor expanded in z 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 rewrites56.1%
Taylor expanded in x around inf
lower-*.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6455.1
Applied rewrites55.1%
Taylor expanded in y around inf
associate-/l*N/A
sub-divN/A
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6470.9
Applied rewrites70.9%
Final simplification64.0%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma (/ (- t x) z) a t)))
(if (<= z -1.55e+22)
t_1
(if (<= z -7.6e-173)
x
(if (<= z 7.7e-109)
(/ (* (- t x) y) a)
(if (<= z 1.28e+42) (* t (/ y (- a z))) t_1))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma(((t - x) / z), a, t);
double tmp;
if (z <= -1.55e+22) {
tmp = t_1;
} else if (z <= -7.6e-173) {
tmp = x;
} else if (z <= 7.7e-109) {
tmp = ((t - x) * y) / a;
} else if (z <= 1.28e+42) {
tmp = t * (y / (a - z));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(Float64(t - x) / z), a, t) tmp = 0.0 if (z <= -1.55e+22) tmp = t_1; elseif (z <= -7.6e-173) tmp = x; elseif (z <= 7.7e-109) tmp = Float64(Float64(Float64(t - x) * y) / a); elseif (z <= 1.28e+42) tmp = Float64(t * Float64(y / Float64(a - z))); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(N[(t - x), $MachinePrecision] / z), $MachinePrecision] * a + t), $MachinePrecision]}, If[LessEqual[z, -1.55e+22], t$95$1, If[LessEqual[z, -7.6e-173], x, If[LessEqual[z, 7.7e-109], N[(N[(N[(t - x), $MachinePrecision] * y), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[z, 1.28e+42], N[(t * N[(y / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{t - x}{z}, a, t\right)\\
\mathbf{if}\;z \leq -1.55 \cdot 10^{+22}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq -7.6 \cdot 10^{-173}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 7.7 \cdot 10^{-109}:\\
\;\;\;\;\frac{\left(t - x\right) \cdot y}{a}\\
\mathbf{elif}\;z \leq 1.28 \cdot 10^{+42}:\\
\;\;\;\;t \cdot \frac{y}{a - z}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -1.5500000000000001e22 or 1.28000000000000004e42 < z Initial program 41.1%
Taylor expanded in z 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 rewrites58.4%
Taylor expanded in x around inf
lower-*.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6429.8
Applied rewrites29.8%
Taylor expanded in y around 0
+-commutativeN/A
associate-/l*N/A
sub-divN/A
*-commutativeN/A
lower-fma.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6450.2
Applied rewrites50.2%
if -1.5500000000000001e22 < z < -7.6000000000000006e-173Initial program 85.5%
Taylor expanded in a around inf
Applied rewrites46.7%
if -7.6000000000000006e-173 < z < 7.70000000000000025e-109Initial program 92.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--.f6455.3
Applied rewrites55.3%
Taylor expanded in z around 0
Applied rewrites51.8%
if 7.70000000000000025e-109 < z < 1.28000000000000004e42Initial program 97.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 rewrites75.0%
Taylor expanded in t around -inf
lower-*.f64N/A
lower-*.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f64N/A
lower-*.f64N/A
lift--.f6452.6
Applied rewrites52.6%
Taylor expanded in y around inf
lift-/.f64N/A
lift--.f6439.0
Applied rewrites39.0%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (/ (- t x) z)) (t_2 (fma t_1 a t)))
(if (<= z -5e+82)
t_2
(if (<= z 2.3e+29)
(fma y (/ (- t x) a) x)
(if (<= z 1.42e+237) (* (- y) t_1) t_2)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (t - x) / z;
double t_2 = fma(t_1, a, t);
double tmp;
if (z <= -5e+82) {
tmp = t_2;
} else if (z <= 2.3e+29) {
tmp = fma(y, ((t - x) / a), x);
} else if (z <= 1.42e+237) {
tmp = -y * t_1;
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(Float64(t - x) / z) t_2 = fma(t_1, a, t) tmp = 0.0 if (z <= -5e+82) tmp = t_2; elseif (z <= 2.3e+29) tmp = fma(y, Float64(Float64(t - x) / a), x); elseif (z <= 1.42e+237) tmp = Float64(Float64(-y) * t_1); else tmp = t_2; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(t - x), $MachinePrecision] / z), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * a + t), $MachinePrecision]}, If[LessEqual[z, -5e+82], t$95$2, If[LessEqual[z, 2.3e+29], N[(y * N[(N[(t - x), $MachinePrecision] / a), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[z, 1.42e+237], N[((-y) * t$95$1), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{t - x}{z}\\
t_2 := \mathsf{fma}\left(t\_1, a, t\right)\\
\mathbf{if}\;z \leq -5 \cdot 10^{+82}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;z \leq 2.3 \cdot 10^{+29}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{t - x}{a}, x\right)\\
\mathbf{elif}\;z \leq 1.42 \cdot 10^{+237}:\\
\;\;\;\;\left(-y\right) \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if z < -5.00000000000000015e82 or 1.42000000000000004e237 < z Initial program 32.5%
Taylor expanded in z 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 rewrites62.7%
Taylor expanded in x around inf
lower-*.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6429.3
Applied rewrites29.3%
Taylor expanded in y around 0
+-commutativeN/A
associate-/l*N/A
sub-divN/A
*-commutativeN/A
lower-fma.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6462.3
Applied rewrites62.3%
if -5.00000000000000015e82 < z < 2.3000000000000001e29Initial program 90.8%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6467.1
Applied rewrites67.1%
if 2.3000000000000001e29 < z < 1.42000000000000004e237Initial program 54.5%
Taylor expanded in z 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 rewrites58.7%
Taylor expanded in x around inf
lower-*.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6430.9
Applied rewrites30.9%
Taylor expanded in y around inf
associate-/l*N/A
sub-divN/A
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6444.7
Applied rewrites44.7%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -1.15e+178) (not (<= z 1.6e+234))) (fma (/ (- t x) z) a 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 <= -1.15e+178) || !(z <= 1.6e+234)) {
tmp = fma(((t - x) / z), a, 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 <= -1.15e+178) || !(z <= 1.6e+234)) tmp = fma(Float64(Float64(t - x) / z), a, 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, -1.15e+178], N[Not[LessEqual[z, 1.6e+234]], $MachinePrecision]], N[(N[(N[(t - x), $MachinePrecision] / z), $MachinePrecision] * a + 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 -1.15 \cdot 10^{+178} \lor \neg \left(z \leq 1.6 \cdot 10^{+234}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{t - x}{z}, a, t\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y - z, \frac{t - x}{a - z}, x\right)\\
\end{array}
\end{array}
if z < -1.15e178 or 1.59999999999999996e234 < z Initial program 25.1%
Taylor expanded in z 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.0%
Taylor expanded in x around inf
lower-*.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6435.6
Applied rewrites35.6%
Taylor expanded in y around 0
+-commutativeN/A
associate-/l*N/A
sub-divN/A
*-commutativeN/A
lower-fma.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6472.8
Applied rewrites72.8%
if -1.15e178 < z < 1.59999999999999996e234Initial program 78.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--.f6486.9
Applied rewrites86.9%
Final simplification84.4%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma (/ (- t x) z) a t)))
(if (<= z -5e+82)
t_1
(if (<= z 4.2e+120)
(fma y (/ (- t x) a) x)
(if (<= z 1.42e+237) (* x (/ (- y a) z)) t_1)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma(((t - x) / z), a, t);
double tmp;
if (z <= -5e+82) {
tmp = t_1;
} else if (z <= 4.2e+120) {
tmp = fma(y, ((t - x) / a), x);
} else if (z <= 1.42e+237) {
tmp = x * ((y - a) / z);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(Float64(t - x) / z), a, t) tmp = 0.0 if (z <= -5e+82) tmp = t_1; elseif (z <= 4.2e+120) tmp = fma(y, Float64(Float64(t - x) / a), x); elseif (z <= 1.42e+237) tmp = Float64(x * Float64(Float64(y - a) / z)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(N[(t - x), $MachinePrecision] / z), $MachinePrecision] * a + t), $MachinePrecision]}, If[LessEqual[z, -5e+82], t$95$1, If[LessEqual[z, 4.2e+120], N[(y * N[(N[(t - x), $MachinePrecision] / a), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[z, 1.42e+237], N[(x * N[(N[(y - a), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{t - x}{z}, a, t\right)\\
\mathbf{if}\;z \leq -5 \cdot 10^{+82}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 4.2 \cdot 10^{+120}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{t - x}{a}, x\right)\\
\mathbf{elif}\;z \leq 1.42 \cdot 10^{+237}:\\
\;\;\;\;x \cdot \frac{y - a}{z}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -5.00000000000000015e82 or 1.42000000000000004e237 < z Initial program 32.5%
Taylor expanded in z 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 rewrites62.7%
Taylor expanded in x around inf
lower-*.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6429.3
Applied rewrites29.3%
Taylor expanded in y around 0
+-commutativeN/A
associate-/l*N/A
sub-divN/A
*-commutativeN/A
lower-fma.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6462.3
Applied rewrites62.3%
if -5.00000000000000015e82 < z < 4.2000000000000001e120Initial program 90.1%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6463.4
Applied rewrites63.4%
if 4.2000000000000001e120 < z < 1.42000000000000004e237Initial program 34.7%
Taylor expanded in z 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 rewrites53.6%
Taylor expanded in x around inf
lower-*.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6441.7
Applied rewrites41.7%
(FPCore (x y z t a) :precision binary64 (if (<= y -1.06e+14) (* t (/ y (- a z))) (if (<= y -5.1e-281) t (if (<= y 66000000000000.0) x (/ (* (- t x) y) a)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (y <= -1.06e+14) {
tmp = t * (y / (a - z));
} else if (y <= -5.1e-281) {
tmp = t;
} else if (y <= 66000000000000.0) {
tmp = x;
} else {
tmp = ((t - x) * y) / a;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: tmp
if (y <= (-1.06d+14)) then
tmp = t * (y / (a - z))
else if (y <= (-5.1d-281)) then
tmp = t
else if (y <= 66000000000000.0d0) then
tmp = x
else
tmp = ((t - x) * y) / a
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (y <= -1.06e+14) {
tmp = t * (y / (a - z));
} else if (y <= -5.1e-281) {
tmp = t;
} else if (y <= 66000000000000.0) {
tmp = x;
} else {
tmp = ((t - x) * y) / a;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if y <= -1.06e+14: tmp = t * (y / (a - z)) elif y <= -5.1e-281: tmp = t elif y <= 66000000000000.0: tmp = x else: tmp = ((t - x) * y) / a return tmp
function code(x, y, z, t, a) tmp = 0.0 if (y <= -1.06e+14) tmp = Float64(t * Float64(y / Float64(a - z))); elseif (y <= -5.1e-281) tmp = t; elseif (y <= 66000000000000.0) tmp = x; else tmp = Float64(Float64(Float64(t - x) * y) / a); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (y <= -1.06e+14) tmp = t * (y / (a - z)); elseif (y <= -5.1e-281) tmp = t; elseif (y <= 66000000000000.0) tmp = x; else tmp = ((t - x) * y) / a; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[y, -1.06e+14], N[(t * N[(y / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -5.1e-281], t, If[LessEqual[y, 66000000000000.0], x, N[(N[(N[(t - x), $MachinePrecision] * y), $MachinePrecision] / a), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.06 \cdot 10^{+14}:\\
\;\;\;\;t \cdot \frac{y}{a - z}\\
\mathbf{elif}\;y \leq -5.1 \cdot 10^{-281}:\\
\;\;\;\;t\\
\mathbf{elif}\;y \leq 66000000000000:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(t - x\right) \cdot y}{a}\\
\end{array}
\end{array}
if y < -1.06e14Initial program 64.1%
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 rewrites60.9%
Taylor expanded in t around -inf
lower-*.f64N/A
lower-*.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f64N/A
lower-*.f64N/A
lift--.f6449.7
Applied rewrites49.7%
Taylor expanded in y around inf
lift-/.f64N/A
lift--.f6445.4
Applied rewrites45.4%
if -1.06e14 < y < -5.10000000000000025e-281Initial program 65.6%
Taylor expanded in z around inf
Applied rewrites43.1%
if -5.10000000000000025e-281 < y < 6.6e13Initial program 72.3%
Taylor expanded in a around inf
Applied rewrites47.8%
if 6.6e13 < y Initial program 71.8%
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--.f6462.8
Applied rewrites62.8%
Taylor expanded in z around 0
Applied rewrites41.5%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (* t (/ y (- a z)))))
(if (<= y -1.06e+14)
t_1
(if (<= y -5.1e-281) t (if (<= y 8.5e+83) x t_1)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = t * (y / (a - z));
double tmp;
if (y <= -1.06e+14) {
tmp = t_1;
} else if (y <= -5.1e-281) {
tmp = t;
} else if (y <= 8.5e+83) {
tmp = 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 / (a - z))
if (y <= (-1.06d+14)) then
tmp = t_1
else if (y <= (-5.1d-281)) then
tmp = t
else if (y <= 8.5d+83) then
tmp = 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 / (a - z));
double tmp;
if (y <= -1.06e+14) {
tmp = t_1;
} else if (y <= -5.1e-281) {
tmp = t;
} else if (y <= 8.5e+83) {
tmp = x;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = t * (y / (a - z)) tmp = 0 if y <= -1.06e+14: tmp = t_1 elif y <= -5.1e-281: tmp = t elif y <= 8.5e+83: tmp = x else: tmp = t_1 return tmp
function code(x, y, z, t, a) t_1 = Float64(t * Float64(y / Float64(a - z))) tmp = 0.0 if (y <= -1.06e+14) tmp = t_1; elseif (y <= -5.1e-281) tmp = t; elseif (y <= 8.5e+83) tmp = x; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = t * (y / (a - z)); tmp = 0.0; if (y <= -1.06e+14) tmp = t_1; elseif (y <= -5.1e-281) tmp = t; elseif (y <= 8.5e+83) tmp = x; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(t * N[(y / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.06e+14], t$95$1, If[LessEqual[y, -5.1e-281], t, If[LessEqual[y, 8.5e+83], x, t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := t \cdot \frac{y}{a - z}\\
\mathbf{if}\;y \leq -1.06 \cdot 10^{+14}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq -5.1 \cdot 10^{-281}:\\
\;\;\;\;t\\
\mathbf{elif}\;y \leq 8.5 \cdot 10^{+83}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -1.06e14 or 8.4999999999999995e83 < y Initial program 68.5%
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 rewrites67.6%
Taylor expanded in t around -inf
lower-*.f64N/A
lower-*.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f64N/A
lower-*.f64N/A
lift--.f6444.1
Applied rewrites44.1%
Taylor expanded in y around inf
lift-/.f64N/A
lift--.f6443.5
Applied rewrites43.5%
if -1.06e14 < y < -5.10000000000000025e-281Initial program 65.6%
Taylor expanded in z around inf
Applied rewrites43.1%
if -5.10000000000000025e-281 < y < 8.4999999999999995e83Initial program 70.6%
Taylor expanded in a around inf
Applied rewrites44.1%
(FPCore (x y z t a) :precision binary64 (if (or (<= a -3.15e+56) (not (<= a 9.2e+24))) (fma (- t x) (/ (- y z) a) x) (* t (/ (- y z) (- a z)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((a <= -3.15e+56) || !(a <= 9.2e+24)) {
tmp = fma((t - x), ((y - z) / a), x);
} else {
tmp = t * ((y - z) / (a - z));
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((a <= -3.15e+56) || !(a <= 9.2e+24)) tmp = fma(Float64(t - x), Float64(Float64(y - z) / 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, -3.15e+56], N[Not[LessEqual[a, 9.2e+24]], $MachinePrecision]], N[(N[(t - x), $MachinePrecision] * N[(N[(y - z), $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 -3.15 \cdot 10^{+56} \lor \neg \left(a \leq 9.2 \cdot 10^{+24}\right):\\
\;\;\;\;\mathsf{fma}\left(t - x, \frac{y - z}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;t \cdot \frac{y - z}{a - z}\\
\end{array}
\end{array}
if a < -3.15e56 or 9.1999999999999996e24 < a Initial program 71.4%
Taylor expanded in a around inf
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6478.0
Applied rewrites78.0%
if -3.15e56 < a < 9.1999999999999996e24Initial 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--.f6469.8
Applied rewrites69.8%
Taylor expanded in t around inf
lower-*.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6469.1
Applied rewrites69.1%
Final simplification73.4%
(FPCore (x y z t a) :precision binary64 (if (or (<= a -1.25e+60) (not (<= a 2.7e+30))) (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.25e+60) || !(a <= 2.7e+30)) {
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.25e+60) || !(a <= 2.7e+30)) 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.25e+60], N[Not[LessEqual[a, 2.7e+30]], $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.25 \cdot 10^{+60} \lor \neg \left(a \leq 2.7 \cdot 10^{+30}\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.24999999999999994e60 or 2.6999999999999999e30 < a Initial program 71.4%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6469.2
Applied rewrites69.2%
if -1.24999999999999994e60 < a < 2.6999999999999999e30Initial 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--.f6469.8
Applied rewrites69.8%
Taylor expanded in t around inf
lower-*.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6469.1
Applied rewrites69.1%
Final simplification69.1%
(FPCore (x y z t a) :precision binary64 (if (or (<= a -1.05e+39) (not (<= a 6.5e-6))) (fma y (/ (- t x) a) x) (* t (/ (- y z) (- z)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((a <= -1.05e+39) || !(a <= 6.5e-6)) {
tmp = fma(y, ((t - x) / a), x);
} else {
tmp = t * ((y - z) / -z);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((a <= -1.05e+39) || !(a <= 6.5e-6)) tmp = fma(y, Float64(Float64(t - x) / a), x); else tmp = Float64(t * Float64(Float64(y - z) / Float64(-z))); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[a, -1.05e+39], N[Not[LessEqual[a, 6.5e-6]], $MachinePrecision]], N[(y * N[(N[(t - x), $MachinePrecision] / a), $MachinePrecision] + x), $MachinePrecision], N[(t * N[(N[(y - z), $MachinePrecision] / (-z)), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.05 \cdot 10^{+39} \lor \neg \left(a \leq 6.5 \cdot 10^{-6}\right):\\
\;\;\;\;\mathsf{fma}\left(y, \frac{t - x}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;t \cdot \frac{y - z}{-z}\\
\end{array}
\end{array}
if a < -1.0499999999999999e39 or 6.4999999999999996e-6 < a Initial program 71.3%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6467.8
Applied rewrites67.8%
if -1.0499999999999999e39 < a < 6.4999999999999996e-6Initial program 65.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--.f6469.1
Applied rewrites69.1%
Taylor expanded in t around inf
lower-*.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6469.2
Applied rewrites69.2%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6460.2
Applied rewrites60.2%
Final simplification64.1%
(FPCore (x y z t a) :precision binary64 (if (<= a -3.6e+57) x (if (<= a 2.2e+30) t x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -3.6e+57) {
tmp = x;
} else if (a <= 2.2e+30) {
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 <= (-3.6d+57)) then
tmp = x
else if (a <= 2.2d+30) 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 <= -3.6e+57) {
tmp = x;
} else if (a <= 2.2e+30) {
tmp = t;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if a <= -3.6e+57: tmp = x elif a <= 2.2e+30: tmp = t else: tmp = x return tmp
function code(x, y, z, t, a) tmp = 0.0 if (a <= -3.6e+57) tmp = x; elseif (a <= 2.2e+30) tmp = t; else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (a <= -3.6e+57) tmp = x; elseif (a <= 2.2e+30) tmp = t; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[a, -3.6e+57], x, If[LessEqual[a, 2.2e+30], t, x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -3.6 \cdot 10^{+57}:\\
\;\;\;\;x\\
\mathbf{elif}\;a \leq 2.2 \cdot 10^{+30}:\\
\;\;\;\;t\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if a < -3.6000000000000002e57 or 2.2e30 < a Initial program 71.4%
Taylor expanded in a around inf
Applied rewrites46.9%
if -3.6000000000000002e57 < a < 2.2e30Initial program 65.7%
Taylor expanded in z around inf
Applied rewrites36.4%
(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 68.5%
Taylor expanded in z around inf
Applied rewrites25.0%
herbie shell --seed 2025085
(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))))