
(FPCore (x y) :precision binary64 (/ (* (* x 2.0) y) (- x y)))
double code(double x, double y) {
return ((x * 2.0) * y) / (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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((x * 2.0d0) * y) / (x - y)
end function
public static double code(double x, double y) {
return ((x * 2.0) * y) / (x - y);
}
def code(x, y): return ((x * 2.0) * y) / (x - y)
function code(x, y) return Float64(Float64(Float64(x * 2.0) * y) / Float64(x - y)) end
function tmp = code(x, y) tmp = ((x * 2.0) * y) / (x - y); end
code[x_, y_] := N[(N[(N[(x * 2.0), $MachinePrecision] * y), $MachinePrecision] / N[(x - y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(x \cdot 2\right) \cdot y}{x - y}
\end{array}
Herbie found 5 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (/ (* (* x 2.0) y) (- x y)))
double code(double x, double y) {
return ((x * 2.0) * y) / (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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((x * 2.0d0) * y) / (x - y)
end function
public static double code(double x, double y) {
return ((x * 2.0) * y) / (x - y);
}
def code(x, y): return ((x * 2.0) * y) / (x - y)
function code(x, y) return Float64(Float64(Float64(x * 2.0) * y) / Float64(x - y)) end
function tmp = code(x, y) tmp = ((x * 2.0) * y) / (x - y); end
code[x_, y_] := N[(N[(N[(x * 2.0), $MachinePrecision] * y), $MachinePrecision] / N[(x - y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(x \cdot 2\right) \cdot y}{x - y}
\end{array}
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (* (+ y y) x) (- x y)))
(t_1 (/ (* (* x 2.0) y) (- x y)))
(t_2 (* (/ (+ x x) (- x y)) y)))
(if (<= t_1 -2e-14)
(/ (+ y y) (/ (- x y) x))
(if (<= t_1 -2e-304)
t_0
(if (<= t_1 0.0) t_2 (if (<= t_1 1e-35) t_0 t_2))))))
double code(double x, double y) {
double t_0 = ((y + y) * x) / (x - y);
double t_1 = ((x * 2.0) * y) / (x - y);
double t_2 = ((x + x) / (x - y)) * y;
double tmp;
if (t_1 <= -2e-14) {
tmp = (y + y) / ((x - y) / x);
} else if (t_1 <= -2e-304) {
tmp = t_0;
} else if (t_1 <= 0.0) {
tmp = t_2;
} else if (t_1 <= 1e-35) {
tmp = t_0;
} else {
tmp = t_2;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = ((y + y) * x) / (x - y)
t_1 = ((x * 2.0d0) * y) / (x - y)
t_2 = ((x + x) / (x - y)) * y
if (t_1 <= (-2d-14)) then
tmp = (y + y) / ((x - y) / x)
else if (t_1 <= (-2d-304)) then
tmp = t_0
else if (t_1 <= 0.0d0) then
tmp = t_2
else if (t_1 <= 1d-35) then
tmp = t_0
else
tmp = t_2
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = ((y + y) * x) / (x - y);
double t_1 = ((x * 2.0) * y) / (x - y);
double t_2 = ((x + x) / (x - y)) * y;
double tmp;
if (t_1 <= -2e-14) {
tmp = (y + y) / ((x - y) / x);
} else if (t_1 <= -2e-304) {
tmp = t_0;
} else if (t_1 <= 0.0) {
tmp = t_2;
} else if (t_1 <= 1e-35) {
tmp = t_0;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y): t_0 = ((y + y) * x) / (x - y) t_1 = ((x * 2.0) * y) / (x - y) t_2 = ((x + x) / (x - y)) * y tmp = 0 if t_1 <= -2e-14: tmp = (y + y) / ((x - y) / x) elif t_1 <= -2e-304: tmp = t_0 elif t_1 <= 0.0: tmp = t_2 elif t_1 <= 1e-35: tmp = t_0 else: tmp = t_2 return tmp
function code(x, y) t_0 = Float64(Float64(Float64(y + y) * x) / Float64(x - y)) t_1 = Float64(Float64(Float64(x * 2.0) * y) / Float64(x - y)) t_2 = Float64(Float64(Float64(x + x) / Float64(x - y)) * y) tmp = 0.0 if (t_1 <= -2e-14) tmp = Float64(Float64(y + y) / Float64(Float64(x - y) / x)); elseif (t_1 <= -2e-304) tmp = t_0; elseif (t_1 <= 0.0) tmp = t_2; elseif (t_1 <= 1e-35) tmp = t_0; else tmp = t_2; end return tmp end
function tmp_2 = code(x, y) t_0 = ((y + y) * x) / (x - y); t_1 = ((x * 2.0) * y) / (x - y); t_2 = ((x + x) / (x - y)) * y; tmp = 0.0; if (t_1 <= -2e-14) tmp = (y + y) / ((x - y) / x); elseif (t_1 <= -2e-304) tmp = t_0; elseif (t_1 <= 0.0) tmp = t_2; elseif (t_1 <= 1e-35) tmp = t_0; else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(N[(y + y), $MachinePrecision] * x), $MachinePrecision] / N[(x - y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(x * 2.0), $MachinePrecision] * y), $MachinePrecision] / N[(x - y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(x + x), $MachinePrecision] / N[(x - y), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[t$95$1, -2e-14], N[(N[(y + y), $MachinePrecision] / N[(N[(x - y), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -2e-304], t$95$0, If[LessEqual[t$95$1, 0.0], t$95$2, If[LessEqual[t$95$1, 1e-35], t$95$0, t$95$2]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\left(y + y\right) \cdot x}{x - y}\\
t_1 := \frac{\left(x \cdot 2\right) \cdot y}{x - y}\\
t_2 := \frac{x + x}{x - y} \cdot y\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{-14}:\\
\;\;\;\;\frac{y + y}{\frac{x - y}{x}}\\
\mathbf{elif}\;t\_1 \leq -2 \cdot 10^{-304}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 10^{-35}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (/.f64 (*.f64 (*.f64 x #s(literal 2 binary64)) y) (-.f64 x y)) < -2e-14Initial program 77.5%
Applied rewrites89.1%
Applied rewrites88.3%
Applied rewrites88.3%
if -2e-14 < (/.f64 (*.f64 (*.f64 x #s(literal 2 binary64)) y) (-.f64 x y)) < -1.99999999999999994e-304 or 0.0 < (/.f64 (*.f64 (*.f64 x #s(literal 2 binary64)) y) (-.f64 x y)) < 1.00000000000000001e-35Initial program 77.5%
Applied rewrites77.5%
if -1.99999999999999994e-304 < (/.f64 (*.f64 (*.f64 x #s(literal 2 binary64)) y) (-.f64 x y)) < 0.0 or 1.00000000000000001e-35 < (/.f64 (*.f64 (*.f64 x #s(literal 2 binary64)) y) (-.f64 x y)) Initial program 77.5%
Applied rewrites89.1%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (* (+ y y) x) (- x y)))
(t_1 (/ (* (* x 2.0) y) (- x y)))
(t_2 (* (/ (+ x x) (- x y)) y)))
(if (<= t_1 -2e-14)
t_2
(if (<= t_1 -2e-304)
t_0
(if (<= t_1 0.0) t_2 (if (<= t_1 1e-35) t_0 t_2))))))
double code(double x, double y) {
double t_0 = ((y + y) * x) / (x - y);
double t_1 = ((x * 2.0) * y) / (x - y);
double t_2 = ((x + x) / (x - y)) * y;
double tmp;
if (t_1 <= -2e-14) {
tmp = t_2;
} else if (t_1 <= -2e-304) {
tmp = t_0;
} else if (t_1 <= 0.0) {
tmp = t_2;
} else if (t_1 <= 1e-35) {
tmp = t_0;
} else {
tmp = t_2;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = ((y + y) * x) / (x - y)
t_1 = ((x * 2.0d0) * y) / (x - y)
t_2 = ((x + x) / (x - y)) * y
if (t_1 <= (-2d-14)) then
tmp = t_2
else if (t_1 <= (-2d-304)) then
tmp = t_0
else if (t_1 <= 0.0d0) then
tmp = t_2
else if (t_1 <= 1d-35) then
tmp = t_0
else
tmp = t_2
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = ((y + y) * x) / (x - y);
double t_1 = ((x * 2.0) * y) / (x - y);
double t_2 = ((x + x) / (x - y)) * y;
double tmp;
if (t_1 <= -2e-14) {
tmp = t_2;
} else if (t_1 <= -2e-304) {
tmp = t_0;
} else if (t_1 <= 0.0) {
tmp = t_2;
} else if (t_1 <= 1e-35) {
tmp = t_0;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y): t_0 = ((y + y) * x) / (x - y) t_1 = ((x * 2.0) * y) / (x - y) t_2 = ((x + x) / (x - y)) * y tmp = 0 if t_1 <= -2e-14: tmp = t_2 elif t_1 <= -2e-304: tmp = t_0 elif t_1 <= 0.0: tmp = t_2 elif t_1 <= 1e-35: tmp = t_0 else: tmp = t_2 return tmp
function code(x, y) t_0 = Float64(Float64(Float64(y + y) * x) / Float64(x - y)) t_1 = Float64(Float64(Float64(x * 2.0) * y) / Float64(x - y)) t_2 = Float64(Float64(Float64(x + x) / Float64(x - y)) * y) tmp = 0.0 if (t_1 <= -2e-14) tmp = t_2; elseif (t_1 <= -2e-304) tmp = t_0; elseif (t_1 <= 0.0) tmp = t_2; elseif (t_1 <= 1e-35) tmp = t_0; else tmp = t_2; end return tmp end
function tmp_2 = code(x, y) t_0 = ((y + y) * x) / (x - y); t_1 = ((x * 2.0) * y) / (x - y); t_2 = ((x + x) / (x - y)) * y; tmp = 0.0; if (t_1 <= -2e-14) tmp = t_2; elseif (t_1 <= -2e-304) tmp = t_0; elseif (t_1 <= 0.0) tmp = t_2; elseif (t_1 <= 1e-35) tmp = t_0; else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(N[(y + y), $MachinePrecision] * x), $MachinePrecision] / N[(x - y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(x * 2.0), $MachinePrecision] * y), $MachinePrecision] / N[(x - y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(x + x), $MachinePrecision] / N[(x - y), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[t$95$1, -2e-14], t$95$2, If[LessEqual[t$95$1, -2e-304], t$95$0, If[LessEqual[t$95$1, 0.0], t$95$2, If[LessEqual[t$95$1, 1e-35], t$95$0, t$95$2]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\left(y + y\right) \cdot x}{x - y}\\
t_1 := \frac{\left(x \cdot 2\right) \cdot y}{x - y}\\
t_2 := \frac{x + x}{x - y} \cdot y\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{-14}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq -2 \cdot 10^{-304}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 10^{-35}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (/.f64 (*.f64 (*.f64 x #s(literal 2 binary64)) y) (-.f64 x y)) < -2e-14 or -1.99999999999999994e-304 < (/.f64 (*.f64 (*.f64 x #s(literal 2 binary64)) y) (-.f64 x y)) < 0.0 or 1.00000000000000001e-35 < (/.f64 (*.f64 (*.f64 x #s(literal 2 binary64)) y) (-.f64 x y)) Initial program 77.5%
Applied rewrites89.1%
if -2e-14 < (/.f64 (*.f64 (*.f64 x #s(literal 2 binary64)) y) (-.f64 x y)) < -1.99999999999999994e-304 or 0.0 < (/.f64 (*.f64 (*.f64 x #s(literal 2 binary64)) y) (-.f64 x y)) < 1.00000000000000001e-35Initial program 77.5%
Applied rewrites77.5%
(FPCore (x y) :precision binary64 (if (<= y -1.75e+152) (* -2.0 x) (if (<= y 5e+206) (* (/ (+ x x) (- x y)) y) (* -2.0 x))))
double code(double x, double y) {
double tmp;
if (y <= -1.75e+152) {
tmp = -2.0 * x;
} else if (y <= 5e+206) {
tmp = ((x + x) / (x - y)) * y;
} else {
tmp = -2.0 * 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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-1.75d+152)) then
tmp = (-2.0d0) * x
else if (y <= 5d+206) then
tmp = ((x + x) / (x - y)) * y
else
tmp = (-2.0d0) * x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -1.75e+152) {
tmp = -2.0 * x;
} else if (y <= 5e+206) {
tmp = ((x + x) / (x - y)) * y;
} else {
tmp = -2.0 * x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.75e+152: tmp = -2.0 * x elif y <= 5e+206: tmp = ((x + x) / (x - y)) * y else: tmp = -2.0 * x return tmp
function code(x, y) tmp = 0.0 if (y <= -1.75e+152) tmp = Float64(-2.0 * x); elseif (y <= 5e+206) tmp = Float64(Float64(Float64(x + x) / Float64(x - y)) * y); else tmp = Float64(-2.0 * x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.75e+152) tmp = -2.0 * x; elseif (y <= 5e+206) tmp = ((x + x) / (x - y)) * y; else tmp = -2.0 * x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.75e+152], N[(-2.0 * x), $MachinePrecision], If[LessEqual[y, 5e+206], N[(N[(N[(x + x), $MachinePrecision] / N[(x - y), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], N[(-2.0 * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.75 \cdot 10^{+152}:\\
\;\;\;\;-2 \cdot x\\
\mathbf{elif}\;y \leq 5 \cdot 10^{+206}:\\
\;\;\;\;\frac{x + x}{x - y} \cdot y\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot x\\
\end{array}
\end{array}
if y < -1.74999999999999991e152 or 5.0000000000000002e206 < y Initial program 77.5%
Taylor expanded in x around 0
Applied rewrites51.5%
if -1.74999999999999991e152 < y < 5.0000000000000002e206Initial program 77.5%
Applied rewrites89.1%
(FPCore (x y) :precision binary64 (if (<= y -2.4e+32) (* -2.0 x) (if (<= y 2.05e-45) (+ y y) (* -2.0 x))))
double code(double x, double y) {
double tmp;
if (y <= -2.4e+32) {
tmp = -2.0 * x;
} else if (y <= 2.05e-45) {
tmp = y + y;
} else {
tmp = -2.0 * 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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-2.4d+32)) then
tmp = (-2.0d0) * x
else if (y <= 2.05d-45) then
tmp = y + y
else
tmp = (-2.0d0) * x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -2.4e+32) {
tmp = -2.0 * x;
} else if (y <= 2.05e-45) {
tmp = y + y;
} else {
tmp = -2.0 * x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -2.4e+32: tmp = -2.0 * x elif y <= 2.05e-45: tmp = y + y else: tmp = -2.0 * x return tmp
function code(x, y) tmp = 0.0 if (y <= -2.4e+32) tmp = Float64(-2.0 * x); elseif (y <= 2.05e-45) tmp = Float64(y + y); else tmp = Float64(-2.0 * x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -2.4e+32) tmp = -2.0 * x; elseif (y <= 2.05e-45) tmp = y + y; else tmp = -2.0 * x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -2.4e+32], N[(-2.0 * x), $MachinePrecision], If[LessEqual[y, 2.05e-45], N[(y + y), $MachinePrecision], N[(-2.0 * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.4 \cdot 10^{+32}:\\
\;\;\;\;-2 \cdot x\\
\mathbf{elif}\;y \leq 2.05 \cdot 10^{-45}:\\
\;\;\;\;y + y\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot x\\
\end{array}
\end{array}
if y < -2.39999999999999991e32 or 2.05e-45 < y Initial program 77.5%
Taylor expanded in x around 0
Applied rewrites51.5%
if -2.39999999999999991e32 < y < 2.05e-45Initial program 77.5%
Taylor expanded in x around inf
Applied rewrites49.8%
Applied rewrites49.8%
(FPCore (x y) :precision binary64 (+ y y))
double code(double x, double y) {
return y + 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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = y + y
end function
public static double code(double x, double y) {
return y + y;
}
def code(x, y): return y + y
function code(x, y) return Float64(y + y) end
function tmp = code(x, y) tmp = y + y; end
code[x_, y_] := N[(y + y), $MachinePrecision]
\begin{array}{l}
\\
y + y
\end{array}
Initial program 77.5%
Taylor expanded in x around inf
Applied rewrites49.8%
Applied rewrites49.8%
herbie shell --seed 2025153
(FPCore (x y)
:name "Linear.Projection:perspective from linear-1.19.1.3, B"
:precision binary64
(/ (* (* x 2.0) y) (- x y)))