
(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(Float64(y * 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[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y \cdot \left(z - t\right)}{z - a}
\end{array}
Herbie found 12 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(Float64(y * 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[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y \cdot \left(z - t\right)}{z - a}
\end{array}
(FPCore (x y z t a) :precision binary64 (fma y (/ (- z t) (- z a)) x))
double code(double x, double y, double z, double t, double a) {
return fma(y, ((z - t) / (z - a)), x);
}
function code(x, y, z, t, a) return fma(y, Float64(Float64(z - t) / Float64(z - a)), x) end
code[x_, y_, z_, t_, a_] := N[(y * N[(N[(z - t), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y, \frac{z - t}{z - a}, x\right)
\end{array}
Initial program 85.8%
Applied rewrites98.2%
(FPCore (x y z t a) :precision binary64 (fma (/ y (- z a)) (- z t) x))
double code(double x, double y, double z, double t, double a) {
return fma((y / (z - a)), (z - t), x);
}
function code(x, y, z, t, a) return fma(Float64(y / Float64(z - a)), Float64(z - t), x) end
code[x_, y_, z_, t_, a_] := N[(N[(y / N[(z - a), $MachinePrecision]), $MachinePrecision] * N[(z - t), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{y}{z - a}, z - t, x\right)
\end{array}
Initial program 85.8%
Taylor expanded in x around inf
Applied rewrites78.9%
Applied rewrites86.8%
Applied rewrites95.8%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (* (/ (- z t) (- z a)) y)) (t_2 (/ (* y (- z t)) (- z a)))) (if (<= t_2 -4e+190) t_1 (if (<= t_2 2e+87) (fma y (/ z (- z a)) x) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = ((z - t) / (z - a)) * y;
double t_2 = (y * (z - t)) / (z - a);
double tmp;
if (t_2 <= -4e+190) {
tmp = t_1;
} else if (t_2 <= 2e+87) {
tmp = fma(y, (z / (z - a)), x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(Float64(Float64(z - t) / Float64(z - a)) * y) t_2 = Float64(Float64(y * Float64(z - t)) / Float64(z - a)) tmp = 0.0 if (t_2 <= -4e+190) tmp = t_1; elseif (t_2 <= 2e+87) tmp = fma(y, Float64(z / Float64(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 - t), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]}, Block[{t$95$2 = N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -4e+190], t$95$1, If[LessEqual[t$95$2, 2e+87], N[(y * N[(z / N[(z - a), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{z - t}{z - a} \cdot y\\
t_2 := \frac{y \cdot \left(z - t\right)}{z - a}\\
\mathbf{if}\;t\_2 \leq -4 \cdot 10^{+190}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+87}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z}{z - a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 (*.f64 y (-.f64 z t)) (-.f64 z a)) < -4.0000000000000003e190 or 1.9999999999999999e87 < (/.f64 (*.f64 y (-.f64 z t)) (-.f64 z a)) Initial program 85.8%
Taylor expanded in x around 0
Applied rewrites40.1%
Applied rewrites49.8%
if -4.0000000000000003e190 < (/.f64 (*.f64 y (-.f64 z t)) (-.f64 z a)) < 1.9999999999999999e87Initial program 85.8%
Applied rewrites98.2%
Taylor expanded in t around 0
Applied rewrites71.1%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (* (/ y (- z a)) (- z t))) (t_2 (/ (* y (- z t)) (- z a)))) (if (<= t_2 -2e+177) t_1 (if (<= t_2 2e+87) (fma y (/ z (- z a)) x) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (y / (z - a)) * (z - t);
double t_2 = (y * (z - t)) / (z - a);
double tmp;
if (t_2 <= -2e+177) {
tmp = t_1;
} else if (t_2 <= 2e+87) {
tmp = fma(y, (z / (z - a)), x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(Float64(y / Float64(z - a)) * Float64(z - t)) t_2 = Float64(Float64(y * Float64(z - t)) / Float64(z - a)) tmp = 0.0 if (t_2 <= -2e+177) tmp = t_1; elseif (t_2 <= 2e+87) tmp = fma(y, Float64(z / Float64(z - a)), x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(y / N[(z - a), $MachinePrecision]), $MachinePrecision] * N[(z - t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -2e+177], t$95$1, If[LessEqual[t$95$2, 2e+87], N[(y * N[(z / N[(z - a), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{y}{z - a} \cdot \left(z - t\right)\\
t_2 := \frac{y \cdot \left(z - t\right)}{z - a}\\
\mathbf{if}\;t\_2 \leq -2 \cdot 10^{+177}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+87}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z}{z - a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 (*.f64 y (-.f64 z t)) (-.f64 z a)) < -2e177 or 1.9999999999999999e87 < (/.f64 (*.f64 y (-.f64 z t)) (-.f64 z a)) Initial program 85.8%
Taylor expanded in x around 0
Applied rewrites40.1%
Applied rewrites49.8%
Applied rewrites47.5%
if -2e177 < (/.f64 (*.f64 y (-.f64 z t)) (-.f64 z a)) < 1.9999999999999999e87Initial program 85.8%
Applied rewrites98.2%
Taylor expanded in t around 0
Applied rewrites71.1%
(FPCore (x y z t a)
:precision binary64
(if (<= z -3e+64)
(fma y (/ (- z t) z) x)
(if (<= z 2.1e-108)
(fma y (/ t a) x)
(if (<= z 3e-13) (/ (* y (- z t)) (- z a)) (fma y (/ z (- z a)) x)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -3e+64) {
tmp = fma(y, ((z - t) / z), x);
} else if (z <= 2.1e-108) {
tmp = fma(y, (t / a), x);
} else if (z <= 3e-13) {
tmp = (y * (z - t)) / (z - a);
} else {
tmp = fma(y, (z / (z - a)), x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -3e+64) tmp = fma(y, Float64(Float64(z - t) / z), x); elseif (z <= 2.1e-108) tmp = fma(y, Float64(t / a), x); elseif (z <= 3e-13) tmp = Float64(Float64(y * Float64(z - t)) / Float64(z - a)); else tmp = fma(y, Float64(z / Float64(z - a)), x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -3e+64], N[(y * N[(N[(z - t), $MachinePrecision] / z), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[z, 2.1e-108], N[(y * N[(t / a), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[z, 3e-13], N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision], N[(y * N[(z / N[(z - a), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3 \cdot 10^{+64}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z - t}{z}, x\right)\\
\mathbf{elif}\;z \leq 2.1 \cdot 10^{-108}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{t}{a}, x\right)\\
\mathbf{elif}\;z \leq 3 \cdot 10^{-13}:\\
\;\;\;\;\frac{y \cdot \left(z - t\right)}{z - a}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z}{z - a}, x\right)\\
\end{array}
\end{array}
if z < -3.0000000000000002e64Initial program 85.8%
Applied rewrites98.2%
Taylor expanded in a around 0
Applied rewrites67.3%
if -3.0000000000000002e64 < z < 2.0999999999999999e-108Initial program 85.8%
Applied rewrites98.2%
Taylor expanded in z around 0
Applied rewrites62.0%
if 2.0999999999999999e-108 < z < 2.99999999999999984e-13Initial program 85.8%
Taylor expanded in x around 0
Applied rewrites40.1%
if 2.99999999999999984e-13 < z Initial program 85.8%
Applied rewrites98.2%
Taylor expanded in t around 0
Applied rewrites71.1%
(FPCore (x y z t a) :precision binary64 (if (<= z -3e+64) (fma y (/ (- z t) z) x) (if (<= z 1.4e-99) (fma y (/ t a) x) (fma y (/ z (- z a)) x))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -3e+64) {
tmp = fma(y, ((z - t) / z), x);
} else if (z <= 1.4e-99) {
tmp = fma(y, (t / a), x);
} else {
tmp = fma(y, (z / (z - a)), x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -3e+64) tmp = fma(y, Float64(Float64(z - t) / z), x); elseif (z <= 1.4e-99) tmp = fma(y, Float64(t / a), x); else tmp = fma(y, Float64(z / Float64(z - a)), x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -3e+64], N[(y * N[(N[(z - t), $MachinePrecision] / z), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[z, 1.4e-99], N[(y * N[(t / a), $MachinePrecision] + x), $MachinePrecision], N[(y * N[(z / N[(z - a), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3 \cdot 10^{+64}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z - t}{z}, x\right)\\
\mathbf{elif}\;z \leq 1.4 \cdot 10^{-99}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{t}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z}{z - a}, x\right)\\
\end{array}
\end{array}
if z < -3.0000000000000002e64Initial program 85.8%
Applied rewrites98.2%
Taylor expanded in a around 0
Applied rewrites67.3%
if -3.0000000000000002e64 < z < 1.4e-99Initial program 85.8%
Applied rewrites98.2%
Taylor expanded in z around 0
Applied rewrites62.0%
if 1.4e-99 < z Initial program 85.8%
Applied rewrites98.2%
Taylor expanded in t around 0
Applied rewrites71.1%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (fma y (/ z (- z a)) x))) (if (<= z -2.3e+26) t_1 (if (<= z 1.4e-99) (fma y (/ t a) x) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma(y, (z / (z - a)), x);
double tmp;
if (z <= -2.3e+26) {
tmp = t_1;
} else if (z <= 1.4e-99) {
tmp = fma(y, (t / a), x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(y, Float64(z / Float64(z - a)), x) tmp = 0.0 if (z <= -2.3e+26) tmp = t_1; elseif (z <= 1.4e-99) tmp = fma(y, Float64(t / a), x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(y * N[(z / N[(z - a), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[z, -2.3e+26], t$95$1, If[LessEqual[z, 1.4e-99], N[(y * N[(t / a), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(y, \frac{z}{z - a}, x\right)\\
\mathbf{if}\;z \leq -2.3 \cdot 10^{+26}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 1.4 \cdot 10^{-99}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{t}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -2.3000000000000001e26 or 1.4e-99 < z Initial program 85.8%
Applied rewrites98.2%
Taylor expanded in t around 0
Applied rewrites71.1%
if -2.3000000000000001e26 < z < 1.4e-99Initial program 85.8%
Applied rewrites98.2%
Taylor expanded in z around 0
Applied rewrites62.0%
(FPCore (x y z t a) :precision binary64 (if (<= z -4.7e+47) (+ x y) (if (<= z 8e-12) (fma y (/ t a) x) (+ x y))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -4.7e+47) {
tmp = x + y;
} else if (z <= 8e-12) {
tmp = fma(y, (t / a), x);
} else {
tmp = x + y;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -4.7e+47) tmp = Float64(x + y); elseif (z <= 8e-12) tmp = fma(y, Float64(t / a), x); else tmp = Float64(x + y); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -4.7e+47], N[(x + y), $MachinePrecision], If[LessEqual[z, 8e-12], N[(y * N[(t / a), $MachinePrecision] + x), $MachinePrecision], N[(x + y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.7 \cdot 10^{+47}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;z \leq 8 \cdot 10^{-12}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{t}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if z < -4.69999999999999964e47 or 7.99999999999999984e-12 < z Initial program 85.8%
Taylor expanded in z around inf
Applied rewrites60.6%
if -4.69999999999999964e47 < z < 7.99999999999999984e-12Initial program 85.8%
Applied rewrites98.2%
Taylor expanded in z around 0
Applied rewrites62.0%
(FPCore (x y z t a) :precision binary64 (if (<= z -4.6e+47) (+ x y) (if (<= z -6.8e-268) (* x 1.0) (if (<= z 3.8e-227) (* (/ t a) y) (+ x y)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -4.6e+47) {
tmp = x + y;
} else if (z <= -6.8e-268) {
tmp = x * 1.0;
} else if (z <= 3.8e-227) {
tmp = (t / a) * y;
} 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 <= (-4.6d+47)) then
tmp = x + y
else if (z <= (-6.8d-268)) then
tmp = x * 1.0d0
else if (z <= 3.8d-227) then
tmp = (t / a) * y
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 <= -4.6e+47) {
tmp = x + y;
} else if (z <= -6.8e-268) {
tmp = x * 1.0;
} else if (z <= 3.8e-227) {
tmp = (t / a) * y;
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if z <= -4.6e+47: tmp = x + y elif z <= -6.8e-268: tmp = x * 1.0 elif z <= 3.8e-227: tmp = (t / a) * y else: tmp = x + y return tmp
function code(x, y, z, t, a) tmp = 0.0 if (z <= -4.6e+47) tmp = Float64(x + y); elseif (z <= -6.8e-268) tmp = Float64(x * 1.0); elseif (z <= 3.8e-227) tmp = Float64(Float64(t / a) * y); else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (z <= -4.6e+47) tmp = x + y; elseif (z <= -6.8e-268) tmp = x * 1.0; elseif (z <= 3.8e-227) tmp = (t / a) * y; else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -4.6e+47], N[(x + y), $MachinePrecision], If[LessEqual[z, -6.8e-268], N[(x * 1.0), $MachinePrecision], If[LessEqual[z, 3.8e-227], N[(N[(t / a), $MachinePrecision] * y), $MachinePrecision], N[(x + y), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.6 \cdot 10^{+47}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;z \leq -6.8 \cdot 10^{-268}:\\
\;\;\;\;x \cdot 1\\
\mathbf{elif}\;z \leq 3.8 \cdot 10^{-227}:\\
\;\;\;\;\frac{t}{a} \cdot y\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if z < -4.5999999999999997e47 or 3.8000000000000001e-227 < z Initial program 85.8%
Taylor expanded in z around inf
Applied rewrites60.6%
if -4.5999999999999997e47 < z < -6.8e-268Initial program 85.8%
Taylor expanded in x around inf
Applied rewrites78.9%
Taylor expanded in x around inf
Applied rewrites50.4%
if -6.8e-268 < z < 3.8000000000000001e-227Initial program 85.8%
Taylor expanded in x around 0
Applied rewrites40.1%
Applied rewrites49.8%
Taylor expanded in z around 0
Applied rewrites20.7%
(FPCore (x y z t a) :precision binary64 (if (<= z -4.6e+47) (+ x y) (if (<= z 3.4e-13) (* x 1.0) (+ x y))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -4.6e+47) {
tmp = x + y;
} else if (z <= 3.4e-13) {
tmp = x * 1.0;
} 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 <= (-4.6d+47)) then
tmp = x + y
else if (z <= 3.4d-13) then
tmp = x * 1.0d0
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 <= -4.6e+47) {
tmp = x + y;
} else if (z <= 3.4e-13) {
tmp = x * 1.0;
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if z <= -4.6e+47: tmp = x + y elif z <= 3.4e-13: tmp = x * 1.0 else: tmp = x + y return tmp
function code(x, y, z, t, a) tmp = 0.0 if (z <= -4.6e+47) tmp = Float64(x + y); elseif (z <= 3.4e-13) tmp = Float64(x * 1.0); else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (z <= -4.6e+47) tmp = x + y; elseif (z <= 3.4e-13) tmp = x * 1.0; else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -4.6e+47], N[(x + y), $MachinePrecision], If[LessEqual[z, 3.4e-13], N[(x * 1.0), $MachinePrecision], N[(x + y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.6 \cdot 10^{+47}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;z \leq 3.4 \cdot 10^{-13}:\\
\;\;\;\;x \cdot 1\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if z < -4.5999999999999997e47 or 3.40000000000000015e-13 < z Initial program 85.8%
Taylor expanded in z around inf
Applied rewrites60.6%
if -4.5999999999999997e47 < z < 3.40000000000000015e-13Initial program 85.8%
Taylor expanded in x around inf
Applied rewrites78.9%
Taylor expanded in x around inf
Applied rewrites50.4%
(FPCore (x y z t a) :precision binary64 (+ x y))
double code(double x, double y, double z, double t, double a) {
return x + y;
}
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
end function
public static double code(double x, double y, double z, double t, double a) {
return x + y;
}
def code(x, y, z, t, a): return x + y
function code(x, y, z, t, a) return Float64(x + y) end
function tmp = code(x, y, z, t, a) tmp = x + y; end
code[x_, y_, z_, t_, a_] := N[(x + y), $MachinePrecision]
\begin{array}{l}
\\
x + y
\end{array}
Initial program 85.8%
Taylor expanded in z around inf
Applied rewrites60.6%
(FPCore (x y z t a) :precision binary64 y)
double code(double x, double y, double z, double t, double a) {
return y;
}
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 = y
end function
public static double code(double x, double y, double z, double t, double a) {
return y;
}
def code(x, y, z, t, a): return y
function code(x, y, z, t, a) return y end
function tmp = code(x, y, z, t, a) tmp = y; end
code[x_, y_, z_, t_, a_] := y
\begin{array}{l}
\\
y
\end{array}
Initial program 85.8%
Taylor expanded in z around inf
Applied rewrites60.6%
Taylor expanded in x around 0
Applied rewrites18.6%
herbie shell --seed 2025161
(FPCore (x y z t a)
:name "Graphics.Rendering.Plot.Render.Plot.Axis:renderAxisTicks from plot-0.2.3.4, A"
:precision binary64
(+ x (/ (* y (- z t)) (- z a))))