
(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 6 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) (- 1.0 (/ y x))))) (if (<= x -500000.0) t_0 (if (<= x 1.5) (* (/ (+ y y) (- x y)) x) t_0))))
double code(double x, double y) {
double t_0 = (y + y) / (1.0 - (y / x));
double tmp;
if (x <= -500000.0) {
tmp = t_0;
} else if (x <= 1.5) {
tmp = ((y + y) / (x - y)) * 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 = (y + y) / (1.0d0 - (y / x))
if (x <= (-500000.0d0)) then
tmp = t_0
else if (x <= 1.5d0) then
tmp = ((y + y) / (x - y)) * x
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (y + y) / (1.0 - (y / x));
double tmp;
if (x <= -500000.0) {
tmp = t_0;
} else if (x <= 1.5) {
tmp = ((y + y) / (x - y)) * x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = (y + y) / (1.0 - (y / x)) tmp = 0 if x <= -500000.0: tmp = t_0 elif x <= 1.5: tmp = ((y + y) / (x - y)) * x else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(Float64(y + y) / Float64(1.0 - Float64(y / x))) tmp = 0.0 if (x <= -500000.0) tmp = t_0; elseif (x <= 1.5) tmp = Float64(Float64(Float64(y + y) / Float64(x - y)) * x); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = (y + y) / (1.0 - (y / x)); tmp = 0.0; if (x <= -500000.0) tmp = t_0; elseif (x <= 1.5) tmp = ((y + y) / (x - y)) * x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(y + y), $MachinePrecision] / N[(1.0 - N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -500000.0], t$95$0, If[LessEqual[x, 1.5], N[(N[(N[(y + y), $MachinePrecision] / N[(x - y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := \frac{y + y}{1 - \frac{y}{x}}\\
\mathbf{if}\;x \leq -500000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.5:\\
\;\;\;\;\frac{y + y}{x - y} \cdot x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if x < -5e5 or 1.5 < x Initial program 77.2%
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-+.f6488.3%
Applied rewrites88.3%
lift-/.f64N/A
mult-flipN/A
lift-+.f64N/A
count-2-revN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
mult-flip-revN/A
frac-2negN/A
metadata-evalN/A
lower-/.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6488.1%
Applied rewrites88.1%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
lift--.f64N/A
sub-negate-revN/A
associate-*l/N/A
count-2N/A
lift-+.f64N/A
*-lft-identityN/A
associate-/r/N/A
sub-to-fractionN/A
lift-/.f64N/A
lift--.f64N/A
lower-/.f6487.7%
lift--.f64N/A
lift-/.f64N/A
sub-to-fractionN/A
*-lft-identityN/A
lower-/.f64N/A
lift--.f6487.7%
Applied rewrites87.7%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
*-inversesN/A
lift-/.f64N/A
lower--.f6487.7%
Applied rewrites87.7%
if -5e5 < x < 1.5Initial program 77.2%
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-+.f6488.3%
Applied rewrites88.3%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* (/ (+ y y) (- x y)) x)))
(if (<= y -5.4e-105)
t_0
(if (<= y 8.8e-132) (* (/ (+ 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 <= -5.4e-105) {
tmp = t_0;
} else if (y <= 8.8e-132) {
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 <= (-5.4d-105)) then
tmp = t_0
else if (y <= 8.8d-132) 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 <= -5.4e-105) {
tmp = t_0;
} else if (y <= 8.8e-132) {
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 <= -5.4e-105: tmp = t_0 elif y <= 8.8e-132: 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 <= -5.4e-105) tmp = t_0; elseif (y <= 8.8e-132) 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 <= -5.4e-105) tmp = t_0; elseif (y <= 8.8e-132) 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, -5.4e-105], t$95$0, If[LessEqual[y, 8.8e-132], 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 -5.4 \cdot 10^{-105}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 8.8 \cdot 10^{-132}:\\
\;\;\;\;\frac{x + x}{x - y} \cdot y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if y < -5.3999999999999999e-105 or 8.7999999999999996e-132 < y Initial program 77.2%
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-+.f6488.3%
Applied rewrites88.3%
if -5.3999999999999999e-105 < y < 8.7999999999999996e-132Initial program 77.2%
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.6%
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f6488.6%
Applied rewrites88.6%
(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 -1e+83)
t_2
(if (<= t_1 -5e-294)
t_0
(if (<= t_1 1e-302) t_2 (if (<= t_1 2e-38) 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 <= -1e+83) {
tmp = t_2;
} else if (t_1 <= -5e-294) {
tmp = t_0;
} else if (t_1 <= 1e-302) {
tmp = t_2;
} else if (t_1 <= 2e-38) {
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 <= (-1d+83)) then
tmp = t_2
else if (t_1 <= (-5d-294)) then
tmp = t_0
else if (t_1 <= 1d-302) then
tmp = t_2
else if (t_1 <= 2d-38) 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 <= -1e+83) {
tmp = t_2;
} else if (t_1 <= -5e-294) {
tmp = t_0;
} else if (t_1 <= 1e-302) {
tmp = t_2;
} else if (t_1 <= 2e-38) {
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 <= -1e+83: tmp = t_2 elif t_1 <= -5e-294: tmp = t_0 elif t_1 <= 1e-302: tmp = t_2 elif t_1 <= 2e-38: 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 <= -1e+83) tmp = t_2; elseif (t_1 <= -5e-294) tmp = t_0; elseif (t_1 <= 1e-302) tmp = t_2; elseif (t_1 <= 2e-38) 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 <= -1e+83) tmp = t_2; elseif (t_1 <= -5e-294) tmp = t_0; elseif (t_1 <= 1e-302) tmp = t_2; elseif (t_1 <= 2e-38) 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, -1e+83], t$95$2, If[LessEqual[t$95$1, -5e-294], t$95$0, If[LessEqual[t$95$1, 1e-302], t$95$2, If[LessEqual[t$95$1, 2e-38], t$95$0, t$95$2]]]]]]]
\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 -1 \cdot 10^{+83}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq -5 \cdot 10^{-294}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_1 \leq 10^{-302}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-38}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
if (/.f64 (*.f64 (*.f64 x #s(literal 2 binary64)) y) (-.f64 x y)) < -1e83 or -5.0000000000000003e-294 < (/.f64 (*.f64 (*.f64 x #s(literal 2 binary64)) y) (-.f64 x y)) < 9.9999999999999996e-303 or 1.9999999999999999e-38 < (/.f64 (*.f64 (*.f64 x #s(literal 2 binary64)) y) (-.f64 x y)) Initial program 77.2%
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.6%
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f6488.6%
Applied rewrites88.6%
if -1e83 < (/.f64 (*.f64 (*.f64 x #s(literal 2 binary64)) y) (-.f64 x y)) < -5.0000000000000003e-294 or 9.9999999999999996e-303 < (/.f64 (*.f64 (*.f64 x #s(literal 2 binary64)) y) (-.f64 x y)) < 1.9999999999999999e-38Initial program 77.2%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
count-2-revN/A
lower-+.f6477.3%
Applied rewrites77.3%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* (fma (/ y x) 2.0 2.0) y)) (t_1 (/ (* (+ y y) x) (- x y))))
(if (<= x -9e+166)
t_0
(if (<= x -2.2e-231)
t_1
(if (<= x 3.2e-240) (* -2.0 x) (if (<= x 5.2e+204) t_1 t_0))))))double code(double x, double y) {
double t_0 = fma((y / x), 2.0, 2.0) * y;
double t_1 = ((y + y) * x) / (x - y);
double tmp;
if (x <= -9e+166) {
tmp = t_0;
} else if (x <= -2.2e-231) {
tmp = t_1;
} else if (x <= 3.2e-240) {
tmp = -2.0 * x;
} else if (x <= 5.2e+204) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y) t_0 = Float64(fma(Float64(y / x), 2.0, 2.0) * y) t_1 = Float64(Float64(Float64(y + y) * x) / Float64(x - y)) tmp = 0.0 if (x <= -9e+166) tmp = t_0; elseif (x <= -2.2e-231) tmp = t_1; elseif (x <= 3.2e-240) tmp = Float64(-2.0 * x); elseif (x <= 5.2e+204) tmp = t_1; else tmp = t_0; end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(N[(N[(y / x), $MachinePrecision] * 2.0 + 2.0), $MachinePrecision] * y), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(y + y), $MachinePrecision] * x), $MachinePrecision] / N[(x - y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -9e+166], t$95$0, If[LessEqual[x, -2.2e-231], t$95$1, If[LessEqual[x, 3.2e-240], N[(-2.0 * x), $MachinePrecision], If[LessEqual[x, 5.2e+204], t$95$1, t$95$0]]]]]]
\begin{array}{l}
t_0 := \mathsf{fma}\left(\frac{y}{x}, 2, 2\right) \cdot y\\
t_1 := \frac{\left(y + y\right) \cdot x}{x - y}\\
\mathbf{if}\;x \leq -9 \cdot 10^{+166}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -2.2 \cdot 10^{-231}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 3.2 \cdot 10^{-240}:\\
\;\;\;\;-2 \cdot x\\
\mathbf{elif}\;x \leq 5.2 \cdot 10^{+204}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if x < -9.0000000000000006e166 or 5.2000000000000002e204 < x Initial program 77.2%
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.6%
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f6488.6%
Applied rewrites88.6%
Taylor expanded in x around inf
lower-+.f64N/A
lower-*.f64N/A
lower-/.f6449.8%
Applied rewrites49.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6449.8%
Applied rewrites49.8%
if -9.0000000000000006e166 < x < -2.2000000000000001e-231 or 3.1999999999999999e-240 < x < 5.2000000000000002e204Initial program 77.2%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
count-2-revN/A
lower-+.f6477.3%
Applied rewrites77.3%
if -2.2000000000000001e-231 < x < 3.1999999999999999e-240Initial program 77.2%
Taylor expanded in x around 0
lower-*.f6451.1%
Applied rewrites51.1%
(FPCore (x y) :precision binary64 (if (<= y -3.1e+14) (* -2.0 x) (if (<= y 2.85e+29) (+ y y) (* -2.0 x))))
double code(double x, double y) {
double tmp;
if (y <= -3.1e+14) {
tmp = -2.0 * x;
} else if (y <= 2.85e+29) {
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+14)) then
tmp = (-2.0d0) * x
else if (y <= 2.85d+29) 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+14) {
tmp = -2.0 * x;
} else if (y <= 2.85e+29) {
tmp = y + y;
} else {
tmp = -2.0 * x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -3.1e+14: tmp = -2.0 * x elif y <= 2.85e+29: tmp = y + y else: tmp = -2.0 * x return tmp
function code(x, y) tmp = 0.0 if (y <= -3.1e+14) tmp = Float64(-2.0 * x); elseif (y <= 2.85e+29) 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+14) tmp = -2.0 * x; elseif (y <= 2.85e+29) tmp = y + y; else tmp = -2.0 * x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -3.1e+14], N[(-2.0 * x), $MachinePrecision], If[LessEqual[y, 2.85e+29], N[(y + y), $MachinePrecision], N[(-2.0 * x), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;y \leq -3.1 \cdot 10^{+14}:\\
\;\;\;\;-2 \cdot x\\
\mathbf{elif}\;y \leq 2.85 \cdot 10^{+29}:\\
\;\;\;\;y + y\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot x\\
\end{array}
if y < -3.1e14 or 2.85e29 < y Initial program 77.2%
Taylor expanded in x around 0
lower-*.f6451.1%
Applied rewrites51.1%
if -3.1e14 < y < 2.85e29Initial program 77.2%
Taylor expanded in x around inf
lower-*.f6450.2%
Applied rewrites50.2%
lift-*.f64N/A
count-2-revN/A
lift-+.f6450.2%
Applied rewrites50.2%
(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.2%
Taylor expanded in x around inf
lower-*.f6450.2%
Applied rewrites50.2%
lift-*.f64N/A
count-2-revN/A
lift-+.f6450.2%
Applied rewrites50.2%
herbie shell --seed 2025202
(FPCore (x y)
:name "Linear.Projection:perspective from linear-1.19.1.3, B"
:precision binary64
(/ (* (* x 2.0) y) (- x y)))