
(FPCore (x y z t a) :precision binary64 (+ x (* y (/ (- z t) (- z a)))))
double code(double x, double y, double z, double t, double a) {
return x + (y * ((z - t) / (z - a)));
}
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) / (z - a)))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + (y * ((z - t) / (z - a)));
}
def code(x, y, z, t, a): return x + (y * ((z - t) / (z - a)))
function code(x, y, z, t, a) return Float64(x + Float64(y * Float64(Float64(z - t) / Float64(z - a)))) end
function tmp = code(x, y, z, t, a) tmp = x + (y * ((z - t) / (z - a))); end
code[x_, y_, z_, t_, a_] := N[(x + N[(y * N[(N[(z - t), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + y \cdot \frac{z - t}{z - a}
\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) (- z a)))))
double code(double x, double y, double z, double t, double a) {
return x + (y * ((z - t) / (z - a)));
}
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) / (z - a)))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + (y * ((z - t) / (z - a)));
}
def code(x, y, z, t, a): return x + (y * ((z - t) / (z - a)))
function code(x, y, z, t, a) return Float64(x + Float64(y * Float64(Float64(z - t) / Float64(z - a)))) end
function tmp = code(x, y, z, t, a) tmp = x + (y * ((z - t) / (z - a))); end
code[x_, y_, z_, t_, a_] := N[(x + N[(y * N[(N[(z - t), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + y \cdot \frac{z - t}{z - a}
\end{array}
(FPCore (x y z t a) :precision binary64 (+ x (* y (/ (- z t) (- z a)))))
double code(double x, double y, double z, double t, double a) {
return x + (y * ((z - t) / (z - a)));
}
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) / (z - a)))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + (y * ((z - t) / (z - a)));
}
def code(x, y, z, t, a): return x + (y * ((z - t) / (z - a)))
function code(x, y, z, t, a) return Float64(x + Float64(y * Float64(Float64(z - t) / Float64(z - a)))) end
function tmp = code(x, y, z, t, a) tmp = x + (y * ((z - t) / (z - a))); end
code[x_, y_, z_, t_, a_] := N[(x + N[(y * N[(N[(z - t), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + y \cdot \frac{z - t}{z - a}
\end{array}
Initial program 98.4%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (/ (- z t) (- z a))) (t_2 (/ y (- z a))))
(if (<= t_1 -5e+108)
(* t_2 (- t))
(if (<= t_1 1e-8)
(- x (/ (* (- z t) y) a))
(if (<= t_1 5e+138) (fma (/ (- z t) z) y x) (* (- z t) t_2))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (z - t) / (z - a);
double t_2 = y / (z - a);
double tmp;
if (t_1 <= -5e+108) {
tmp = t_2 * -t;
} else if (t_1 <= 1e-8) {
tmp = x - (((z - t) * y) / a);
} else if (t_1 <= 5e+138) {
tmp = fma(((z - t) / z), y, x);
} else {
tmp = (z - t) * t_2;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(Float64(z - t) / Float64(z - a)) t_2 = Float64(y / Float64(z - a)) tmp = 0.0 if (t_1 <= -5e+108) tmp = Float64(t_2 * Float64(-t)); elseif (t_1 <= 1e-8) tmp = Float64(x - Float64(Float64(Float64(z - t) * y) / a)); elseif (t_1 <= 5e+138) tmp = fma(Float64(Float64(z - t) / z), y, x); else tmp = Float64(Float64(z - t) * t_2); end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(z - t), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(y / N[(z - a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+108], N[(t$95$2 * (-t)), $MachinePrecision], If[LessEqual[t$95$1, 1e-8], N[(x - N[(N[(N[(z - t), $MachinePrecision] * y), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e+138], N[(N[(N[(z - t), $MachinePrecision] / z), $MachinePrecision] * y + x), $MachinePrecision], N[(N[(z - t), $MachinePrecision] * t$95$2), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{z - t}{z - a}\\
t_2 := \frac{y}{z - a}\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+108}:\\
\;\;\;\;t\_2 \cdot \left(-t\right)\\
\mathbf{elif}\;t\_1 \leq 10^{-8}:\\
\;\;\;\;x - \frac{\left(z - t\right) \cdot y}{a}\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+138}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z - t}{z}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(z - t\right) \cdot t\_2\\
\end{array}
\end{array}
if (/.f64 (-.f64 z t) (-.f64 z a)) < -4.99999999999999991e108Initial program 90.4%
Taylor expanded in t around inf
Applied rewrites99.9%
Taylor expanded in t around inf
Applied rewrites90.3%
if -4.99999999999999991e108 < (/.f64 (-.f64 z t) (-.f64 z a)) < 1e-8Initial program 99.8%
Taylor expanded in t around inf
Applied rewrites89.2%
Taylor expanded in a around inf
Applied rewrites89.8%
if 1e-8 < (/.f64 (-.f64 z t) (-.f64 z a)) < 5.00000000000000016e138Initial program 100.0%
Taylor expanded in a around 0
Applied rewrites96.3%
if 5.00000000000000016e138 < (/.f64 (-.f64 z t) (-.f64 z a)) Initial program 93.6%
Taylor expanded in x around 0
Applied rewrites93.5%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (/ (- z t) (- z a))) (t_2 (/ y (- z a))))
(if (<= t_1 -1e+106)
(* t_2 (- t))
(if (<= t_1 1e-8)
(+ x (* y (/ t a)))
(if (<= t_1 5e+138) (fma (/ (- z t) z) y x) (* (- z t) t_2))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (z - t) / (z - a);
double t_2 = y / (z - a);
double tmp;
if (t_1 <= -1e+106) {
tmp = t_2 * -t;
} else if (t_1 <= 1e-8) {
tmp = x + (y * (t / a));
} else if (t_1 <= 5e+138) {
tmp = fma(((z - t) / z), y, x);
} else {
tmp = (z - t) * t_2;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(Float64(z - t) / Float64(z - a)) t_2 = Float64(y / Float64(z - a)) tmp = 0.0 if (t_1 <= -1e+106) tmp = Float64(t_2 * Float64(-t)); elseif (t_1 <= 1e-8) tmp = Float64(x + Float64(y * Float64(t / a))); elseif (t_1 <= 5e+138) tmp = fma(Float64(Float64(z - t) / z), y, x); else tmp = Float64(Float64(z - t) * t_2); end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(z - t), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(y / N[(z - a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -1e+106], N[(t$95$2 * (-t)), $MachinePrecision], If[LessEqual[t$95$1, 1e-8], N[(x + N[(y * N[(t / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e+138], N[(N[(N[(z - t), $MachinePrecision] / z), $MachinePrecision] * y + x), $MachinePrecision], N[(N[(z - t), $MachinePrecision] * t$95$2), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{z - t}{z - a}\\
t_2 := \frac{y}{z - a}\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+106}:\\
\;\;\;\;t\_2 \cdot \left(-t\right)\\
\mathbf{elif}\;t\_1 \leq 10^{-8}:\\
\;\;\;\;x + y \cdot \frac{t}{a}\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+138}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z - t}{z}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(z - t\right) \cdot t\_2\\
\end{array}
\end{array}
if (/.f64 (-.f64 z t) (-.f64 z a)) < -1.00000000000000009e106Initial program 90.6%
Taylor expanded in t around inf
Applied rewrites99.9%
Taylor expanded in t around inf
Applied rewrites90.6%
if -1.00000000000000009e106 < (/.f64 (-.f64 z t) (-.f64 z a)) < 1e-8Initial program 99.9%
Taylor expanded in z around 0
Applied rewrites86.2%
if 1e-8 < (/.f64 (-.f64 z t) (-.f64 z a)) < 5.00000000000000016e138Initial program 100.0%
Taylor expanded in a around 0
Applied rewrites96.3%
if 5.00000000000000016e138 < (/.f64 (-.f64 z t) (-.f64 z a)) Initial program 93.6%
Taylor expanded in x around 0
Applied rewrites93.5%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (/ (- z t) (- z a))) (t_2 (* (/ y (- z a)) (- t))))
(if (<= t_1 -1e+106)
t_2
(if (<= t_1 1e-8)
(+ x (* y (/ t a)))
(if (<= t_1 5e+138) (fma (/ (- z t) z) y x) t_2)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (z - t) / (z - a);
double t_2 = (y / (z - a)) * -t;
double tmp;
if (t_1 <= -1e+106) {
tmp = t_2;
} else if (t_1 <= 1e-8) {
tmp = x + (y * (t / a));
} else if (t_1 <= 5e+138) {
tmp = fma(((z - t) / z), y, x);
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(Float64(z - t) / Float64(z - a)) t_2 = Float64(Float64(y / Float64(z - a)) * Float64(-t)) tmp = 0.0 if (t_1 <= -1e+106) tmp = t_2; elseif (t_1 <= 1e-8) tmp = Float64(x + Float64(y * Float64(t / a))); elseif (t_1 <= 5e+138) tmp = fma(Float64(Float64(z - t) / z), y, x); else tmp = t_2; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(z - t), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(y / N[(z - a), $MachinePrecision]), $MachinePrecision] * (-t)), $MachinePrecision]}, If[LessEqual[t$95$1, -1e+106], t$95$2, If[LessEqual[t$95$1, 1e-8], N[(x + N[(y * N[(t / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e+138], N[(N[(N[(z - t), $MachinePrecision] / z), $MachinePrecision] * y + x), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{z - t}{z - a}\\
t_2 := \frac{y}{z - a} \cdot \left(-t\right)\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+106}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 10^{-8}:\\
\;\;\;\;x + y \cdot \frac{t}{a}\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+138}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z - t}{z}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (/.f64 (-.f64 z t) (-.f64 z a)) < -1.00000000000000009e106 or 5.00000000000000016e138 < (/.f64 (-.f64 z t) (-.f64 z a)) Initial program 91.6%
Taylor expanded in t around inf
Applied rewrites99.9%
Taylor expanded in t around inf
Applied rewrites91.5%
if -1.00000000000000009e106 < (/.f64 (-.f64 z t) (-.f64 z a)) < 1e-8Initial program 99.9%
Taylor expanded in z around 0
Applied rewrites86.2%
if 1e-8 < (/.f64 (-.f64 z t) (-.f64 z a)) < 5.00000000000000016e138Initial program 100.0%
Taylor expanded in a around 0
Applied rewrites96.3%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (/ (- z t) (- z a))))
(if (<= t_1 -5e+24)
(/ (* t y) a)
(if (<= t_1 1e-36) x (if (<= t_1 5e+138) (+ x y) (* (/ y a) t))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (z - t) / (z - a);
double tmp;
if (t_1 <= -5e+24) {
tmp = (t * y) / a;
} else if (t_1 <= 1e-36) {
tmp = x;
} else if (t_1 <= 5e+138) {
tmp = x + y;
} else {
tmp = (y / a) * t;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: t_1
real(8) :: tmp
t_1 = (z - t) / (z - a)
if (t_1 <= (-5d+24)) then
tmp = (t * y) / a
else if (t_1 <= 1d-36) then
tmp = x
else if (t_1 <= 5d+138) then
tmp = x + y
else
tmp = (y / a) * t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double t_1 = (z - t) / (z - a);
double tmp;
if (t_1 <= -5e+24) {
tmp = (t * y) / a;
} else if (t_1 <= 1e-36) {
tmp = x;
} else if (t_1 <= 5e+138) {
tmp = x + y;
} else {
tmp = (y / a) * t;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = (z - t) / (z - a) tmp = 0 if t_1 <= -5e+24: tmp = (t * y) / a elif t_1 <= 1e-36: tmp = x elif t_1 <= 5e+138: tmp = x + y else: tmp = (y / a) * t return tmp
function code(x, y, z, t, a) t_1 = Float64(Float64(z - t) / Float64(z - a)) tmp = 0.0 if (t_1 <= -5e+24) tmp = Float64(Float64(t * y) / a); elseif (t_1 <= 1e-36) tmp = x; elseif (t_1 <= 5e+138) tmp = Float64(x + y); else tmp = Float64(Float64(y / a) * t); end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = (z - t) / (z - a); tmp = 0.0; if (t_1 <= -5e+24) tmp = (t * y) / a; elseif (t_1 <= 1e-36) tmp = x; elseif (t_1 <= 5e+138) tmp = x + y; else tmp = (y / a) * t; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(z - t), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+24], N[(N[(t * y), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[t$95$1, 1e-36], x, If[LessEqual[t$95$1, 5e+138], N[(x + y), $MachinePrecision], N[(N[(y / a), $MachinePrecision] * t), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{z - t}{z - a}\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+24}:\\
\;\;\;\;\frac{t \cdot y}{a}\\
\mathbf{elif}\;t\_1 \leq 10^{-36}:\\
\;\;\;\;x\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+138}:\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{a} \cdot t\\
\end{array}
\end{array}
if (/.f64 (-.f64 z t) (-.f64 z a)) < -5.00000000000000045e24Initial program 93.2%
Taylor expanded in t around inf
Applied rewrites97.7%
Taylor expanded in a around inf
Applied rewrites73.3%
Taylor expanded in t around inf
Applied rewrites60.6%
if -5.00000000000000045e24 < (/.f64 (-.f64 z t) (-.f64 z a)) < 9.9999999999999994e-37Initial program 99.9%
Taylor expanded in x around inf
Applied rewrites71.7%
if 9.9999999999999994e-37 < (/.f64 (-.f64 z t) (-.f64 z a)) < 5.00000000000000016e138Initial program 99.9%
Taylor expanded in z around inf
Applied rewrites90.0%
if 5.00000000000000016e138 < (/.f64 (-.f64 z t) (-.f64 z a)) Initial program 93.6%
Taylor expanded in z around 0
Applied rewrites87.0%
Taylor expanded in x around 0
Applied rewrites80.8%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (/ (- z t) (- z a))) (t_2 (* (/ y a) t)))
(if (<= t_1 -5e+24)
t_2
(if (<= t_1 1e-36) x (if (<= t_1 5e+138) (+ x y) t_2)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (z - t) / (z - a);
double t_2 = (y / a) * t;
double tmp;
if (t_1 <= -5e+24) {
tmp = t_2;
} else if (t_1 <= 1e-36) {
tmp = x;
} else if (t_1 <= 5e+138) {
tmp = x + y;
} else {
tmp = t_2;
}
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) :: t_2
real(8) :: tmp
t_1 = (z - t) / (z - a)
t_2 = (y / a) * t
if (t_1 <= (-5d+24)) then
tmp = t_2
else if (t_1 <= 1d-36) then
tmp = x
else if (t_1 <= 5d+138) then
tmp = x + y
else
tmp = t_2
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double t_1 = (z - t) / (z - a);
double t_2 = (y / a) * t;
double tmp;
if (t_1 <= -5e+24) {
tmp = t_2;
} else if (t_1 <= 1e-36) {
tmp = x;
} else if (t_1 <= 5e+138) {
tmp = x + y;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = (z - t) / (z - a) t_2 = (y / a) * t tmp = 0 if t_1 <= -5e+24: tmp = t_2 elif t_1 <= 1e-36: tmp = x elif t_1 <= 5e+138: tmp = x + y else: tmp = t_2 return tmp
function code(x, y, z, t, a) t_1 = Float64(Float64(z - t) / Float64(z - a)) t_2 = Float64(Float64(y / a) * t) tmp = 0.0 if (t_1 <= -5e+24) tmp = t_2; elseif (t_1 <= 1e-36) tmp = x; elseif (t_1 <= 5e+138) tmp = Float64(x + y); else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = (z - t) / (z - a); t_2 = (y / a) * t; tmp = 0.0; if (t_1 <= -5e+24) tmp = t_2; elseif (t_1 <= 1e-36) tmp = x; elseif (t_1 <= 5e+138) tmp = x + y; else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(z - t), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(y / a), $MachinePrecision] * t), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+24], t$95$2, If[LessEqual[t$95$1, 1e-36], x, If[LessEqual[t$95$1, 5e+138], N[(x + y), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{z - t}{z - a}\\
t_2 := \frac{y}{a} \cdot t\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+24}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 10^{-36}:\\
\;\;\;\;x\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+138}:\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (/.f64 (-.f64 z t) (-.f64 z a)) < -5.00000000000000045e24 or 5.00000000000000016e138 < (/.f64 (-.f64 z t) (-.f64 z a)) Initial program 93.3%
Taylor expanded in z around 0
Applied rewrites76.9%
Taylor expanded in x around 0
Applied rewrites65.8%
if -5.00000000000000045e24 < (/.f64 (-.f64 z t) (-.f64 z a)) < 9.9999999999999994e-37Initial program 99.9%
Taylor expanded in x around inf
Applied rewrites71.7%
if 9.9999999999999994e-37 < (/.f64 (-.f64 z t) (-.f64 z a)) < 5.00000000000000016e138Initial program 99.9%
Taylor expanded in z around inf
Applied rewrites90.0%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (/ (- z t) (- z a))) (t_2 (* y (/ t a))))
(if (<= t_1 -5e+24)
t_2
(if (<= t_1 1e-36) x (if (<= t_1 5e+138) (+ x y) t_2)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (z - t) / (z - a);
double t_2 = y * (t / a);
double tmp;
if (t_1 <= -5e+24) {
tmp = t_2;
} else if (t_1 <= 1e-36) {
tmp = x;
} else if (t_1 <= 5e+138) {
tmp = x + y;
} else {
tmp = t_2;
}
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) :: t_2
real(8) :: tmp
t_1 = (z - t) / (z - a)
t_2 = y * (t / a)
if (t_1 <= (-5d+24)) then
tmp = t_2
else if (t_1 <= 1d-36) then
tmp = x
else if (t_1 <= 5d+138) then
tmp = x + y
else
tmp = t_2
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double t_1 = (z - t) / (z - a);
double t_2 = y * (t / a);
double tmp;
if (t_1 <= -5e+24) {
tmp = t_2;
} else if (t_1 <= 1e-36) {
tmp = x;
} else if (t_1 <= 5e+138) {
tmp = x + y;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = (z - t) / (z - a) t_2 = y * (t / a) tmp = 0 if t_1 <= -5e+24: tmp = t_2 elif t_1 <= 1e-36: tmp = x elif t_1 <= 5e+138: tmp = x + y else: tmp = t_2 return tmp
function code(x, y, z, t, a) t_1 = Float64(Float64(z - t) / Float64(z - a)) t_2 = Float64(y * Float64(t / a)) tmp = 0.0 if (t_1 <= -5e+24) tmp = t_2; elseif (t_1 <= 1e-36) tmp = x; elseif (t_1 <= 5e+138) tmp = Float64(x + y); else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = (z - t) / (z - a); t_2 = y * (t / a); tmp = 0.0; if (t_1 <= -5e+24) tmp = t_2; elseif (t_1 <= 1e-36) tmp = x; elseif (t_1 <= 5e+138) tmp = x + y; else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(z - t), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(y * N[(t / a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+24], t$95$2, If[LessEqual[t$95$1, 1e-36], x, If[LessEqual[t$95$1, 5e+138], N[(x + y), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{z - t}{z - a}\\
t_2 := y \cdot \frac{t}{a}\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+24}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 10^{-36}:\\
\;\;\;\;x\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+138}:\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (/.f64 (-.f64 z t) (-.f64 z a)) < -5.00000000000000045e24 or 5.00000000000000016e138 < (/.f64 (-.f64 z t) (-.f64 z a)) Initial program 93.3%
Taylor expanded in z around 0
Applied rewrites76.9%
Taylor expanded in x around 0
Applied rewrites65.8%
Applied rewrites61.5%
if -5.00000000000000045e24 < (/.f64 (-.f64 z t) (-.f64 z a)) < 9.9999999999999994e-37Initial program 99.9%
Taylor expanded in x around inf
Applied rewrites71.7%
if 9.9999999999999994e-37 < (/.f64 (-.f64 z t) (-.f64 z a)) < 5.00000000000000016e138Initial program 99.9%
Taylor expanded in z around inf
Applied rewrites90.0%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (/ (- z t) (- z a)))) (if (or (<= t_1 1e-8) (not (<= t_1 5e+60))) (fma (/ y a) t x) (+ x y))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (z - t) / (z - a);
double tmp;
if ((t_1 <= 1e-8) || !(t_1 <= 5e+60)) {
tmp = fma((y / a), t, x);
} else {
tmp = x + y;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(Float64(z - t) / Float64(z - a)) tmp = 0.0 if ((t_1 <= 1e-8) || !(t_1 <= 5e+60)) tmp = fma(Float64(y / a), t, x); else tmp = Float64(x + y); end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(z - t), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, 1e-8], N[Not[LessEqual[t$95$1, 5e+60]], $MachinePrecision]], N[(N[(y / a), $MachinePrecision] * t + x), $MachinePrecision], N[(x + y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{z - t}{z - a}\\
\mathbf{if}\;t\_1 \leq 10^{-8} \lor \neg \left(t\_1 \leq 5 \cdot 10^{+60}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a}, t, x\right)\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if (/.f64 (-.f64 z t) (-.f64 z a)) < 1e-8 or 4.99999999999999975e60 < (/.f64 (-.f64 z t) (-.f64 z a)) Initial program 97.4%
Taylor expanded in z around 0
Applied rewrites80.8%
if 1e-8 < (/.f64 (-.f64 z t) (-.f64 z a)) < 4.99999999999999975e60Initial program 100.0%
Taylor expanded in z around inf
Applied rewrites95.4%
Final simplification86.7%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -8e-26) (not (<= z 3.9e+42))) (fma (/ z (- z a)) y x) (+ x (/ (* t y) a))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -8e-26) || !(z <= 3.9e+42)) {
tmp = fma((z / (z - a)), y, x);
} else {
tmp = x + ((t * y) / a);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -8e-26) || !(z <= 3.9e+42)) tmp = fma(Float64(z / Float64(z - a)), y, x); else tmp = Float64(x + Float64(Float64(t * y) / a)); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -8e-26], N[Not[LessEqual[z, 3.9e+42]], $MachinePrecision]], N[(N[(z / N[(z - a), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision], N[(x + N[(N[(t * y), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8 \cdot 10^{-26} \lor \neg \left(z \leq 3.9 \cdot 10^{+42}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{z - a}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;x + \frac{t \cdot y}{a}\\
\end{array}
\end{array}
if z < -8.0000000000000003e-26 or 3.8999999999999997e42 < z Initial program 99.9%
Taylor expanded in t around 0
Applied rewrites88.5%
if -8.0000000000000003e-26 < z < 3.8999999999999997e42Initial program 96.7%
Taylor expanded in z around 0
Applied rewrites88.0%
Final simplification88.2%
(FPCore (x y z t a) :precision binary64 (if (<= z -8e-26) (fma (/ z (- z a)) y x) (if (<= z 3.9e+42) (+ x (/ (* t y) a)) (fma (/ (- z t) z) y x))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -8e-26) {
tmp = fma((z / (z - a)), y, x);
} else if (z <= 3.9e+42) {
tmp = x + ((t * y) / a);
} else {
tmp = fma(((z - t) / z), y, x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -8e-26) tmp = fma(Float64(z / Float64(z - a)), y, x); elseif (z <= 3.9e+42) tmp = Float64(x + Float64(Float64(t * y) / a)); else tmp = fma(Float64(Float64(z - t) / z), y, x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -8e-26], N[(N[(z / N[(z - a), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision], If[LessEqual[z, 3.9e+42], N[(x + N[(N[(t * y), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(N[(z - t), $MachinePrecision] / z), $MachinePrecision] * y + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8 \cdot 10^{-26}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{z - a}, y, x\right)\\
\mathbf{elif}\;z \leq 3.9 \cdot 10^{+42}:\\
\;\;\;\;x + \frac{t \cdot y}{a}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z - t}{z}, y, x\right)\\
\end{array}
\end{array}
if z < -8.0000000000000003e-26Initial program 99.9%
Taylor expanded in t around 0
Applied rewrites89.3%
if -8.0000000000000003e-26 < z < 3.8999999999999997e42Initial program 96.7%
Taylor expanded in z around 0
Applied rewrites88.0%
if 3.8999999999999997e42 < z Initial program 100.0%
Taylor expanded in a around 0
Applied rewrites90.4%
(FPCore (x y z t a) :precision binary64 (if (<= (/ (- z t) (- z a)) 1.45e-36) x (+ x y)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (((z - t) / (z - a)) <= 1.45e-36) {
tmp = x;
} else {
tmp = x + y;
}
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 - t) / (z - a)) <= 1.45d-36) then
tmp = x
else
tmp = x + y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (((z - t) / (z - a)) <= 1.45e-36) {
tmp = x;
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if ((z - t) / (z - a)) <= 1.45e-36: tmp = x else: tmp = x + y return tmp
function code(x, y, z, t, a) tmp = 0.0 if (Float64(Float64(z - t) / Float64(z - a)) <= 1.45e-36) tmp = x; else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (((z - t) / (z - a)) <= 1.45e-36) tmp = x; else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[N[(N[(z - t), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision], 1.45e-36], x, N[(x + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{z - t}{z - a} \leq 1.45 \cdot 10^{-36}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if (/.f64 (-.f64 z t) (-.f64 z a)) < 1.45000000000000006e-36Initial program 97.5%
Taylor expanded in x around inf
Applied rewrites52.3%
if 1.45000000000000006e-36 < (/.f64 (-.f64 z t) (-.f64 z a)) Initial program 99.3%
Taylor expanded in z around inf
Applied rewrites81.4%
(FPCore (x y z t a) :precision binary64 (if (or (<= x -4.5e-108) (not (<= x 1.6e-184))) x y))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x <= -4.5e-108) || !(x <= 1.6e-184)) {
tmp = x;
} else {
tmp = y;
}
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 ((x <= (-4.5d-108)) .or. (.not. (x <= 1.6d-184))) then
tmp = x
else
tmp = y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x <= -4.5e-108) || !(x <= 1.6e-184)) {
tmp = x;
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (x <= -4.5e-108) or not (x <= 1.6e-184): tmp = x else: tmp = y return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((x <= -4.5e-108) || !(x <= 1.6e-184)) tmp = x; else tmp = y; end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((x <= -4.5e-108) || ~((x <= 1.6e-184))) tmp = x; else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[x, -4.5e-108], N[Not[LessEqual[x, 1.6e-184]], $MachinePrecision]], x, y]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.5 \cdot 10^{-108} \lor \neg \left(x \leq 1.6 \cdot 10^{-184}\right):\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if x < -4.4999999999999997e-108 or 1.6e-184 < x Initial program 98.4%
Taylor expanded in x around inf
Applied rewrites63.4%
if -4.4999999999999997e-108 < x < 1.6e-184Initial program 98.5%
Taylor expanded in a around 0
Applied rewrites55.5%
Taylor expanded in x around 0
Applied rewrites49.9%
Taylor expanded in z around inf
Applied rewrites38.3%
Final simplification55.7%
(FPCore (x y z t a) :precision binary64 x)
double code(double x, double y, double z, double t, double a) {
return x;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = x
end function
public static double code(double x, double y, double z, double t, double a) {
return x;
}
def code(x, y, z, t, a): return x
function code(x, y, z, t, a) return x end
function tmp = code(x, y, z, t, a) tmp = x; end
code[x_, y_, z_, t_, a_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 98.4%
Taylor expanded in x around inf
Applied rewrites49.5%
(FPCore (x y z t a) :precision binary64 (+ x (/ y (/ (- z a) (- z t)))))
double code(double x, double y, double z, double t, double a) {
return x + (y / ((z - a) / (z - t)));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = x + (y / ((z - a) / (z - t)))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + (y / ((z - a) / (z - t)));
}
def code(x, y, z, t, a): return x + (y / ((z - a) / (z - t)))
function code(x, y, z, t, a) return Float64(x + Float64(y / Float64(Float64(z - a) / Float64(z - t)))) end
function tmp = code(x, y, z, t, a) tmp = x + (y / ((z - a) / (z - t))); end
code[x_, y_, z_, t_, a_] := N[(x + N[(y / N[(N[(z - a), $MachinePrecision] / N[(z - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y}{\frac{z - a}{z - t}}
\end{array}
herbie shell --seed 2025018
(FPCore (x y z t a)
:name "Graphics.Rendering.Plot.Render.Plot.Axis:renderAxisLine from plot-0.2.3.4, A"
:precision binary64
:alt
(! :herbie-platform default (+ x (/ y (/ (- z a) (- z t)))))
(+ x (* y (/ (- z t) (- z a)))))