
(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 11 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.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.7
Applied rewrites99.7%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma (fma t y (- y)) a x)) (t_2 (- x (* a (/ y t)))))
(if (<= t -1.0)
t_2
(if (<= t -4.7e-91)
t_1
(if (<= t 1.45e-131)
(fma (/ z (- 1.0 z)) a x)
(if (<= t 2.8e-14) t_1 t_2))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma(fma(t, y, -y), a, x);
double t_2 = x - (a * (y / t));
double tmp;
if (t <= -1.0) {
tmp = t_2;
} else if (t <= -4.7e-91) {
tmp = t_1;
} else if (t <= 1.45e-131) {
tmp = fma((z / (1.0 - z)), a, x);
} else if (t <= 2.8e-14) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(fma(t, y, Float64(-y)), a, x) t_2 = Float64(x - Float64(a * Float64(y / t))) tmp = 0.0 if (t <= -1.0) tmp = t_2; elseif (t <= -4.7e-91) tmp = t_1; elseif (t <= 1.45e-131) tmp = fma(Float64(z / Float64(1.0 - z)), a, x); elseif (t <= 2.8e-14) tmp = t_1; else tmp = t_2; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(t * y + (-y)), $MachinePrecision] * a + x), $MachinePrecision]}, Block[{t$95$2 = N[(x - N[(a * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t, -1.0], t$95$2, If[LessEqual[t, -4.7e-91], t$95$1, If[LessEqual[t, 1.45e-131], N[(N[(z / N[(1.0 - z), $MachinePrecision]), $MachinePrecision] * a + x), $MachinePrecision], If[LessEqual[t, 2.8e-14], t$95$1, t$95$2]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\mathsf{fma}\left(t, y, -y\right), a, x\right)\\
t_2 := x - a \cdot \frac{y}{t}\\
\mathbf{if}\;t \leq -1:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t \leq -4.7 \cdot 10^{-91}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 1.45 \cdot 10^{-131}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{1 - z}, a, x\right)\\
\mathbf{elif}\;t \leq 2.8 \cdot 10^{-14}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if t < -1 or 2.8000000000000001e-14 < t Initial program 96.6%
Taylor expanded in y around inf
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-+.f6480.9
Applied rewrites80.9%
Taylor expanded in t around inf
Applied rewrites77.1%
if -1 < t < -4.70000000000000006e-91 or 1.4500000000000001e-131 < t < 2.8000000000000001e-14Initial program 98.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.9
Applied rewrites99.9%
Taylor expanded in z around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-+.f6467.2
Applied rewrites67.2%
Taylor expanded in t around 0
+-commutativeN/A
lower-fma.f64N/A
mul-1-negN/A
lift-neg.f6467.1
Applied rewrites67.1%
if -4.70000000000000006e-91 < t < 1.4500000000000001e-131Initial program 97.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-+.f64100.0
Applied rewrites100.0%
Taylor expanded in t around 0
Applied rewrites100.0%
Taylor expanded in y around 0
Applied rewrites68.8%
(FPCore (x y z t a)
:precision binary64
(if (<= z -1.55e+82)
(- x a)
(if (<= z 7.5e+51)
(fma (/ (- y) (+ 1.0 t)) a x)
(if (<= z 4.7e+181) (- x (* a (/ y (- z)))) (- x a)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -1.55e+82) {
tmp = x - a;
} else if (z <= 7.5e+51) {
tmp = fma((-y / (1.0 + t)), a, x);
} else if (z <= 4.7e+181) {
tmp = x - (a * (y / -z));
} else {
tmp = x - a;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -1.55e+82) tmp = Float64(x - a); elseif (z <= 7.5e+51) tmp = fma(Float64(Float64(-y) / Float64(1.0 + t)), a, x); elseif (z <= 4.7e+181) tmp = Float64(x - Float64(a * Float64(y / Float64(-z)))); else tmp = Float64(x - a); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -1.55e+82], N[(x - a), $MachinePrecision], If[LessEqual[z, 7.5e+51], N[(N[((-y) / N[(1.0 + t), $MachinePrecision]), $MachinePrecision] * a + x), $MachinePrecision], If[LessEqual[z, 4.7e+181], N[(x - N[(a * N[(y / (-z)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - a), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.55 \cdot 10^{+82}:\\
\;\;\;\;x - a\\
\mathbf{elif}\;z \leq 7.5 \cdot 10^{+51}:\\
\;\;\;\;\mathsf{fma}\left(\frac{-y}{1 + t}, a, x\right)\\
\mathbf{elif}\;z \leq 4.7 \cdot 10^{+181}:\\
\;\;\;\;x - a \cdot \frac{y}{-z}\\
\mathbf{else}:\\
\;\;\;\;x - a\\
\end{array}
\end{array}
if z < -1.55000000000000016e82 or 4.70000000000000027e181 < z Initial program 93.3%
Taylor expanded in z around inf
Applied rewrites84.1%
if -1.55000000000000016e82 < z < 7.4999999999999999e51Initial program 98.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.5
Applied rewrites99.5%
Taylor expanded in z around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-+.f6487.2
Applied rewrites87.2%
if 7.4999999999999999e51 < z < 4.70000000000000027e181Initial program 96.5%
Taylor expanded in y around inf
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-+.f6469.1
Applied rewrites69.1%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6462.8
Applied rewrites62.8%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma (/ (- z y) t) a x)))
(if (<= t -1.45e+32)
t_1
(if (<= t 1.45e-131)
(fma (/ z (- 1.0 z)) a x)
(if (<= t 54000000.0) (fma (- y) a x) t_1)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma(((z - y) / t), a, x);
double tmp;
if (t <= -1.45e+32) {
tmp = t_1;
} else if (t <= 1.45e-131) {
tmp = fma((z / (1.0 - z)), a, x);
} else if (t <= 54000000.0) {
tmp = fma(-y, a, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(Float64(z - y) / t), a, x) tmp = 0.0 if (t <= -1.45e+32) tmp = t_1; elseif (t <= 1.45e-131) tmp = fma(Float64(z / Float64(1.0 - z)), a, x); elseif (t <= 54000000.0) tmp = fma(Float64(-y), 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] / t), $MachinePrecision] * a + x), $MachinePrecision]}, If[LessEqual[t, -1.45e+32], t$95$1, If[LessEqual[t, 1.45e-131], N[(N[(z / N[(1.0 - z), $MachinePrecision]), $MachinePrecision] * a + x), $MachinePrecision], If[LessEqual[t, 54000000.0], N[((-y) * a + x), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{z - y}{t}, a, x\right)\\
\mathbf{if}\;t \leq -1.45 \cdot 10^{+32}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 1.45 \cdot 10^{-131}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{1 - z}, a, x\right)\\
\mathbf{elif}\;t \leq 54000000:\\
\;\;\;\;\mathsf{fma}\left(-y, a, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -1.45000000000000001e32 or 5.4e7 < t Initial program 96.6%
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 rewrites84.3%
if -1.45000000000000001e32 < t < 1.4500000000000001e-131Initial program 97.5%
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 0
Applied rewrites98.1%
Taylor expanded in y around 0
Applied rewrites68.3%
if 1.4500000000000001e-131 < t < 5.4e7Initial 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.9
Applied rewrites99.9%
Taylor expanded in z around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-+.f6466.7
Applied rewrites66.7%
Taylor expanded in t around 0
mul-1-negN/A
lift-neg.f6465.5
Applied rewrites65.5%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma (/ (- z y) t) a x)))
(if (<= t -1.4e+32)
t_1
(if (<= t 9.2e+45) (fma (/ (- z y) (- 1.0 z)) a x) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma(((z - y) / t), a, x);
double tmp;
if (t <= -1.4e+32) {
tmp = t_1;
} else if (t <= 9.2e+45) {
tmp = fma(((z - y) / (1.0 - z)), a, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(Float64(z - y) / t), a, x) tmp = 0.0 if (t <= -1.4e+32) tmp = t_1; elseif (t <= 9.2e+45) tmp = fma(Float64(Float64(z - y) / Float64(1.0 - z)), 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] / t), $MachinePrecision] * a + x), $MachinePrecision]}, If[LessEqual[t, -1.4e+32], t$95$1, If[LessEqual[t, 9.2e+45], N[(N[(N[(z - y), $MachinePrecision] / N[(1.0 - z), $MachinePrecision]), $MachinePrecision] * a + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{z - y}{t}, a, x\right)\\
\mathbf{if}\;t \leq -1.4 \cdot 10^{+32}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 9.2 \cdot 10^{+45}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z - y}{1 - z}, a, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -1.4e32 or 9.20000000000000049e45 < t Initial program 96.6%
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 rewrites85.5%
if -1.4e32 < t < 9.20000000000000049e45Initial program 97.4%
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 0
Applied rewrites97.1%
(FPCore (x y z t a)
:precision binary64
(if (<= z -1.3e+22)
(fma (/ z (- (+ 1.0 t) z)) a x)
(if (<= z 7.8e+49)
(fma (/ (- y) (+ 1.0 t)) a x)
(fma (/ (- z y) (- z)) a x))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -1.3e+22) {
tmp = fma((z / ((1.0 + t) - z)), a, x);
} else if (z <= 7.8e+49) {
tmp = fma((-y / (1.0 + t)), a, x);
} else {
tmp = fma(((z - y) / -z), a, x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -1.3e+22) tmp = fma(Float64(z / Float64(Float64(1.0 + t) - z)), a, x); elseif (z <= 7.8e+49) tmp = fma(Float64(Float64(-y) / Float64(1.0 + t)), a, x); else tmp = fma(Float64(Float64(z - y) / Float64(-z)), a, x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -1.3e+22], N[(N[(z / N[(N[(1.0 + t), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] * a + x), $MachinePrecision], If[LessEqual[z, 7.8e+49], N[(N[((-y) / N[(1.0 + t), $MachinePrecision]), $MachinePrecision] * a + x), $MachinePrecision], N[(N[(N[(z - y), $MachinePrecision] / (-z)), $MachinePrecision] * a + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.3 \cdot 10^{+22}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{\left(1 + t\right) - z}, a, x\right)\\
\mathbf{elif}\;z \leq 7.8 \cdot 10^{+49}:\\
\;\;\;\;\mathsf{fma}\left(\frac{-y}{1 + t}, a, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z - y}{-z}, a, x\right)\\
\end{array}
\end{array}
if z < -1.3e22Initial program 94.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 y around 0
Applied rewrites86.4%
if -1.3e22 < z < 7.8000000000000002e49Initial 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.5
Applied rewrites99.5%
Taylor expanded in z around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-+.f6489.8
Applied rewrites89.8%
if 7.8000000000000002e49 < z Initial program 94.7%
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.f6488.0
Applied rewrites88.0%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma (/ (- z y) (- z)) a x)))
(if (<= z -1.08e+82)
t_1
(if (<= z 7.8e+49) (fma (/ (- 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 <= -1.08e+82) {
tmp = t_1;
} else if (z <= 7.8e+49) {
tmp = fma((-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 <= -1.08e+82) tmp = t_1; elseif (z <= 7.8e+49) tmp = fma(Float64(Float64(-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, -1.08e+82], t$95$1, If[LessEqual[z, 7.8e+49], N[(N[((-y) / 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 -1.08 \cdot 10^{+82}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 7.8 \cdot 10^{+49}:\\
\;\;\;\;\mathsf{fma}\left(\frac{-y}{1 + t}, a, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -1.08e82 or 7.8000000000000002e49 < z Initial program 94.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 z around inf
mul-1-negN/A
lower-neg.f6488.7
Applied rewrites88.7%
if -1.08e82 < z < 7.8000000000000002e49Initial program 98.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.5
Applied rewrites99.5%
Taylor expanded in z around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-+.f6487.5
Applied rewrites87.5%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (- x (* a (/ y t))))) (if (<= t -1.0) t_1 (if (<= t 2.8e-14) (fma (fma t y (- y)) a x) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = x - (a * (y / t));
double tmp;
if (t <= -1.0) {
tmp = t_1;
} else if (t <= 2.8e-14) {
tmp = fma(fma(t, y, -y), a, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(x - Float64(a * Float64(y / t))) tmp = 0.0 if (t <= -1.0) tmp = t_1; elseif (t <= 2.8e-14) tmp = fma(fma(t, y, Float64(-y)), a, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(x - N[(a * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t, -1.0], t$95$1, If[LessEqual[t, 2.8e-14], N[(N[(t * y + (-y)), $MachinePrecision] * a + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x - a \cdot \frac{y}{t}\\
\mathbf{if}\;t \leq -1:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 2.8 \cdot 10^{-14}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(t, y, -y\right), a, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -1 or 2.8000000000000001e-14 < t Initial program 96.6%
Taylor expanded in y around inf
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-+.f6480.9
Applied rewrites80.9%
Taylor expanded in t around inf
Applied rewrites77.1%
if -1 < t < 2.8000000000000001e-14Initial program 97.5%
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 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-+.f6466.2
Applied rewrites66.2%
Taylor expanded in t around 0
+-commutativeN/A
lower-fma.f64N/A
mul-1-negN/A
lift-neg.f6466.2
Applied rewrites66.2%
(FPCore (x y z t a) :precision binary64 (if (<= z -800000000000.0) (- x a) (if (<= z 1.1) (fma (- y) a x) (- x a))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -800000000000.0) {
tmp = x - a;
} else if (z <= 1.1) {
tmp = fma(-y, a, x);
} else {
tmp = x - a;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -800000000000.0) tmp = Float64(x - a); elseif (z <= 1.1) tmp = fma(Float64(-y), a, x); else tmp = Float64(x - a); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -800000000000.0], N[(x - a), $MachinePrecision], If[LessEqual[z, 1.1], N[((-y) * a + x), $MachinePrecision], N[(x - a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -800000000000:\\
\;\;\;\;x - a\\
\mathbf{elif}\;z \leq 1.1:\\
\;\;\;\;\mathsf{fma}\left(-y, a, x\right)\\
\mathbf{else}:\\
\;\;\;\;x - a\\
\end{array}
\end{array}
if z < -8e11 or 1.1000000000000001 < z Initial program 94.9%
Taylor expanded in z around inf
Applied rewrites75.5%
if -8e11 < z < 1.1000000000000001Initial 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.5
Applied rewrites99.5%
Taylor expanded in z around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-+.f6493.2
Applied rewrites93.2%
Taylor expanded in t around 0
mul-1-negN/A
lift-neg.f6472.3
Applied rewrites72.3%
(FPCore (x y z t a) :precision binary64 (if (<= t -8.2e+92) x (if (<= t 8.4e+46) (- x a) x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= -8.2e+92) {
tmp = x;
} else if (t <= 8.4e+46) {
tmp = x - a;
} else {
tmp = x;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: tmp
if (t <= (-8.2d+92)) then
tmp = x
else if (t <= 8.4d+46) then
tmp = x - a
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= -8.2e+92) {
tmp = x;
} else if (t <= 8.4e+46) {
tmp = x - a;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if t <= -8.2e+92: tmp = x elif t <= 8.4e+46: tmp = x - a else: tmp = x return tmp
function code(x, y, z, t, a) tmp = 0.0 if (t <= -8.2e+92) tmp = x; elseif (t <= 8.4e+46) tmp = Float64(x - a); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (t <= -8.2e+92) tmp = x; elseif (t <= 8.4e+46) tmp = x - a; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, -8.2e+92], x, If[LessEqual[t, 8.4e+46], N[(x - a), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -8.2 \cdot 10^{+92}:\\
\;\;\;\;x\\
\mathbf{elif}\;t \leq 8.4 \cdot 10^{+46}:\\
\;\;\;\;x - a\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if t < -8.20000000000000047e92 or 8.4e46 < t Initial program 96.7%
Taylor expanded in x around inf
Applied rewrites64.1%
if -8.20000000000000047e92 < t < 8.4e46Initial program 97.3%
Taylor expanded in z around inf
Applied rewrites61.2%
(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.1%
Taylor expanded in x around inf
Applied rewrites53.4%
(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(Float64(y - z) / 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[(N[(y - z), $MachinePrecision] / N[(N[(t - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \frac{y - z}{\left(t - z\right) + 1} \cdot a
\end{array}
herbie shell --seed 2025088
(FPCore (x y z t a)
:name "Graphics.Rendering.Chart.SparkLine:renderSparkLine from Chart-1.5.3"
:precision binary64
:alt
(! :herbie-platform default (- x (* (/ (- y z) (+ (- t z) 1)) a)))
(- x (/ (- y z) (/ (+ (- t z) 1.0) a))))