
(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]
\frac{\left(x \cdot 2\right) \cdot y}{x - y}
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]
\frac{\left(x \cdot 2\right) \cdot y}{x - y}
(FPCore (x y)
:precision binary64
(let* ((t_0 (* (/ (+ y y) (- x y)) x)))
(if (<= y -9.5e+73)
t_0
(if (<= y 5e+39) (* (/ (+ x x) (- x y)) y) t_0))))double code(double x, double y) {
double t_0 = ((y + y) / (x - y)) * x;
double tmp;
if (y <= -9.5e+73) {
tmp = t_0;
} else if (y <= 5e+39) {
tmp = ((x + x) / (x - y)) * y;
} else {
tmp = t_0;
}
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) :: tmp
t_0 = ((y + y) / (x - y)) * x
if (y <= (-9.5d+73)) then
tmp = t_0
else if (y <= 5d+39) then
tmp = ((x + x) / (x - y)) * y
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = ((y + y) / (x - y)) * x;
double tmp;
if (y <= -9.5e+73) {
tmp = t_0;
} else if (y <= 5e+39) {
tmp = ((x + x) / (x - y)) * y;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = ((y + y) / (x - y)) * x tmp = 0 if y <= -9.5e+73: tmp = t_0 elif y <= 5e+39: tmp = ((x + x) / (x - y)) * y else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(Float64(Float64(y + y) / Float64(x - y)) * x) tmp = 0.0 if (y <= -9.5e+73) tmp = t_0; elseif (y <= 5e+39) tmp = Float64(Float64(Float64(x + x) / Float64(x - y)) * y); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = ((y + y) / (x - y)) * x; tmp = 0.0; if (y <= -9.5e+73) tmp = t_0; elseif (y <= 5e+39) tmp = ((x + x) / (x - y)) * y; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(N[(y + y), $MachinePrecision] / N[(x - y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[y, -9.5e+73], t$95$0, If[LessEqual[y, 5e+39], N[(N[(N[(x + x), $MachinePrecision] / N[(x - y), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := \frac{y + y}{x - y} \cdot x\\
\mathbf{if}\;y \leq -9.5 \cdot 10^{+73}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 5 \cdot 10^{+39}:\\
\;\;\;\;\frac{x + x}{x - y} \cdot y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if y < -9.4999999999999996e73 or 5.0000000000000002e39 < y Initial program 77.7%
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
mult-flip-revN/A
lower-/.f64N/A
count-2-revN/A
lower-+.f6489.3%
Applied rewrites89.3%
if -9.4999999999999996e73 < y < 5.0000000000000002e39Initial program 77.7%
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
mult-flip-revN/A
lower-/.f6488.1%
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f6488.1%
Applied rewrites88.1%
(FPCore (x y) :precision binary64 (let* ((t_0 (* (/ (+ x x) (- x y)) y))) (if (<= x -1.9e-221) t_0 (if (<= x 5.2e-203) (* -2.0 x) t_0))))
double code(double x, double y) {
double t_0 = ((x + x) / (x - y)) * y;
double tmp;
if (x <= -1.9e-221) {
tmp = t_0;
} else if (x <= 5.2e-203) {
tmp = -2.0 * x;
} else {
tmp = t_0;
}
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) :: tmp
t_0 = ((x + x) / (x - y)) * y
if (x <= (-1.9d-221)) then
tmp = t_0
else if (x <= 5.2d-203) then
tmp = (-2.0d0) * x
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = ((x + x) / (x - y)) * y;
double tmp;
if (x <= -1.9e-221) {
tmp = t_0;
} else if (x <= 5.2e-203) {
tmp = -2.0 * x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = ((x + x) / (x - y)) * y tmp = 0 if x <= -1.9e-221: tmp = t_0 elif x <= 5.2e-203: tmp = -2.0 * x else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(Float64(Float64(x + x) / Float64(x - y)) * y) tmp = 0.0 if (x <= -1.9e-221) tmp = t_0; elseif (x <= 5.2e-203) tmp = Float64(-2.0 * x); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = ((x + x) / (x - y)) * y; tmp = 0.0; if (x <= -1.9e-221) tmp = t_0; elseif (x <= 5.2e-203) tmp = -2.0 * x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(N[(x + x), $MachinePrecision] / N[(x - y), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[x, -1.9e-221], t$95$0, If[LessEqual[x, 5.2e-203], N[(-2.0 * x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := \frac{x + x}{x - y} \cdot y\\
\mathbf{if}\;x \leq -1.9 \cdot 10^{-221}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 5.2 \cdot 10^{-203}:\\
\;\;\;\;-2 \cdot x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if x < -1.9e-221 or 5.1999999999999995e-203 < x Initial program 77.7%
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
mult-flip-revN/A
lower-/.f6488.1%
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f6488.1%
Applied rewrites88.1%
if -1.9e-221 < x < 5.1999999999999995e-203Initial program 77.7%
Taylor expanded in x around 0
lower-*.f6451.5%
Applied rewrites51.5%
(FPCore (x y) :precision binary64 (if (<= y -3.1e+22) (* (- -2.0 (/ (+ x x) y)) x) (if (<= y 1.95e-6) (+ y y) (* -2.0 x))))
double code(double x, double y) {
double tmp;
if (y <= -3.1e+22) {
tmp = (-2.0 - ((x + x) / y)) * x;
} else if (y <= 1.95e-6) {
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 <= (-3.1d+22)) then
tmp = ((-2.0d0) - ((x + x) / y)) * x
else if (y <= 1.95d-6) 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 <= -3.1e+22) {
tmp = (-2.0 - ((x + x) / y)) * x;
} else if (y <= 1.95e-6) {
tmp = y + y;
} else {
tmp = -2.0 * x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -3.1e+22: tmp = (-2.0 - ((x + x) / y)) * x elif y <= 1.95e-6: tmp = y + y else: tmp = -2.0 * x return tmp
function code(x, y) tmp = 0.0 if (y <= -3.1e+22) tmp = Float64(Float64(-2.0 - Float64(Float64(x + x) / y)) * x); elseif (y <= 1.95e-6) 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 <= -3.1e+22) tmp = (-2.0 - ((x + x) / y)) * x; elseif (y <= 1.95e-6) tmp = y + y; else tmp = -2.0 * x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -3.1e+22], N[(N[(-2.0 - N[(N[(x + x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[y, 1.95e-6], N[(y + y), $MachinePrecision], N[(-2.0 * x), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;y \leq -3.1 \cdot 10^{+22}:\\
\;\;\;\;\left(-2 - \frac{x + x}{y}\right) \cdot x\\
\mathbf{elif}\;y \leq 1.95 \cdot 10^{-6}:\\
\;\;\;\;y + y\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot x\\
\end{array}
if y < -3.1000000000000002e22Initial program 77.7%
Taylor expanded in x around 0
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f6451.0%
Applied rewrites51.0%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6451.0%
lift--.f64N/A
sub-flipN/A
metadata-evalN/A
+-commutativeN/A
add-flipN/A
lower--.f64N/A
lift-*.f64N/A
distribute-lft-neg-outN/A
metadata-evalN/A
lift-/.f64N/A
associate-*r/N/A
count-2N/A
lift-+.f64N/A
lower-/.f6451.0%
Applied rewrites51.0%
if -3.1000000000000002e22 < y < 1.95e-6Initial program 77.7%
Taylor expanded in x around inf
lower-*.f6449.7%
Applied rewrites49.7%
lift-*.f64N/A
count-2-revN/A
lift-+.f6449.7%
Applied rewrites49.7%
if 1.95e-6 < y Initial program 77.7%
Taylor expanded in x around 0
lower-*.f6451.5%
Applied rewrites51.5%
(FPCore (x y) :precision binary64 (if (<= y -3.1e+22) (* -2.0 x) (if (<= y 1.95e-6) (+ y y) (* -2.0 x))))
double code(double x, double y) {
double tmp;
if (y <= -3.1e+22) {
tmp = -2.0 * x;
} else if (y <= 1.95e-6) {
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 <= (-3.1d+22)) then
tmp = (-2.0d0) * x
else if (y <= 1.95d-6) 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 <= -3.1e+22) {
tmp = -2.0 * x;
} else if (y <= 1.95e-6) {
tmp = y + y;
} else {
tmp = -2.0 * x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -3.1e+22: tmp = -2.0 * x elif y <= 1.95e-6: tmp = y + y else: tmp = -2.0 * x return tmp
function code(x, y) tmp = 0.0 if (y <= -3.1e+22) tmp = Float64(-2.0 * x); elseif (y <= 1.95e-6) 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 <= -3.1e+22) tmp = -2.0 * x; elseif (y <= 1.95e-6) tmp = y + y; else tmp = -2.0 * x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -3.1e+22], N[(-2.0 * x), $MachinePrecision], If[LessEqual[y, 1.95e-6], N[(y + y), $MachinePrecision], N[(-2.0 * x), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;y \leq -3.1 \cdot 10^{+22}:\\
\;\;\;\;-2 \cdot x\\
\mathbf{elif}\;y \leq 1.95 \cdot 10^{-6}:\\
\;\;\;\;y + y\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot x\\
\end{array}
if y < -3.1000000000000002e22 or 1.95e-6 < y Initial program 77.7%
Taylor expanded in x around 0
lower-*.f6451.5%
Applied rewrites51.5%
if -3.1000000000000002e22 < y < 1.95e-6Initial program 77.7%
Taylor expanded in x around inf
lower-*.f6449.7%
Applied rewrites49.7%
lift-*.f64N/A
count-2-revN/A
lift-+.f6449.7%
Applied rewrites49.7%
(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]
y + y
Initial program 77.7%
Taylor expanded in x around inf
lower-*.f6449.7%
Applied rewrites49.7%
lift-*.f64N/A
count-2-revN/A
lift-+.f6449.7%
Applied rewrites49.7%
herbie shell --seed 2025258
(FPCore (x y)
:name "Linear.Projection:perspective from linear-1.19.1.3, B"
:precision binary64
(/ (* (* x 2.0) y) (- x y)))