
(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 13 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
(let* ((t_1 (/ (- t x) (- a z))) (t_2 (+ x (/ (* (- y z) (- t x)) (- a z)))))
(if (<= t_2 (- INFINITY))
(fma (- y z) t_1 x)
(if (<= t_2 -2e-217)
t_2
(if (<= t_2 0.0)
(fma (/ (* (- t x) (- y a)) z) -1.0 t)
(if (<= t_2 5e+305) t_2 (+ (* (- y z) t_1) x)))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (t - x) / (a - z);
double t_2 = x + (((y - z) * (t - x)) / (a - z));
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = fma((y - z), t_1, x);
} else if (t_2 <= -2e-217) {
tmp = t_2;
} else if (t_2 <= 0.0) {
tmp = fma((((t - x) * (y - a)) / z), -1.0, t);
} else if (t_2 <= 5e+305) {
tmp = t_2;
} else {
tmp = ((y - z) * t_1) + x;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(Float64(t - x) / Float64(a - z)) t_2 = Float64(x + Float64(Float64(Float64(y - z) * Float64(t - x)) / Float64(a - z))) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = fma(Float64(y - z), t_1, x); elseif (t_2 <= -2e-217) tmp = t_2; elseif (t_2 <= 0.0) tmp = fma(Float64(Float64(Float64(t - x) * Float64(y - a)) / z), -1.0, t); elseif (t_2 <= 5e+305) tmp = t_2; else tmp = Float64(Float64(Float64(y - z) * t_1) + x); end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(t - x), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x + N[(N[(N[(y - z), $MachinePrecision] * N[(t - x), $MachinePrecision]), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], N[(N[(y - z), $MachinePrecision] * t$95$1 + x), $MachinePrecision], If[LessEqual[t$95$2, -2e-217], t$95$2, If[LessEqual[t$95$2, 0.0], N[(N[(N[(N[(t - x), $MachinePrecision] * N[(y - a), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision] * -1.0 + t), $MachinePrecision], If[LessEqual[t$95$2, 5e+305], t$95$2, N[(N[(N[(y - z), $MachinePrecision] * t$95$1), $MachinePrecision] + x), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{t - x}{a - z}\\
t_2 := x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\\
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;\mathsf{fma}\left(y - z, t\_1, x\right)\\
\mathbf{elif}\;t\_2 \leq -2 \cdot 10^{-217}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_2 \leq 0:\\
\;\;\;\;\mathsf{fma}\left(\frac{\left(t - x\right) \cdot \left(y - a\right)}{z}, -1, t\right)\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+305}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;\left(y - z\right) \cdot t\_1 + x\\
\end{array}
\end{array}
if (+.f64 x (/.f64 (*.f64 (-.f64 y z) (-.f64 t x)) (-.f64 a z))) < -inf.0Initial program 38.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--.f6476.9
Applied rewrites76.9%
if -inf.0 < (+.f64 x (/.f64 (*.f64 (-.f64 y z) (-.f64 t x)) (-.f64 a z))) < -2.00000000000000016e-217 or 0.0 < (+.f64 x (/.f64 (*.f64 (-.f64 y z) (-.f64 t x)) (-.f64 a z))) < 5.00000000000000009e305Initial program 98.3%
if -2.00000000000000016e-217 < (+.f64 x (/.f64 (*.f64 (-.f64 y z) (-.f64 t x)) (-.f64 a z))) < 0.0Initial program 8.8%
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 rewrites99.6%
if 5.00000000000000009e305 < (+.f64 x (/.f64 (*.f64 (-.f64 y z) (-.f64 t x)) (-.f64 a z))) Initial program 47.4%
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--.f6486.3
Applied rewrites86.3%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma (- y z) (/ (- t x) (- a z)) x))
(t_2 (+ x (/ (* (- y z) (- t x)) (- a z)))))
(if (<= t_2 (- INFINITY))
t_1
(if (<= t_2 -2e-217)
t_2
(if (<= t_2 0.0)
(fma (/ (* (- t x) (- y a)) z) -1.0 t)
(if (<= t_2 5e+305) t_2 t_1))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma((y - z), ((t - x) / (a - z)), x);
double t_2 = x + (((y - z) * (t - x)) / (a - z));
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = t_1;
} else if (t_2 <= -2e-217) {
tmp = t_2;
} else if (t_2 <= 0.0) {
tmp = fma((((t - x) * (y - a)) / z), -1.0, t);
} else if (t_2 <= 5e+305) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(y - z), Float64(Float64(t - x) / Float64(a - z)), x) t_2 = Float64(x + Float64(Float64(Float64(y - z) * Float64(t - x)) / Float64(a - z))) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = t_1; elseif (t_2 <= -2e-217) tmp = t_2; elseif (t_2 <= 0.0) tmp = fma(Float64(Float64(Float64(t - x) * Float64(y - a)) / z), -1.0, t); elseif (t_2 <= 5e+305) tmp = t_2; else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(y - z), $MachinePrecision] * N[(N[(t - x), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]}, Block[{t$95$2 = N[(x + N[(N[(N[(y - z), $MachinePrecision] * N[(t - x), $MachinePrecision]), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], t$95$1, If[LessEqual[t$95$2, -2e-217], t$95$2, If[LessEqual[t$95$2, 0.0], N[(N[(N[(N[(t - x), $MachinePrecision] * N[(y - a), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision] * -1.0 + t), $MachinePrecision], If[LessEqual[t$95$2, 5e+305], t$95$2, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(y - z, \frac{t - x}{a - z}, x\right)\\
t_2 := x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\\
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq -2 \cdot 10^{-217}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_2 \leq 0:\\
\;\;\;\;\mathsf{fma}\left(\frac{\left(t - x\right) \cdot \left(y - a\right)}{z}, -1, t\right)\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+305}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (+.f64 x (/.f64 (*.f64 (-.f64 y z) (-.f64 t x)) (-.f64 a z))) < -inf.0 or 5.00000000000000009e305 < (+.f64 x (/.f64 (*.f64 (-.f64 y z) (-.f64 t x)) (-.f64 a z))) Initial program 42.9%
lift-+.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
associate-/l*N/A
sub-divN/A
lower-fma.f64N/A
lift--.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6481.6
Applied rewrites81.6%
if -inf.0 < (+.f64 x (/.f64 (*.f64 (-.f64 y z) (-.f64 t x)) (-.f64 a z))) < -2.00000000000000016e-217 or 0.0 < (+.f64 x (/.f64 (*.f64 (-.f64 y z) (-.f64 t x)) (-.f64 a z))) < 5.00000000000000009e305Initial program 98.3%
if -2.00000000000000016e-217 < (+.f64 x (/.f64 (*.f64 (-.f64 y z) (-.f64 t x)) (-.f64 a z))) < 0.0Initial program 8.8%
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 rewrites99.6%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -1.5e+102) (not (<= z 6.4e+143))) (fma (- y) (/ (- 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 <= -1.5e+102) || !(z <= 6.4e+143)) {
tmp = fma(-y, ((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 <= -1.5e+102) || !(z <= 6.4e+143)) tmp = fma(Float64(-y), 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, -1.5e+102], N[Not[LessEqual[z, 6.4e+143]], $MachinePrecision]], N[((-y) * 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 -1.5 \cdot 10^{+102} \lor \neg \left(z \leq 6.4 \cdot 10^{+143}\right):\\
\;\;\;\;\mathsf{fma}\left(-y, \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 < -1.4999999999999999e102 or 6.40000000000000033e143 < z Initial program 33.2%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6452.1
Applied rewrites52.1%
Taylor expanded in y around 0
+-commutativeN/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6480.5
Applied rewrites80.5%
if -1.4999999999999999e102 < z < 6.40000000000000033e143Initial program 85.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--.f6486.0
Applied rewrites86.0%
Final simplification84.5%
(FPCore (x y z t a)
:precision binary64
(if (<= z -1.5e+102)
(fma (/ (* (- t x) (- y a)) z) -1.0 t)
(if (<= z 6.4e+143)
(fma (- y z) (/ (- t x) (- a z)) x)
(fma (- y) (/ (- t x) z) t))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -1.5e+102) {
tmp = fma((((t - x) * (y - a)) / z), -1.0, t);
} else if (z <= 6.4e+143) {
tmp = fma((y - z), ((t - x) / (a - z)), x);
} else {
tmp = fma(-y, ((t - x) / z), t);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -1.5e+102) tmp = fma(Float64(Float64(Float64(t - x) * Float64(y - a)) / z), -1.0, t); elseif (z <= 6.4e+143) tmp = fma(Float64(y - z), Float64(Float64(t - x) / Float64(a - z)), x); else tmp = fma(Float64(-y), Float64(Float64(t - x) / z), t); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -1.5e+102], N[(N[(N[(N[(t - x), $MachinePrecision] * N[(y - a), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision] * -1.0 + t), $MachinePrecision], If[LessEqual[z, 6.4e+143], N[(N[(y - z), $MachinePrecision] * N[(N[(t - x), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[((-y) * N[(N[(t - x), $MachinePrecision] / z), $MachinePrecision] + t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.5 \cdot 10^{+102}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\left(t - x\right) \cdot \left(y - a\right)}{z}, -1, t\right)\\
\mathbf{elif}\;z \leq 6.4 \cdot 10^{+143}:\\
\;\;\;\;\mathsf{fma}\left(y - z, \frac{t - x}{a - z}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-y, \frac{t - x}{z}, t\right)\\
\end{array}
\end{array}
if z < -1.4999999999999999e102Initial program 43.9%
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 rewrites79.9%
if -1.4999999999999999e102 < z < 6.40000000000000033e143Initial program 85.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--.f6486.0
Applied rewrites86.0%
if 6.40000000000000033e143 < z Initial program 23.6%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6444.8
Applied rewrites44.8%
Taylor expanded in y around 0
+-commutativeN/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6481.2
Applied rewrites81.2%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -4.8e+74) (not (<= z 5.6e+76))) (fma (- y) (/ (- t x) z) t) (fma (- t x) (/ (- y z) a) x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -4.8e+74) || !(z <= 5.6e+76)) {
tmp = fma(-y, ((t - x) / z), t);
} else {
tmp = fma((t - x), ((y - z) / a), x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -4.8e+74) || !(z <= 5.6e+76)) tmp = fma(Float64(-y), Float64(Float64(t - x) / z), t); else tmp = fma(Float64(t - x), Float64(Float64(y - z) / a), x); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -4.8e+74], N[Not[LessEqual[z, 5.6e+76]], $MachinePrecision]], N[((-y) * N[(N[(t - x), $MachinePrecision] / z), $MachinePrecision] + t), $MachinePrecision], N[(N[(t - x), $MachinePrecision] * N[(N[(y - z), $MachinePrecision] / a), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.8 \cdot 10^{+74} \lor \neg \left(z \leq 5.6 \cdot 10^{+76}\right):\\
\;\;\;\;\mathsf{fma}\left(-y, \frac{t - x}{z}, t\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t - x, \frac{y - z}{a}, x\right)\\
\end{array}
\end{array}
if z < -4.80000000000000017e74 or 5.5999999999999997e76 < z Initial program 37.1%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6453.8
Applied rewrites53.8%
Taylor expanded in y around 0
+-commutativeN/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6478.3
Applied rewrites78.3%
if -4.80000000000000017e74 < z < 5.5999999999999997e76Initial program 87.9%
Taylor expanded in a around inf
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6475.5
Applied rewrites75.5%
Final simplification76.5%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -54000000000.0) (not (<= z 1.25e-43))) (fma (- y) (/ (- t x) z) t) (fma y (/ (- t x) a) x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -54000000000.0) || !(z <= 1.25e-43)) {
tmp = fma(-y, ((t - x) / z), t);
} else {
tmp = fma(y, ((t - x) / a), x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -54000000000.0) || !(z <= 1.25e-43)) tmp = fma(Float64(-y), Float64(Float64(t - x) / z), t); else tmp = fma(y, Float64(Float64(t - x) / a), x); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -54000000000.0], N[Not[LessEqual[z, 1.25e-43]], $MachinePrecision]], N[((-y) * N[(N[(t - x), $MachinePrecision] / z), $MachinePrecision] + t), $MachinePrecision], N[(y * N[(N[(t - x), $MachinePrecision] / a), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -54000000000 \lor \neg \left(z \leq 1.25 \cdot 10^{-43}\right):\\
\;\;\;\;\mathsf{fma}\left(-y, \frac{t - x}{z}, t\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{t - x}{a}, x\right)\\
\end{array}
\end{array}
if z < -5.4e10 or 1.25000000000000005e-43 < z Initial program 48.5%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6449.4
Applied rewrites49.4%
Taylor expanded in y around 0
+-commutativeN/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6468.9
Applied rewrites68.9%
if -5.4e10 < z < 1.25000000000000005e-43Initial program 91.8%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6472.7
Applied rewrites72.7%
Final simplification70.8%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -3.9e+74) (not (<= z 2.1e+32))) (* (- t) (/ (- y z) z)) (fma y (/ (- t x) a) x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -3.9e+74) || !(z <= 2.1e+32)) {
tmp = -t * ((y - z) / z);
} else {
tmp = fma(y, ((t - x) / a), x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -3.9e+74) || !(z <= 2.1e+32)) tmp = Float64(Float64(-t) * Float64(Float64(y - z) / z)); else tmp = fma(y, Float64(Float64(t - x) / a), x); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -3.9e+74], N[Not[LessEqual[z, 2.1e+32]], $MachinePrecision]], N[((-t) * N[(N[(y - z), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(y * N[(N[(t - x), $MachinePrecision] / a), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.9 \cdot 10^{+74} \lor \neg \left(z \leq 2.1 \cdot 10^{+32}\right):\\
\;\;\;\;\left(-t\right) \cdot \frac{y - z}{z}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{t - x}{a}, x\right)\\
\end{array}
\end{array}
if z < -3.90000000000000008e74 or 2.1000000000000001e32 < z Initial program 42.1%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6452.3
Applied rewrites52.3%
Taylor expanded in x around 0
mul-1-negN/A
lower-neg.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift--.f6457.9
Applied rewrites57.9%
if -3.90000000000000008e74 < z < 2.1000000000000001e32Initial program 88.3%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6466.4
Applied rewrites66.4%
Final simplification63.2%
(FPCore (x y z t a) :precision binary64 (if (<= z -3.9e+74) (* (- t) (/ (- y z) z)) (if (<= z 2.1e+32) (fma y (/ (- t x) a) x) (* (- (/ y z) 1.0) (- t)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -3.9e+74) {
tmp = -t * ((y - z) / z);
} else if (z <= 2.1e+32) {
tmp = fma(y, ((t - x) / a), x);
} else {
tmp = ((y / z) - 1.0) * -t;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -3.9e+74) tmp = Float64(Float64(-t) * Float64(Float64(y - z) / z)); elseif (z <= 2.1e+32) tmp = fma(y, Float64(Float64(t - x) / a), x); else tmp = Float64(Float64(Float64(y / z) - 1.0) * Float64(-t)); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -3.9e+74], N[((-t) * N[(N[(y - z), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2.1e+32], N[(y * N[(N[(t - x), $MachinePrecision] / a), $MachinePrecision] + x), $MachinePrecision], N[(N[(N[(y / z), $MachinePrecision] - 1.0), $MachinePrecision] * (-t)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.9 \cdot 10^{+74}:\\
\;\;\;\;\left(-t\right) \cdot \frac{y - z}{z}\\
\mathbf{elif}\;z \leq 2.1 \cdot 10^{+32}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{t - x}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{y}{z} - 1\right) \cdot \left(-t\right)\\
\end{array}
\end{array}
if z < -3.90000000000000008e74Initial program 45.3%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6459.2
Applied rewrites59.2%
Taylor expanded in x around 0
mul-1-negN/A
lower-neg.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift--.f6461.4
Applied rewrites61.4%
if -3.90000000000000008e74 < z < 2.1000000000000001e32Initial program 88.3%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6466.4
Applied rewrites66.4%
if 2.1000000000000001e32 < z Initial program 39.9%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6447.5
Applied rewrites47.5%
Taylor expanded in t around -inf
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f6455.5
Applied rewrites55.5%
Final simplification63.2%
(FPCore (x y z t a) :precision binary64 (if (<= z -1.2e+75) t (if (<= z 3.8e+143) (fma y (/ (- t x) a) x) t)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -1.2e+75) {
tmp = t;
} else if (z <= 3.8e+143) {
tmp = fma(y, ((t - x) / a), x);
} else {
tmp = t;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -1.2e+75) tmp = t; elseif (z <= 3.8e+143) 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, -1.2e+75], t, If[LessEqual[z, 3.8e+143], N[(y * N[(N[(t - x), $MachinePrecision] / a), $MachinePrecision] + x), $MachinePrecision], t]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.2 \cdot 10^{+75}:\\
\;\;\;\;t\\
\mathbf{elif}\;z \leq 3.8 \cdot 10^{+143}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{t - x}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\\
\end{array}
\end{array}
if z < -1.2e75 or 3.8e143 < z Initial program 34.7%
Taylor expanded in z around inf
Applied rewrites54.0%
if -1.2e75 < z < 3.8e143Initial program 86.4%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6463.6
Applied rewrites63.6%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -1.2e+75) (not (<= z 7e+32))) t (* (- t x) (/ y a))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -1.2e+75) || !(z <= 7e+32)) {
tmp = t;
} 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 ((z <= (-1.2d+75)) .or. (.not. (z <= 7d+32))) then
tmp = t
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 ((z <= -1.2e+75) || !(z <= 7e+32)) {
tmp = t;
} else {
tmp = (t - x) * (y / a);
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (z <= -1.2e+75) or not (z <= 7e+32): tmp = t else: tmp = (t - x) * (y / a) return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -1.2e+75) || !(z <= 7e+32)) tmp = t; else tmp = Float64(Float64(t - x) * Float64(y / a)); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((z <= -1.2e+75) || ~((z <= 7e+32))) tmp = t; else tmp = (t - x) * (y / a); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -1.2e+75], N[Not[LessEqual[z, 7e+32]], $MachinePrecision]], t, N[(N[(t - x), $MachinePrecision] * N[(y / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.2 \cdot 10^{+75} \lor \neg \left(z \leq 7 \cdot 10^{+32}\right):\\
\;\;\;\;t\\
\mathbf{else}:\\
\;\;\;\;\left(t - x\right) \cdot \frac{y}{a}\\
\end{array}
\end{array}
if z < -1.2e75 or 7.0000000000000002e32 < z Initial program 42.1%
Taylor expanded in z around inf
Applied rewrites48.8%
if -1.2e75 < z < 7.0000000000000002e32Initial program 88.3%
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--.f6457.0
Applied rewrites57.0%
Taylor expanded in z around 0
Applied rewrites42.8%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift--.f64N/A
lower-/.f6444.5
Applied rewrites44.5%
Final simplification46.1%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -1.2e+75) (not (<= z 5.2e+32))) t (* t (/ y (- a z)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -1.2e+75) || !(z <= 5.2e+32)) {
tmp = t;
} else {
tmp = t * (y / (a - z));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: tmp
if ((z <= (-1.2d+75)) .or. (.not. (z <= 5.2d+32))) then
tmp = t
else
tmp = t * (y / (a - z))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -1.2e+75) || !(z <= 5.2e+32)) {
tmp = t;
} else {
tmp = t * (y / (a - z));
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (z <= -1.2e+75) or not (z <= 5.2e+32): tmp = t else: tmp = t * (y / (a - z)) return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -1.2e+75) || !(z <= 5.2e+32)) tmp = t; else tmp = Float64(t * Float64(y / Float64(a - z))); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((z <= -1.2e+75) || ~((z <= 5.2e+32))) tmp = t; else tmp = t * (y / (a - z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -1.2e+75], N[Not[LessEqual[z, 5.2e+32]], $MachinePrecision]], t, N[(t * N[(y / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.2 \cdot 10^{+75} \lor \neg \left(z \leq 5.2 \cdot 10^{+32}\right):\\
\;\;\;\;t\\
\mathbf{else}:\\
\;\;\;\;t \cdot \frac{y}{a - z}\\
\end{array}
\end{array}
if z < -1.2e75 or 5.2000000000000004e32 < z Initial program 42.1%
Taylor expanded in z around inf
Applied rewrites48.8%
if -1.2e75 < z < 5.2000000000000004e32Initial program 88.3%
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--.f6457.0
Applied rewrites57.0%
Taylor expanded in x around 0
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift--.f6433.0
Applied rewrites33.0%
Final simplification39.1%
(FPCore (x y z t a) :precision binary64 (if (<= a -90000000000.0) x (if (<= a 1.55e-7) t x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -90000000000.0) {
tmp = x;
} else if (a <= 1.55e-7) {
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 <= (-90000000000.0d0)) then
tmp = x
else if (a <= 1.55d-7) 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 <= -90000000000.0) {
tmp = x;
} else if (a <= 1.55e-7) {
tmp = t;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if a <= -90000000000.0: tmp = x elif a <= 1.55e-7: tmp = t else: tmp = x return tmp
function code(x, y, z, t, a) tmp = 0.0 if (a <= -90000000000.0) tmp = x; elseif (a <= 1.55e-7) tmp = t; else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (a <= -90000000000.0) tmp = x; elseif (a <= 1.55e-7) tmp = t; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[a, -90000000000.0], x, If[LessEqual[a, 1.55e-7], t, x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -90000000000:\\
\;\;\;\;x\\
\mathbf{elif}\;a \leq 1.55 \cdot 10^{-7}:\\
\;\;\;\;t\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if a < -9e10 or 1.55e-7 < a Initial program 69.6%
Taylor expanded in a around inf
Applied rewrites43.1%
if -9e10 < a < 1.55e-7Initial program 71.4%
Taylor expanded in z around inf
Applied rewrites32.6%
(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 70.6%
Taylor expanded in z around inf
Applied rewrites23.4%
(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 2025037
(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))))