
(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}
Sampling outcomes in binary64 precision:
Herbie found 9 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 (/ (- z t) (- z a)) y x))
double code(double x, double y, double z, double t, double a) {
return fma(((z - t) / (z - a)), y, x);
}
function code(x, y, z, t, a) return fma(Float64(Float64(z - t) / Float64(z - a)), y, x) end
code[x_, y_, z_, t_, a_] := N[(N[(N[(z - t), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{z - t}{z - a}, y, x\right)
\end{array}
Initial program 88.2%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6497.7
Applied rewrites97.7%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma (/ z (- z a)) y x)))
(if (<= z -3.7e-81)
t_1
(if (<= z -2.3e-151)
(fma (/ (- t) z) y x)
(if (<= z 1.62e-13) (fma (/ y a) t x) t_1)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma((z / (z - a)), y, x);
double tmp;
if (z <= -3.7e-81) {
tmp = t_1;
} else if (z <= -2.3e-151) {
tmp = fma((-t / z), y, x);
} else if (z <= 1.62e-13) {
tmp = fma((y / a), t, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(z / Float64(z - a)), y, x) tmp = 0.0 if (z <= -3.7e-81) tmp = t_1; elseif (z <= -2.3e-151) tmp = fma(Float64(Float64(-t) / z), y, x); elseif (z <= 1.62e-13) tmp = fma(Float64(y / a), t, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(z / N[(z - a), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision]}, If[LessEqual[z, -3.7e-81], t$95$1, If[LessEqual[z, -2.3e-151], N[(N[((-t) / z), $MachinePrecision] * y + x), $MachinePrecision], If[LessEqual[z, 1.62e-13], N[(N[(y / a), $MachinePrecision] * t + x), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{z}{z - a}, y, x\right)\\
\mathbf{if}\;z \leq -3.7 \cdot 10^{-81}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq -2.3 \cdot 10^{-151}:\\
\;\;\;\;\mathsf{fma}\left(\frac{-t}{z}, y, x\right)\\
\mathbf{elif}\;z \leq 1.62 \cdot 10^{-13}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a}, t, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -3.69999999999999986e-81 or 1.61999999999999991e-13 < z Initial program 82.4%
Taylor expanded in t around 0
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower--.f6485.2
Applied rewrites85.2%
if -3.69999999999999986e-81 < z < -2.29999999999999996e-151Initial program 99.9%
Taylor expanded in a around 0
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower--.f6478.9
Applied rewrites78.9%
Taylor expanded in z around 0
Applied rewrites85.8%
if -2.29999999999999996e-151 < z < 1.61999999999999991e-13Initial program 95.9%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6484.5
Applied rewrites84.5%
(FPCore (x y z t a)
:precision binary64
(if (<= z -5.6e+89)
(+ y x)
(if (<= z -2.3e-151)
(fma (/ (- t) z) y x)
(if (<= z 1.9e-13) (fma (/ y a) t x) (+ y x)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -5.6e+89) {
tmp = y + x;
} else if (z <= -2.3e-151) {
tmp = fma((-t / z), y, x);
} else if (z <= 1.9e-13) {
tmp = fma((y / a), t, x);
} else {
tmp = y + x;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -5.6e+89) tmp = Float64(y + x); elseif (z <= -2.3e-151) tmp = fma(Float64(Float64(-t) / z), y, x); elseif (z <= 1.9e-13) tmp = fma(Float64(y / a), t, x); else tmp = Float64(y + x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -5.6e+89], N[(y + x), $MachinePrecision], If[LessEqual[z, -2.3e-151], N[(N[((-t) / z), $MachinePrecision] * y + x), $MachinePrecision], If[LessEqual[z, 1.9e-13], N[(N[(y / a), $MachinePrecision] * t + x), $MachinePrecision], N[(y + x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.6 \cdot 10^{+89}:\\
\;\;\;\;y + x\\
\mathbf{elif}\;z \leq -2.3 \cdot 10^{-151}:\\
\;\;\;\;\mathsf{fma}\left(\frac{-t}{z}, y, x\right)\\
\mathbf{elif}\;z \leq 1.9 \cdot 10^{-13}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a}, t, x\right)\\
\mathbf{else}:\\
\;\;\;\;y + x\\
\end{array}
\end{array}
if z < -5.5999999999999996e89 or 1.9e-13 < z Initial program 78.0%
Taylor expanded in z around inf
+-commutativeN/A
lower-+.f6481.6
Applied rewrites81.6%
if -5.5999999999999996e89 < z < -2.29999999999999996e-151Initial program 99.9%
Taylor expanded in a around 0
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower--.f6476.7
Applied rewrites76.7%
Taylor expanded in z around 0
Applied rewrites77.8%
if -2.29999999999999996e-151 < z < 1.9e-13Initial program 95.9%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6484.5
Applied rewrites84.5%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -5.8e-161) (not (<= z 2.6e-12))) (fma (/ (- z t) z) y x) (fma (/ (- z t) (- a)) y x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -5.8e-161) || !(z <= 2.6e-12)) {
tmp = fma(((z - t) / z), y, x);
} else {
tmp = fma(((z - t) / -a), y, x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -5.8e-161) || !(z <= 2.6e-12)) tmp = fma(Float64(Float64(z - t) / z), y, x); else tmp = fma(Float64(Float64(z - t) / Float64(-a)), y, x); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -5.8e-161], N[Not[LessEqual[z, 2.6e-12]], $MachinePrecision]], N[(N[(N[(z - t), $MachinePrecision] / z), $MachinePrecision] * y + x), $MachinePrecision], N[(N[(N[(z - t), $MachinePrecision] / (-a)), $MachinePrecision] * y + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.8 \cdot 10^{-161} \lor \neg \left(z \leq 2.6 \cdot 10^{-12}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{z - t}{z}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z - t}{-a}, y, x\right)\\
\end{array}
\end{array}
if z < -5.8e-161 or 2.59999999999999983e-12 < z Initial program 84.0%
Taylor expanded in a around 0
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower--.f6485.8
Applied rewrites85.8%
if -5.8e-161 < z < 2.59999999999999983e-12Initial program 95.9%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6495.7
Applied rewrites95.7%
Taylor expanded in z around 0
mul-1-negN/A
lower-neg.f6489.4
Applied rewrites89.4%
Final simplification87.0%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -5.8e-161) (not (<= z 2.6e-12))) (fma (/ (- z t) z) y x) (- x (/ (* (- z t) y) a))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -5.8e-161) || !(z <= 2.6e-12)) {
tmp = fma(((z - t) / z), y, x);
} else {
tmp = x - (((z - t) * y) / a);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -5.8e-161) || !(z <= 2.6e-12)) tmp = fma(Float64(Float64(z - t) / z), y, x); else tmp = Float64(x - Float64(Float64(Float64(z - t) * y) / a)); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -5.8e-161], N[Not[LessEqual[z, 2.6e-12]], $MachinePrecision]], N[(N[(N[(z - t), $MachinePrecision] / z), $MachinePrecision] * y + x), $MachinePrecision], N[(x - N[(N[(N[(z - t), $MachinePrecision] * y), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.8 \cdot 10^{-161} \lor \neg \left(z \leq 2.6 \cdot 10^{-12}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{z - t}{z}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\left(z - t\right) \cdot y}{a}\\
\end{array}
\end{array}
if z < -5.8e-161 or 2.59999999999999983e-12 < z Initial program 84.0%
Taylor expanded in a around 0
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower--.f6485.8
Applied rewrites85.8%
if -5.8e-161 < z < 2.59999999999999983e-12Initial program 95.9%
Taylor expanded in a around inf
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6487.6
Applied rewrites87.6%
Final simplification86.4%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -2.3e-151) (not (<= z 1.3e-13))) (fma (/ (- z t) z) y x) (fma (/ y a) t x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -2.3e-151) || !(z <= 1.3e-13)) {
tmp = fma(((z - t) / z), y, x);
} else {
tmp = fma((y / a), t, x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -2.3e-151) || !(z <= 1.3e-13)) tmp = fma(Float64(Float64(z - t) / z), y, x); else tmp = fma(Float64(y / a), t, x); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -2.3e-151], N[Not[LessEqual[z, 1.3e-13]], $MachinePrecision]], N[(N[(N[(z - t), $MachinePrecision] / z), $MachinePrecision] * y + x), $MachinePrecision], N[(N[(y / a), $MachinePrecision] * t + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.3 \cdot 10^{-151} \lor \neg \left(z \leq 1.3 \cdot 10^{-13}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{z - t}{z}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a}, t, x\right)\\
\end{array}
\end{array}
if z < -2.29999999999999996e-151 or 1.3e-13 < z Initial program 83.9%
Taylor expanded in a around 0
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower--.f6486.2
Applied rewrites86.2%
if -2.29999999999999996e-151 < z < 1.3e-13Initial program 95.9%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6484.5
Applied rewrites84.5%
Final simplification85.6%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -8.2e+117) (not (<= z 1.9e-13))) (+ y x) (fma (/ y a) t x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -8.2e+117) || !(z <= 1.9e-13)) {
tmp = y + x;
} else {
tmp = fma((y / a), t, x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -8.2e+117) || !(z <= 1.9e-13)) tmp = Float64(y + x); else tmp = fma(Float64(y / a), t, x); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -8.2e+117], N[Not[LessEqual[z, 1.9e-13]], $MachinePrecision]], N[(y + x), $MachinePrecision], N[(N[(y / a), $MachinePrecision] * t + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8.2 \cdot 10^{+117} \lor \neg \left(z \leq 1.9 \cdot 10^{-13}\right):\\
\;\;\;\;y + x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a}, t, x\right)\\
\end{array}
\end{array}
if z < -8.1999999999999999e117 or 1.9e-13 < z Initial program 77.4%
Taylor expanded in z around inf
+-commutativeN/A
lower-+.f6482.0
Applied rewrites82.0%
if -8.1999999999999999e117 < z < 1.9e-13Initial program 97.3%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6477.2
Applied rewrites77.2%
Final simplification79.4%
(FPCore (x y z t a) :precision binary64 (if (<= t 8.2e+245) (+ y x) (/ (* y t) a)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= 8.2e+245) {
tmp = y + x;
} else {
tmp = (y * t) / 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 (t <= 8.2d+245) then
tmp = y + x
else
tmp = (y * t) / a
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+245) {
tmp = y + x;
} else {
tmp = (y * t) / a;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if t <= 8.2e+245: tmp = y + x else: tmp = (y * t) / a return tmp
function code(x, y, z, t, a) tmp = 0.0 if (t <= 8.2e+245) tmp = Float64(y + x); else tmp = Float64(Float64(y * t) / a); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (t <= 8.2e+245) tmp = y + x; else tmp = (y * t) / a; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, 8.2e+245], N[(y + x), $MachinePrecision], N[(N[(y * t), $MachinePrecision] / a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq 8.2 \cdot 10^{+245}:\\
\;\;\;\;y + x\\
\mathbf{else}:\\
\;\;\;\;\frac{y \cdot t}{a}\\
\end{array}
\end{array}
if t < 8.2000000000000001e245Initial program 88.0%
Taylor expanded in z around inf
+-commutativeN/A
lower-+.f6465.4
Applied rewrites65.4%
if 8.2000000000000001e245 < t Initial program 91.6%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6475.9
Applied rewrites75.9%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6459.3
Applied rewrites59.3%
Taylor expanded in x around 0
Applied rewrites51.1%
Final simplification64.7%
(FPCore (x y z t a) :precision binary64 (+ y x))
double code(double x, double y, double z, double t, double a) {
return y + 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 = y + x
end function
public static double code(double x, double y, double z, double t, double a) {
return y + x;
}
def code(x, y, z, t, a): return y + x
function code(x, y, z, t, a) return Float64(y + x) end
function tmp = code(x, y, z, t, a) tmp = y + x; end
code[x_, y_, z_, t_, a_] := N[(y + x), $MachinePrecision]
\begin{array}{l}
\\
y + x
\end{array}
Initial program 88.2%
Taylor expanded in z around inf
+-commutativeN/A
lower-+.f6462.9
Applied rewrites62.9%
(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 2024359
(FPCore (x y z t a)
:name "Graphics.Rendering.Plot.Render.Plot.Axis:renderAxisTicks 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))))