
(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) z)))
(if (<= z -1.7e+177)
(fma (fma -1.0 y a) t_1 t)
(if (<= z 6.2e+160)
(fma (/ (- t x) (- a z)) (- y z) x)
(+
(+ (fma (- y) t_1 (* (* (- (- t x)) (/ (- y a) z)) (/ a z))) t)
(* a t_1))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (t - x) / z;
double tmp;
if (z <= -1.7e+177) {
tmp = fma(fma(-1.0, y, a), t_1, t);
} else if (z <= 6.2e+160) {
tmp = fma(((t - x) / (a - z)), (y - z), x);
} else {
tmp = (fma(-y, t_1, ((-(t - x) * ((y - a) / z)) * (a / z))) + t) + (a * t_1);
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(Float64(t - x) / z) tmp = 0.0 if (z <= -1.7e+177) tmp = fma(fma(-1.0, y, a), t_1, t); elseif (z <= 6.2e+160) tmp = fma(Float64(Float64(t - x) / Float64(a - z)), Float64(y - z), x); else tmp = Float64(Float64(fma(Float64(-y), t_1, Float64(Float64(Float64(-Float64(t - x)) * Float64(Float64(y - a) / z)) * Float64(a / z))) + t) + Float64(a * t_1)); end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(t - x), $MachinePrecision] / z), $MachinePrecision]}, If[LessEqual[z, -1.7e+177], N[(N[(-1.0 * y + a), $MachinePrecision] * t$95$1 + t), $MachinePrecision], If[LessEqual[z, 6.2e+160], N[(N[(N[(t - x), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision] * N[(y - z), $MachinePrecision] + x), $MachinePrecision], N[(N[(N[((-y) * t$95$1 + N[(N[((-N[(t - x), $MachinePrecision]) * N[(N[(y - a), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision] * N[(a / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t), $MachinePrecision] + N[(a * t$95$1), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{t - x}{z}\\
\mathbf{if}\;z \leq -1.7 \cdot 10^{+177}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-1, y, a\right), t\_1, t\right)\\
\mathbf{elif}\;z \leq 6.2 \cdot 10^{+160}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t - x}{a - z}, y - z, x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(-y, t\_1, \left(\left(-\left(t - x\right)\right) \cdot \frac{y - a}{z}\right) \cdot \frac{a}{z}\right) + t\right) + a \cdot t\_1\\
\end{array}
\end{array}
if z < -1.6999999999999999e177Initial program 21.2%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6448.8
Applied rewrites48.8%
Taylor expanded in z around inf
associate--l+N/A
associate-*r/N/A
associate-*r/N/A
associate-*r*N/A
mul-1-negN/A
div-subN/A
mul-1-negN/A
associate-*r*N/A
distribute-lft-out--N/A
associate-*r/N/A
Applied rewrites94.3%
if -1.6999999999999999e177 < z < 6.1999999999999996e160Initial program 80.3%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6488.5
Applied rewrites88.5%
if 6.1999999999999996e160 < z Initial program 30.9%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6450.1
Applied rewrites50.1%
lift-/.f64N/A
lift--.f64N/A
flip--N/A
associate-/r/N/A
lower-*.f64N/A
lower-/.f64N/A
difference-of-squaresN/A
lift--.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f649.9
Applied rewrites9.9%
Taylor expanded in z around inf
Applied rewrites89.1%
Final simplification89.4%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -1.7e+177) (not (<= z 6.2e+160))) (fma (fma -1.0 y a) (/ (- t x) z) t) (fma (/ (- t x) (- a z)) (- y z) x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -1.7e+177) || !(z <= 6.2e+160)) {
tmp = fma(fma(-1.0, y, a), ((t - x) / z), t);
} else {
tmp = fma(((t - x) / (a - z)), (y - z), x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -1.7e+177) || !(z <= 6.2e+160)) tmp = fma(fma(-1.0, y, a), Float64(Float64(t - x) / z), t); else tmp = fma(Float64(Float64(t - x) / Float64(a - z)), Float64(y - z), x); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -1.7e+177], N[Not[LessEqual[z, 6.2e+160]], $MachinePrecision]], N[(N[(-1.0 * y + a), $MachinePrecision] * N[(N[(t - x), $MachinePrecision] / z), $MachinePrecision] + t), $MachinePrecision], N[(N[(N[(t - x), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision] * N[(y - z), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.7 \cdot 10^{+177} \lor \neg \left(z \leq 6.2 \cdot 10^{+160}\right):\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-1, y, a\right), \frac{t - x}{z}, t\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t - x}{a - z}, y - z, x\right)\\
\end{array}
\end{array}
if z < -1.6999999999999999e177 or 6.1999999999999996e160 < z Initial program 25.5%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6449.4
Applied rewrites49.4%
Taylor expanded in z around inf
associate--l+N/A
associate-*r/N/A
associate-*r/N/A
associate-*r*N/A
mul-1-negN/A
div-subN/A
mul-1-negN/A
associate-*r*N/A
distribute-lft-out--N/A
associate-*r/N/A
Applied rewrites91.6%
if -1.6999999999999999e177 < z < 6.1999999999999996e160Initial program 80.3%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6488.5
Applied rewrites88.5%
Final simplification89.3%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -3.5e-51) (not (<= z 6.4e+17))) (fma (fma -1.0 y a) (/ (- t x) z) t) (fma (- y z) (/ (- t x) a) x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -3.5e-51) || !(z <= 6.4e+17)) {
tmp = fma(fma(-1.0, y, a), ((t - x) / z), t);
} else {
tmp = fma((y - z), ((t - x) / a), x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -3.5e-51) || !(z <= 6.4e+17)) tmp = fma(fma(-1.0, y, a), Float64(Float64(t - x) / z), t); else tmp = fma(Float64(y - z), Float64(Float64(t - x) / a), x); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -3.5e-51], N[Not[LessEqual[z, 6.4e+17]], $MachinePrecision]], N[(N[(-1.0 * y + a), $MachinePrecision] * N[(N[(t - x), $MachinePrecision] / z), $MachinePrecision] + t), $MachinePrecision], N[(N[(y - z), $MachinePrecision] * N[(N[(t - x), $MachinePrecision] / a), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.5 \cdot 10^{-51} \lor \neg \left(z \leq 6.4 \cdot 10^{+17}\right):\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-1, y, a\right), \frac{t - x}{z}, t\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y - z, \frac{t - x}{a}, x\right)\\
\end{array}
\end{array}
if z < -3.4999999999999997e-51 or 6.4e17 < z Initial program 45.3%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6466.9
Applied rewrites66.9%
Taylor expanded in z around inf
associate--l+N/A
associate-*r/N/A
associate-*r/N/A
associate-*r*N/A
mul-1-negN/A
div-subN/A
mul-1-negN/A
associate-*r*N/A
distribute-lft-out--N/A
associate-*r/N/A
Applied rewrites78.2%
if -3.4999999999999997e-51 < z < 6.4e17Initial program 91.8%
Taylor expanded in a around inf
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6480.5
Applied rewrites80.5%
Final simplification79.2%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma x (/ (- y a) z) t)))
(if (<= z -3.6e-51)
t_1
(if (<= z 8e+17)
(fma (- y z) (/ (- t x) a) x)
(if (<= z 1.25e+196) (fma (/ (- x t) z) y t) t_1)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma(x, ((y - a) / z), t);
double tmp;
if (z <= -3.6e-51) {
tmp = t_1;
} else if (z <= 8e+17) {
tmp = fma((y - z), ((t - x) / a), x);
} else if (z <= 1.25e+196) {
tmp = fma(((x - t) / z), y, t);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(x, Float64(Float64(y - a) / z), t) tmp = 0.0 if (z <= -3.6e-51) tmp = t_1; elseif (z <= 8e+17) tmp = fma(Float64(y - z), Float64(Float64(t - x) / a), x); elseif (z <= 1.25e+196) tmp = fma(Float64(Float64(x - t) / z), y, t); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(x * N[(N[(y - a), $MachinePrecision] / z), $MachinePrecision] + t), $MachinePrecision]}, If[LessEqual[z, -3.6e-51], t$95$1, If[LessEqual[z, 8e+17], N[(N[(y - z), $MachinePrecision] * N[(N[(t - x), $MachinePrecision] / a), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[z, 1.25e+196], N[(N[(N[(x - t), $MachinePrecision] / z), $MachinePrecision] * y + t), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(x, \frac{y - a}{z}, t\right)\\
\mathbf{if}\;z \leq -3.6 \cdot 10^{-51}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 8 \cdot 10^{+17}:\\
\;\;\;\;\mathsf{fma}\left(y - z, \frac{t - x}{a}, x\right)\\
\mathbf{elif}\;z \leq 1.25 \cdot 10^{+196}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x - t}{z}, y, t\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -3.6e-51 or 1.2499999999999999e196 < z Initial program 40.7%
Taylor expanded in z around inf
associate--l+N/A
distribute-lft-out--N/A
div-subN/A
+-commutativeN/A
mul-1-negN/A
distribute-rgt-out--N/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
Applied rewrites78.4%
Taylor expanded in x around inf
Applied rewrites76.2%
if -3.6e-51 < z < 8e17Initial program 91.8%
Taylor expanded in a around inf
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6480.5
Applied rewrites80.5%
if 8e17 < z < 1.2499999999999999e196Initial program 56.4%
Taylor expanded in z around inf
associate--l+N/A
distribute-lft-out--N/A
div-subN/A
+-commutativeN/A
mul-1-negN/A
distribute-rgt-out--N/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
Applied rewrites69.4%
Taylor expanded in a around 0
+-commutativeN/A
associate-/l*N/A
div-subN/A
*-commutativeN/A
lower-fma.f64N/A
div-subN/A
lower-/.f64N/A
lower--.f6463.7
Applied rewrites63.7%
Final simplification75.9%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma x (/ (- y a) z) t)))
(if (<= z -3.6e-51)
t_1
(if (<= z 2.3e+16)
(fma (/ (- t x) a) y x)
(if (<= z 1.25e+196) (fma (/ (- x t) z) y t) t_1)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma(x, ((y - a) / z), t);
double tmp;
if (z <= -3.6e-51) {
tmp = t_1;
} else if (z <= 2.3e+16) {
tmp = fma(((t - x) / a), y, x);
} else if (z <= 1.25e+196) {
tmp = fma(((x - t) / z), y, t);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(x, Float64(Float64(y - a) / z), t) tmp = 0.0 if (z <= -3.6e-51) tmp = t_1; elseif (z <= 2.3e+16) tmp = fma(Float64(Float64(t - x) / a), y, x); elseif (z <= 1.25e+196) tmp = fma(Float64(Float64(x - t) / z), y, t); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(x * N[(N[(y - a), $MachinePrecision] / z), $MachinePrecision] + t), $MachinePrecision]}, If[LessEqual[z, -3.6e-51], t$95$1, If[LessEqual[z, 2.3e+16], N[(N[(N[(t - x), $MachinePrecision] / a), $MachinePrecision] * y + x), $MachinePrecision], If[LessEqual[z, 1.25e+196], N[(N[(N[(x - t), $MachinePrecision] / z), $MachinePrecision] * y + t), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(x, \frac{y - a}{z}, t\right)\\
\mathbf{if}\;z \leq -3.6 \cdot 10^{-51}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 2.3 \cdot 10^{+16}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t - x}{a}, y, x\right)\\
\mathbf{elif}\;z \leq 1.25 \cdot 10^{+196}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x - t}{z}, y, t\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -3.6e-51 or 1.2499999999999999e196 < z Initial program 40.7%
Taylor expanded in z around inf
associate--l+N/A
distribute-lft-out--N/A
div-subN/A
+-commutativeN/A
mul-1-negN/A
distribute-rgt-out--N/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
Applied rewrites78.4%
Taylor expanded in x around inf
Applied rewrites76.2%
if -3.6e-51 < z < 2.3e16Initial program 91.8%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower--.f6478.1
Applied rewrites78.1%
if 2.3e16 < z < 1.2499999999999999e196Initial program 56.4%
Taylor expanded in z around inf
associate--l+N/A
distribute-lft-out--N/A
div-subN/A
+-commutativeN/A
mul-1-negN/A
distribute-rgt-out--N/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
Applied rewrites69.4%
Taylor expanded in a around 0
+-commutativeN/A
associate-/l*N/A
div-subN/A
*-commutativeN/A
lower-fma.f64N/A
div-subN/A
lower-/.f64N/A
lower--.f6463.7
Applied rewrites63.7%
Final simplification74.9%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma x (/ (- y a) z) t)))
(if (<= z -3e-51)
t_1
(if (<= z 2.3e+16)
(fma y (/ t a) x)
(if (<= z 1.25e+196) (fma (/ (- x t) z) y t) t_1)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma(x, ((y - a) / z), t);
double tmp;
if (z <= -3e-51) {
tmp = t_1;
} else if (z <= 2.3e+16) {
tmp = fma(y, (t / a), x);
} else if (z <= 1.25e+196) {
tmp = fma(((x - t) / z), y, t);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(x, Float64(Float64(y - a) / z), t) tmp = 0.0 if (z <= -3e-51) tmp = t_1; elseif (z <= 2.3e+16) tmp = fma(y, Float64(t / a), x); elseif (z <= 1.25e+196) tmp = fma(Float64(Float64(x - t) / z), y, t); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(x * N[(N[(y - a), $MachinePrecision] / z), $MachinePrecision] + t), $MachinePrecision]}, If[LessEqual[z, -3e-51], t$95$1, If[LessEqual[z, 2.3e+16], N[(y * N[(t / a), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[z, 1.25e+196], N[(N[(N[(x - t), $MachinePrecision] / z), $MachinePrecision] * y + t), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(x, \frac{y - a}{z}, t\right)\\
\mathbf{if}\;z \leq -3 \cdot 10^{-51}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 2.3 \cdot 10^{+16}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{t}{a}, x\right)\\
\mathbf{elif}\;z \leq 1.25 \cdot 10^{+196}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x - t}{z}, y, t\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -3.00000000000000002e-51 or 1.2499999999999999e196 < z Initial program 40.7%
Taylor expanded in z around inf
associate--l+N/A
distribute-lft-out--N/A
div-subN/A
+-commutativeN/A
mul-1-negN/A
distribute-rgt-out--N/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
Applied rewrites78.4%
Taylor expanded in x around inf
Applied rewrites76.2%
if -3.00000000000000002e-51 < z < 2.3e16Initial program 91.8%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6491.9
Applied rewrites91.9%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower--.f6478.1
Applied rewrites78.1%
Taylor expanded in x around 0
Applied rewrites59.2%
if 2.3e16 < z < 1.2499999999999999e196Initial program 56.4%
Taylor expanded in z around inf
associate--l+N/A
distribute-lft-out--N/A
div-subN/A
+-commutativeN/A
mul-1-negN/A
distribute-rgt-out--N/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
Applied rewrites69.4%
Taylor expanded in a around 0
+-commutativeN/A
associate-/l*N/A
div-subN/A
*-commutativeN/A
lower-fma.f64N/A
div-subN/A
lower-/.f64N/A
lower--.f6463.7
Applied rewrites63.7%
Final simplification66.9%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -3.5e-51) (not (<= z 6.4e+17))) (fma (- (- t x)) (/ (- y a) z) t) (fma (- y z) (/ (- t x) a) x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -3.5e-51) || !(z <= 6.4e+17)) {
tmp = fma(-(t - x), ((y - a) / z), t);
} else {
tmp = fma((y - z), ((t - x) / a), x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -3.5e-51) || !(z <= 6.4e+17)) tmp = fma(Float64(-Float64(t - x)), Float64(Float64(y - a) / z), t); else tmp = fma(Float64(y - z), Float64(Float64(t - x) / a), x); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -3.5e-51], N[Not[LessEqual[z, 6.4e+17]], $MachinePrecision]], N[((-N[(t - x), $MachinePrecision]) * N[(N[(y - a), $MachinePrecision] / z), $MachinePrecision] + t), $MachinePrecision], N[(N[(y - z), $MachinePrecision] * N[(N[(t - x), $MachinePrecision] / a), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.5 \cdot 10^{-51} \lor \neg \left(z \leq 6.4 \cdot 10^{+17}\right):\\
\;\;\;\;\mathsf{fma}\left(-\left(t - x\right), \frac{y - a}{z}, t\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y - z, \frac{t - x}{a}, x\right)\\
\end{array}
\end{array}
if z < -3.4999999999999997e-51 or 6.4e17 < z Initial program 45.3%
Taylor expanded in z around inf
associate--l+N/A
distribute-lft-out--N/A
div-subN/A
+-commutativeN/A
mul-1-negN/A
distribute-rgt-out--N/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
Applied rewrites75.8%
if -3.4999999999999997e-51 < z < 6.4e17Initial program 91.8%
Taylor expanded in a around inf
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6480.5
Applied rewrites80.5%
Final simplification77.8%
(FPCore (x y z t a)
:precision binary64
(if (<= z -1.5e+103)
t
(if (<= z 2.55e+16)
(fma y (/ t a) x)
(if (<= z 1.14e+92) (* (/ (- x t) z) y) t))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -1.5e+103) {
tmp = t;
} else if (z <= 2.55e+16) {
tmp = fma(y, (t / a), x);
} else if (z <= 1.14e+92) {
tmp = ((x - t) / z) * y;
} else {
tmp = t;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -1.5e+103) tmp = t; elseif (z <= 2.55e+16) tmp = fma(y, Float64(t / a), x); elseif (z <= 1.14e+92) tmp = Float64(Float64(Float64(x - t) / z) * y); else tmp = t; end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -1.5e+103], t, If[LessEqual[z, 2.55e+16], N[(y * N[(t / a), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[z, 1.14e+92], N[(N[(N[(x - t), $MachinePrecision] / z), $MachinePrecision] * y), $MachinePrecision], t]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.5 \cdot 10^{+103}:\\
\;\;\;\;t\\
\mathbf{elif}\;z \leq 2.55 \cdot 10^{+16}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{t}{a}, x\right)\\
\mathbf{elif}\;z \leq 1.14 \cdot 10^{+92}:\\
\;\;\;\;\frac{x - t}{z} \cdot y\\
\mathbf{else}:\\
\;\;\;\;t\\
\end{array}
\end{array}
if z < -1.5e103 or 1.13999999999999993e92 < z Initial program 35.5%
Taylor expanded in z around inf
Applied rewrites50.4%
if -1.5e103 < z < 2.55e16Initial program 89.4%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6490.8
Applied rewrites90.8%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower--.f6471.8
Applied rewrites71.8%
Taylor expanded in x around 0
Applied rewrites55.5%
if 2.55e16 < z < 1.13999999999999993e92Initial program 60.3%
Taylor expanded in z around inf
associate--l+N/A
distribute-lft-out--N/A
div-subN/A
+-commutativeN/A
mul-1-negN/A
distribute-rgt-out--N/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
Applied rewrites77.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
div-subN/A
lower-/.f64N/A
lower--.f6457.0
Applied rewrites57.0%
Final simplification53.5%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -2.8e-51) (not (<= z 2.3e+16))) (fma (/ (- x t) z) y t) (fma y (/ t a) x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -2.8e-51) || !(z <= 2.3e+16)) {
tmp = fma(((x - t) / z), y, t);
} else {
tmp = fma(y, (t / a), x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -2.8e-51) || !(z <= 2.3e+16)) tmp = fma(Float64(Float64(x - t) / z), y, t); else tmp = fma(y, Float64(t / a), x); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -2.8e-51], N[Not[LessEqual[z, 2.3e+16]], $MachinePrecision]], N[(N[(N[(x - t), $MachinePrecision] / z), $MachinePrecision] * y + t), $MachinePrecision], N[(y * N[(t / a), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.8 \cdot 10^{-51} \lor \neg \left(z \leq 2.3 \cdot 10^{+16}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{x - t}{z}, y, t\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{t}{a}, x\right)\\
\end{array}
\end{array}
if z < -2.8e-51 or 2.3e16 < z Initial program 45.3%
Taylor expanded in z around inf
associate--l+N/A
distribute-lft-out--N/A
div-subN/A
+-commutativeN/A
mul-1-negN/A
distribute-rgt-out--N/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
Applied rewrites75.8%
Taylor expanded in a around 0
+-commutativeN/A
associate-/l*N/A
div-subN/A
*-commutativeN/A
lower-fma.f64N/A
div-subN/A
lower-/.f64N/A
lower--.f6468.4
Applied rewrites68.4%
if -2.8e-51 < z < 2.3e16Initial program 91.8%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6491.9
Applied rewrites91.9%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower--.f6478.1
Applied rewrites78.1%
Taylor expanded in x around 0
Applied rewrites59.2%
Final simplification64.5%
(FPCore (x y z t a) :precision binary64 (if (<= z -1.5e+103) t (if (<= z 4.5e+94) (fma y (/ t a) x) t)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -1.5e+103) {
tmp = t;
} else if (z <= 4.5e+94) {
tmp = fma(y, (t / a), x);
} else {
tmp = t;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -1.5e+103) tmp = t; elseif (z <= 4.5e+94) tmp = fma(y, Float64(t / a), x); else tmp = t; end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -1.5e+103], t, If[LessEqual[z, 4.5e+94], N[(y * N[(t / a), $MachinePrecision] + x), $MachinePrecision], t]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.5 \cdot 10^{+103}:\\
\;\;\;\;t\\
\mathbf{elif}\;z \leq 4.5 \cdot 10^{+94}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{t}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\\
\end{array}
\end{array}
if z < -1.5e103 or 4.49999999999999972e94 < z Initial program 34.9%
Taylor expanded in z around inf
Applied rewrites50.7%
if -1.5e103 < z < 4.49999999999999972e94Initial program 85.8%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6489.5
Applied rewrites89.5%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower--.f6465.3
Applied rewrites65.3%
Taylor expanded in x around 0
Applied rewrites51.0%
Final simplification50.9%
(FPCore (x y z t a) :precision binary64 (if (<= z -6.5e+180) t (if (<= z -4.6e-179) (+ x t) (if (<= z 9.6e+26) x t))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -6.5e+180) {
tmp = t;
} else if (z <= -4.6e-179) {
tmp = x + t;
} else if (z <= 9.6e+26) {
tmp = x;
} else {
tmp = t;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: tmp
if (z <= (-6.5d+180)) then
tmp = t
else if (z <= (-4.6d-179)) then
tmp = x + t
else if (z <= 9.6d+26) then
tmp = x
else
tmp = t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -6.5e+180) {
tmp = t;
} else if (z <= -4.6e-179) {
tmp = x + t;
} else if (z <= 9.6e+26) {
tmp = x;
} else {
tmp = t;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if z <= -6.5e+180: tmp = t elif z <= -4.6e-179: tmp = x + t elif z <= 9.6e+26: tmp = x else: tmp = t return tmp
function code(x, y, z, t, a) tmp = 0.0 if (z <= -6.5e+180) tmp = t; elseif (z <= -4.6e-179) tmp = Float64(x + t); elseif (z <= 9.6e+26) tmp = x; else tmp = t; end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (z <= -6.5e+180) tmp = t; elseif (z <= -4.6e-179) tmp = x + t; elseif (z <= 9.6e+26) tmp = x; else tmp = t; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -6.5e+180], t, If[LessEqual[z, -4.6e-179], N[(x + t), $MachinePrecision], If[LessEqual[z, 9.6e+26], x, t]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.5 \cdot 10^{+180}:\\
\;\;\;\;t\\
\mathbf{elif}\;z \leq -4.6 \cdot 10^{-179}:\\
\;\;\;\;x + t\\
\mathbf{elif}\;z \leq 9.6 \cdot 10^{+26}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t\\
\end{array}
\end{array}
if z < -6.5e180 or 9.60000000000000018e26 < z Initial program 38.2%
Taylor expanded in z around inf
Applied rewrites47.5%
if -6.5e180 < z < -4.59999999999999975e-179Initial program 74.6%
Taylor expanded in z around inf
lower--.f6417.4
Applied rewrites17.4%
Taylor expanded in x around 0
Applied rewrites41.2%
if -4.59999999999999975e-179 < z < 9.60000000000000018e26Initial program 90.8%
Taylor expanded in a around inf
Applied rewrites33.4%
Final simplification41.2%
(FPCore (x y z t a) :precision binary64 (if (<= z -450000.0) t (if (<= z 9.6e+26) x t)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -450000.0) {
tmp = t;
} else if (z <= 9.6e+26) {
tmp = x;
} else {
tmp = t;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: tmp
if (z <= (-450000.0d0)) then
tmp = t
else if (z <= 9.6d+26) then
tmp = x
else
tmp = t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -450000.0) {
tmp = t;
} else if (z <= 9.6e+26) {
tmp = x;
} else {
tmp = t;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if z <= -450000.0: tmp = t elif z <= 9.6e+26: tmp = x else: tmp = t return tmp
function code(x, y, z, t, a) tmp = 0.0 if (z <= -450000.0) tmp = t; elseif (z <= 9.6e+26) tmp = x; else tmp = t; end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (z <= -450000.0) tmp = t; elseif (z <= 9.6e+26) tmp = x; else tmp = t; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -450000.0], t, If[LessEqual[z, 9.6e+26], x, t]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -450000:\\
\;\;\;\;t\\
\mathbf{elif}\;z \leq 9.6 \cdot 10^{+26}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t\\
\end{array}
\end{array}
if z < -4.5e5 or 9.60000000000000018e26 < z Initial program 41.8%
Taylor expanded in z around inf
Applied rewrites44.7%
if -4.5e5 < z < 9.60000000000000018e26Initial program 90.4%
Taylor expanded in a around inf
Applied rewrites32.9%
Final simplification39.1%
(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 64.9%
Taylor expanded in z around inf
Applied rewrites26.9%
Final simplification26.9%
(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 2025026
(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))))