
(FPCore (x y z t a) :precision binary64 (- x (/ (- y z) (/ (+ (- t z) 1.0) a))))
double code(double x, double y, double z, double t, double a) {
return x - ((y - z) / (((t - z) + 1.0) / 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) + 1.0d0) / a))
end function
public static double code(double x, double y, double z, double t, double a) {
return x - ((y - z) / (((t - z) + 1.0) / a));
}
def code(x, y, z, t, a): return x - ((y - z) / (((t - z) + 1.0) / a))
function code(x, y, z, t, a) return Float64(x - Float64(Float64(y - z) / Float64(Float64(Float64(t - z) + 1.0) / a))) end
function tmp = code(x, y, z, t, a) tmp = x - ((y - z) / (((t - z) + 1.0) / a)); end
code[x_, y_, z_, t_, a_] := N[(x - N[(N[(y - z), $MachinePrecision] / N[(N[(N[(t - z), $MachinePrecision] + 1.0), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \frac{y - z}{\frac{\left(t - z\right) + 1}{a}}
\end{array}
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a) :precision binary64 (- x (/ (- y z) (/ (+ (- t z) 1.0) a))))
double code(double x, double y, double z, double t, double a) {
return x - ((y - z) / (((t - z) + 1.0) / 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) + 1.0d0) / a))
end function
public static double code(double x, double y, double z, double t, double a) {
return x - ((y - z) / (((t - z) + 1.0) / a));
}
def code(x, y, z, t, a): return x - ((y - z) / (((t - z) + 1.0) / a))
function code(x, y, z, t, a) return Float64(x - Float64(Float64(y - z) / Float64(Float64(Float64(t - z) + 1.0) / a))) end
function tmp = code(x, y, z, t, a) tmp = x - ((y - z) / (((t - z) + 1.0) / a)); end
code[x_, y_, z_, t_, a_] := N[(x - N[(N[(y - z), $MachinePrecision] / N[(N[(N[(t - z), $MachinePrecision] + 1.0), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \frac{y - z}{\frac{\left(t - z\right) + 1}{a}}
\end{array}
(FPCore (x y z t a) :precision binary64 (fma (/ (- z y) (- (+ 1.0 t) z)) a x))
double code(double x, double y, double z, double t, double a) {
return fma(((z - y) / ((1.0 + t) - z)), a, x);
}
function code(x, y, z, t, a) return fma(Float64(Float64(z - y) / Float64(Float64(1.0 + t) - z)), a, x) end
code[x_, y_, z_, t_, a_] := N[(N[(N[(z - y), $MachinePrecision] / N[(N[(1.0 + t), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] * a + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{z - y}{\left(1 + t\right) - z}, a, x\right)
\end{array}
Initial program 97.2%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-divN/A
lower-/.f64N/A
lower--.f64N/A
lower--.f64N/A
lower-+.f6499.6
Applied rewrites99.6%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (fma (/ (- z y) (- t z)) a x))) (if (<= z -1.0) t_1 (if (<= z 0.75) (fma (/ (- z y) (+ 1.0 t)) a x) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma(((z - y) / (t - z)), a, x);
double tmp;
if (z <= -1.0) {
tmp = t_1;
} else if (z <= 0.75) {
tmp = fma(((z - y) / (1.0 + t)), a, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(Float64(z - y) / Float64(t - z)), a, x) tmp = 0.0 if (z <= -1.0) tmp = t_1; elseif (z <= 0.75) tmp = fma(Float64(Float64(z - y) / Float64(1.0 + t)), a, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(N[(z - y), $MachinePrecision] / N[(t - z), $MachinePrecision]), $MachinePrecision] * a + x), $MachinePrecision]}, If[LessEqual[z, -1.0], t$95$1, If[LessEqual[z, 0.75], N[(N[(N[(z - y), $MachinePrecision] / N[(1.0 + t), $MachinePrecision]), $MachinePrecision] * a + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{z - y}{t - z}, a, x\right)\\
\mathbf{if}\;z \leq -1:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 0.75:\\
\;\;\;\;\mathsf{fma}\left(\frac{z - y}{1 + t}, a, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -1 or 0.75 < z Initial program 95.2%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-divN/A
lower-/.f64N/A
lower--.f64N/A
lower--.f64N/A
lower-+.f6499.9
Applied rewrites99.9%
Taylor expanded in t around inf
Applied rewrites99.3%
if -1 < z < 0.75Initial program 99.2%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-divN/A
lower-/.f64N/A
lower--.f64N/A
lower--.f64N/A
lower-+.f6499.3
Applied rewrites99.3%
Taylor expanded in z around 0
lift-+.f6498.9
Applied rewrites98.9%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma (/ (- z y) (- z)) a x)))
(if (<= z -8.5e+16)
t_1
(if (<= z 5.8e+36) (fma (/ (- z y) (+ 1.0 t)) a x) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma(((z - y) / -z), a, x);
double tmp;
if (z <= -8.5e+16) {
tmp = t_1;
} else if (z <= 5.8e+36) {
tmp = fma(((z - y) / (1.0 + t)), a, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(Float64(z - y) / Float64(-z)), a, x) tmp = 0.0 if (z <= -8.5e+16) tmp = t_1; elseif (z <= 5.8e+36) tmp = fma(Float64(Float64(z - y) / Float64(1.0 + t)), a, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(N[(z - y), $MachinePrecision] / (-z)), $MachinePrecision] * a + x), $MachinePrecision]}, If[LessEqual[z, -8.5e+16], t$95$1, If[LessEqual[z, 5.8e+36], N[(N[(N[(z - y), $MachinePrecision] / N[(1.0 + t), $MachinePrecision]), $MachinePrecision] * a + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{z - y}{-z}, a, x\right)\\
\mathbf{if}\;z \leq -8.5 \cdot 10^{+16}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 5.8 \cdot 10^{+36}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z - y}{1 + t}, a, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -8.5e16 or 5.8e36 < z Initial program 94.9%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-divN/A
lower-/.f64N/A
lower--.f64N/A
lower--.f64N/A
lower-+.f6499.9
Applied rewrites99.9%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6487.2
Applied rewrites87.2%
if -8.5e16 < z < 5.8e36Initial program 99.1%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-divN/A
lower-/.f64N/A
lower--.f64N/A
lower--.f64N/A
lower-+.f6499.4
Applied rewrites99.4%
Taylor expanded in z around 0
lift-+.f6496.7
Applied rewrites96.7%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma (/ (- z y) (- z)) a x)))
(if (<= z -8.5e+16)
t_1
(if (<= z 3.4e+23) (- x (* a (/ y (+ 1.0 t)))) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma(((z - y) / -z), a, x);
double tmp;
if (z <= -8.5e+16) {
tmp = t_1;
} else if (z <= 3.4e+23) {
tmp = x - (a * (y / (1.0 + t)));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(Float64(z - y) / Float64(-z)), a, x) tmp = 0.0 if (z <= -8.5e+16) tmp = t_1; elseif (z <= 3.4e+23) tmp = Float64(x - Float64(a * Float64(y / Float64(1.0 + t)))); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(N[(z - y), $MachinePrecision] / (-z)), $MachinePrecision] * a + x), $MachinePrecision]}, If[LessEqual[z, -8.5e+16], t$95$1, If[LessEqual[z, 3.4e+23], N[(x - N[(a * N[(y / N[(1.0 + t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{z - y}{-z}, a, x\right)\\
\mathbf{if}\;z \leq -8.5 \cdot 10^{+16}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 3.4 \cdot 10^{+23}:\\
\;\;\;\;x - a \cdot \frac{y}{1 + t}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -8.5e16 or 3.39999999999999992e23 < z Initial program 94.9%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-divN/A
lower-/.f64N/A
lower--.f64N/A
lower--.f64N/A
lower-+.f6499.9
Applied rewrites99.9%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6486.7
Applied rewrites86.7%
if -8.5e16 < z < 3.39999999999999992e23Initial program 99.2%
Taylor expanded in z around 0
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lower-+.f6491.2
Applied rewrites91.2%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (fma (/ (- z y) (- z)) a x))) (if (<= z -7.2e+16) t_1 (if (<= z 9.5e+32) (fma (/ (- z y) t) a x) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma(((z - y) / -z), a, x);
double tmp;
if (z <= -7.2e+16) {
tmp = t_1;
} else if (z <= 9.5e+32) {
tmp = fma(((z - y) / t), a, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(Float64(z - y) / Float64(-z)), a, x) tmp = 0.0 if (z <= -7.2e+16) tmp = t_1; elseif (z <= 9.5e+32) tmp = fma(Float64(Float64(z - y) / t), a, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(N[(z - y), $MachinePrecision] / (-z)), $MachinePrecision] * a + x), $MachinePrecision]}, If[LessEqual[z, -7.2e+16], t$95$1, If[LessEqual[z, 9.5e+32], N[(N[(N[(z - y), $MachinePrecision] / t), $MachinePrecision] * a + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{z - y}{-z}, a, x\right)\\
\mathbf{if}\;z \leq -7.2 \cdot 10^{+16}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 9.5 \cdot 10^{+32}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z - y}{t}, a, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -7.2e16 or 9.50000000000000006e32 < z Initial program 94.9%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-divN/A
lower-/.f64N/A
lower--.f64N/A
lower--.f64N/A
lower-+.f6499.9
Applied rewrites99.9%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6487.0
Applied rewrites87.0%
if -7.2e16 < z < 9.50000000000000006e32Initial program 99.1%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-divN/A
lower-/.f64N/A
lower--.f64N/A
lower--.f64N/A
lower-+.f6499.4
Applied rewrites99.4%
Taylor expanded in t around inf
Applied rewrites65.8%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (fma (/ z (- t z)) a x))) (if (<= z -1.35e+16) t_1 (if (<= z 4.9e-26) (fma (/ (- z y) t) a x) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma((z / (t - z)), a, x);
double tmp;
if (z <= -1.35e+16) {
tmp = t_1;
} else if (z <= 4.9e-26) {
tmp = fma(((z - y) / t), a, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(z / Float64(t - z)), a, x) tmp = 0.0 if (z <= -1.35e+16) tmp = t_1; elseif (z <= 4.9e-26) tmp = fma(Float64(Float64(z - y) / t), a, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(z / N[(t - z), $MachinePrecision]), $MachinePrecision] * a + x), $MachinePrecision]}, If[LessEqual[z, -1.35e+16], t$95$1, If[LessEqual[z, 4.9e-26], N[(N[(N[(z - y), $MachinePrecision] / t), $MachinePrecision] * a + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{z}{t - z}, a, x\right)\\
\mathbf{if}\;z \leq -1.35 \cdot 10^{+16}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 4.9 \cdot 10^{-26}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z - y}{t}, a, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -1.35e16 or 4.8999999999999999e-26 < z Initial program 95.3%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-divN/A
lower-/.f64N/A
lower--.f64N/A
lower--.f64N/A
lower-+.f6499.9
Applied rewrites99.9%
Taylor expanded in t around inf
Applied rewrites98.2%
Taylor expanded in y around 0
Applied rewrites84.1%
if -1.35e16 < z < 4.8999999999999999e-26Initial program 99.1%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-divN/A
lower-/.f64N/A
lower--.f64N/A
lower--.f64N/A
lower-+.f6499.3
Applied rewrites99.3%
Taylor expanded in t around inf
Applied rewrites65.9%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (/ (- (* a y)) 1.0)) (t_2 (/ (- y z) (/ (+ (- t z) 1.0) a)))) (if (<= t_2 -1e+305) t_1 (if (<= t_2 5e+299) (fma (/ z (- t z)) a x) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = -(a * y) / 1.0;
double t_2 = (y - z) / (((t - z) + 1.0) / a);
double tmp;
if (t_2 <= -1e+305) {
tmp = t_1;
} else if (t_2 <= 5e+299) {
tmp = fma((z / (t - z)), a, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(Float64(-Float64(a * y)) / 1.0) t_2 = Float64(Float64(y - z) / Float64(Float64(Float64(t - z) + 1.0) / a)) tmp = 0.0 if (t_2 <= -1e+305) tmp = t_1; elseif (t_2 <= 5e+299) tmp = fma(Float64(z / Float64(t - z)), a, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[((-N[(a * y), $MachinePrecision]) / 1.0), $MachinePrecision]}, Block[{t$95$2 = N[(N[(y - z), $MachinePrecision] / N[(N[(N[(t - z), $MachinePrecision] + 1.0), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -1e+305], t$95$1, If[LessEqual[t$95$2, 5e+299], N[(N[(z / N[(t - z), $MachinePrecision]), $MachinePrecision] * a + x), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{-a \cdot y}{1}\\
t_2 := \frac{y - z}{\frac{\left(t - z\right) + 1}{a}}\\
\mathbf{if}\;t\_2 \leq -1 \cdot 10^{+305}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+299}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{t - z}, a, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 (-.f64 y z) (/.f64 (+.f64 (-.f64 t z) #s(literal 1 binary64)) a)) < -9.9999999999999994e304 or 5.0000000000000003e299 < (/.f64 (-.f64 y z) (/.f64 (+.f64 (-.f64 t z) #s(literal 1 binary64)) a)) Initial program 100.0%
Taylor expanded in y around inf
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-+.f6493.4
Applied rewrites93.4%
Taylor expanded in z around 0
lift-+.f6482.9
Applied rewrites82.9%
Taylor expanded in t around 0
Applied rewrites72.9%
if -9.9999999999999994e304 < (/.f64 (-.f64 y z) (/.f64 (+.f64 (-.f64 t z) #s(literal 1 binary64)) a)) < 5.0000000000000003e299Initial program 97.0%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-divN/A
lower-/.f64N/A
lower--.f64N/A
lower--.f64N/A
lower-+.f6499.6
Applied rewrites99.6%
Taylor expanded in t around inf
Applied rewrites85.1%
Taylor expanded in y around 0
Applied rewrites75.4%
(FPCore (x y z t a) :precision binary64 (if (<= z -2.7e-8) (- x a) (if (<= z 7.4e-11) x (- x a))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -2.7e-8) {
tmp = x - a;
} else if (z <= 7.4e-11) {
tmp = x;
} else {
tmp = x - 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 <= (-2.7d-8)) then
tmp = x - a
else if (z <= 7.4d-11) then
tmp = x
else
tmp = x - 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 <= -2.7e-8) {
tmp = x - a;
} else if (z <= 7.4e-11) {
tmp = x;
} else {
tmp = x - a;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if z <= -2.7e-8: tmp = x - a elif z <= 7.4e-11: tmp = x else: tmp = x - a return tmp
function code(x, y, z, t, a) tmp = 0.0 if (z <= -2.7e-8) tmp = Float64(x - a); elseif (z <= 7.4e-11) tmp = x; else tmp = Float64(x - a); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (z <= -2.7e-8) tmp = x - a; elseif (z <= 7.4e-11) tmp = x; else tmp = x - a; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -2.7e-8], N[(x - a), $MachinePrecision], If[LessEqual[z, 7.4e-11], x, N[(x - a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.7 \cdot 10^{-8}:\\
\;\;\;\;x - a\\
\mathbf{elif}\;z \leq 7.4 \cdot 10^{-11}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - a\\
\end{array}
\end{array}
if z < -2.70000000000000002e-8 or 7.4000000000000003e-11 < z Initial program 95.3%
Taylor expanded in z around inf
Applied rewrites75.4%
if -2.70000000000000002e-8 < z < 7.4000000000000003e-11Initial program 99.2%
Taylor expanded in x around inf
Applied rewrites57.1%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (/ (- y z) (/ (+ (- t z) 1.0) a)))) (if (<= t_1 -6.2e+95) (- a) (if (<= t_1 1e+95) x (- a)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (y - z) / (((t - z) + 1.0) / a);
double tmp;
if (t_1 <= -6.2e+95) {
tmp = -a;
} else if (t_1 <= 1e+95) {
tmp = x;
} else {
tmp = -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) :: t_1
real(8) :: tmp
t_1 = (y - z) / (((t - z) + 1.0d0) / a)
if (t_1 <= (-6.2d+95)) then
tmp = -a
else if (t_1 <= 1d+95) then
tmp = x
else
tmp = -a
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double t_1 = (y - z) / (((t - z) + 1.0) / a);
double tmp;
if (t_1 <= -6.2e+95) {
tmp = -a;
} else if (t_1 <= 1e+95) {
tmp = x;
} else {
tmp = -a;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = (y - z) / (((t - z) + 1.0) / a) tmp = 0 if t_1 <= -6.2e+95: tmp = -a elif t_1 <= 1e+95: tmp = x else: tmp = -a return tmp
function code(x, y, z, t, a) t_1 = Float64(Float64(y - z) / Float64(Float64(Float64(t - z) + 1.0) / a)) tmp = 0.0 if (t_1 <= -6.2e+95) tmp = Float64(-a); elseif (t_1 <= 1e+95) tmp = x; else tmp = Float64(-a); end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = (y - z) / (((t - z) + 1.0) / a); tmp = 0.0; if (t_1 <= -6.2e+95) tmp = -a; elseif (t_1 <= 1e+95) tmp = x; else tmp = -a; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(y - z), $MachinePrecision] / N[(N[(N[(t - z), $MachinePrecision] + 1.0), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -6.2e+95], (-a), If[LessEqual[t$95$1, 1e+95], x, (-a)]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{y - z}{\frac{\left(t - z\right) + 1}{a}}\\
\mathbf{if}\;t\_1 \leq -6.2 \cdot 10^{+95}:\\
\;\;\;\;-a\\
\mathbf{elif}\;t\_1 \leq 10^{+95}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;-a\\
\end{array}
\end{array}
if (/.f64 (-.f64 y z) (/.f64 (+.f64 (-.f64 t z) #s(literal 1 binary64)) a)) < -6.2000000000000006e95 or 1.00000000000000002e95 < (/.f64 (-.f64 y z) (/.f64 (+.f64 (-.f64 t z) #s(literal 1 binary64)) a)) Initial program 99.8%
Taylor expanded in x around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64N/A
lower--.f64N/A
lower-+.f6451.3
Applied rewrites51.3%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6427.2
Applied rewrites27.2%
if -6.2000000000000006e95 < (/.f64 (-.f64 y z) (/.f64 (+.f64 (-.f64 t z) #s(literal 1 binary64)) a)) < 1.00000000000000002e95Initial program 96.0%
Taylor expanded in x around inf
Applied rewrites71.3%
(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 97.2%
Taylor expanded in x around inf
Applied rewrites54.0%
herbie shell --seed 2025101
(FPCore (x y z t a)
:name "Graphics.Rendering.Chart.SparkLine:renderSparkLine from Chart-1.5.3"
:precision binary64
(- x (/ (- y z) (/ (+ (- t z) 1.0) a))))