
(FPCore (x y z) :precision binary64 (/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0)))
double code(double x, double y, double z) {
return (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (((x * x) + (y * y)) - (z * z)) / (y * 2.0d0)
end function
public static double code(double x, double y, double z) {
return (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
}
def code(x, y, z): return (((x * x) + (y * y)) - (z * z)) / (y * 2.0)
function code(x, y, z) return Float64(Float64(Float64(Float64(x * x) + Float64(y * y)) - Float64(z * z)) / Float64(y * 2.0)) end
function tmp = code(x, y, z) tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0); end
code[x_, y_, z_] := N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}
\end{array}
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0)))
double code(double x, double y, double z) {
return (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (((x * x) + (y * y)) - (z * z)) / (y * 2.0d0)
end function
public static double code(double x, double y, double z) {
return (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
}
def code(x, y, z): return (((x * x) + (y * y)) - (z * z)) / (y * 2.0)
function code(x, y, z) return Float64(Float64(Float64(Float64(x * x) + Float64(y * y)) - Float64(z * z)) / Float64(y * 2.0)) end
function tmp = code(x, y, z) tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0); end
code[x_, y_, z_] := N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}
\end{array}
(FPCore (x y z) :precision binary64 (fma (+ z x) (* (/ (- x z) y) 0.5) (* 0.5 y)))
double code(double x, double y, double z) {
return fma((z + x), (((x - z) / y) * 0.5), (0.5 * y));
}
function code(x, y, z) return fma(Float64(z + x), Float64(Float64(Float64(x - z) / y) * 0.5), Float64(0.5 * y)) end
code[x_, y_, z_] := N[(N[(z + x), $MachinePrecision] * N[(N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision] * 0.5), $MachinePrecision] + N[(0.5 * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(z + x, \frac{x - z}{y} \cdot 0.5, 0.5 \cdot y\right)
\end{array}
Initial program 69.4%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
pow2N/A
div-subN/A
lower--.f64N/A
lower-/.f64N/A
pow2N/A
pow2N/A
+-commutativeN/A
pow2N/A
lower-fma.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f64N/A
Applied rewrites67.6%
Taylor expanded in x around 0
associate--l+N/A
associate-*r/N/A
associate-*r/N/A
div-subN/A
distribute-lft-out--N/A
pow2N/A
pow2N/A
difference-of-squares-revN/A
associate-*r/N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.9%
lift-fma.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift--.f64N/A
lift-/.f64N/A
+-commutativeN/A
associate-*l*N/A
lower-fma.f64N/A
lift-+.f64N/A
lower-*.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-*.f6499.9
Applied rewrites99.9%
(FPCore (x y z) :precision binary64 (fma 0.5 y (* (* (+ z x) (/ (- x z) y)) 0.5)))
double code(double x, double y, double z) {
return fma(0.5, y, (((z + x) * ((x - z) / y)) * 0.5));
}
function code(x, y, z) return fma(0.5, y, Float64(Float64(Float64(z + x) * Float64(Float64(x - z) / y)) * 0.5)) end
code[x_, y_, z_] := N[(0.5 * y + N[(N[(N[(z + x), $MachinePrecision] * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(0.5, y, \left(\left(z + x\right) \cdot \frac{x - z}{y}\right) \cdot 0.5\right)
\end{array}
Initial program 69.4%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
pow2N/A
div-subN/A
lower--.f64N/A
lower-/.f64N/A
pow2N/A
pow2N/A
+-commutativeN/A
pow2N/A
lower-fma.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f64N/A
Applied rewrites67.6%
Taylor expanded in x around 0
associate--l+N/A
associate-*r/N/A
associate-*r/N/A
div-subN/A
distribute-lft-out--N/A
pow2N/A
pow2N/A
difference-of-squares-revN/A
associate-*r/N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (- x z) y)))
(if (<= (/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0)) -5e-129)
(* (* (+ z x) t_0) 0.5)
(fma 0.5 y (* (* x t_0) 0.5)))))
double code(double x, double y, double z) {
double t_0 = (x - z) / y;
double tmp;
if (((((x * x) + (y * y)) - (z * z)) / (y * 2.0)) <= -5e-129) {
tmp = ((z + x) * t_0) * 0.5;
} else {
tmp = fma(0.5, y, ((x * t_0) * 0.5));
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(x - z) / y) tmp = 0.0 if (Float64(Float64(Float64(Float64(x * x) + Float64(y * y)) - Float64(z * z)) / Float64(y * 2.0)) <= -5e-129) tmp = Float64(Float64(Float64(z + x) * t_0) * 0.5); else tmp = fma(0.5, y, Float64(Float64(x * t_0) * 0.5)); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision], -5e-129], N[(N[(N[(z + x), $MachinePrecision] * t$95$0), $MachinePrecision] * 0.5), $MachinePrecision], N[(0.5 * y + N[(N[(x * t$95$0), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x - z}{y}\\
\mathbf{if}\;\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \leq -5 \cdot 10^{-129}:\\
\;\;\;\;\left(\left(z + x\right) \cdot t\_0\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.5, y, \left(x \cdot t\_0\right) \cdot 0.5\right)\\
\end{array}
\end{array}
if (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y #s(literal 2 binary64))) < -5.00000000000000027e-129Initial program 79.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
pow2N/A
pow2N/A
difference-of-squaresN/A
lower-*.f64N/A
lower-+.f64N/A
lower--.f64N/A
pow2N/A
lift-*.f6483.2
Applied rewrites83.2%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift--.f6466.8
Applied rewrites66.8%
if -5.00000000000000027e-129 < (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y #s(literal 2 binary64))) Initial program 61.8%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
pow2N/A
div-subN/A
lower--.f64N/A
lower-/.f64N/A
pow2N/A
pow2N/A
+-commutativeN/A
pow2N/A
lower-fma.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f64N/A
Applied rewrites61.8%
Taylor expanded in x around 0
associate--l+N/A
associate-*r/N/A
associate-*r/N/A
div-subN/A
distribute-lft-out--N/A
pow2N/A
pow2N/A
difference-of-squares-revN/A
associate-*r/N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.9%
Taylor expanded in x around inf
Applied rewrites72.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (* (+ z x) (/ (- x z) y)) 0.5))
(t_1 (/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0))))
(if (<= t_1 -5e-129)
t_0
(if (<= t_1 INFINITY) (* 0.5 (+ (/ (* x x) y) y)) t_0))))
double code(double x, double y, double z) {
double t_0 = ((z + x) * ((x - z) / y)) * 0.5;
double t_1 = (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
double tmp;
if (t_1 <= -5e-129) {
tmp = t_0;
} else if (t_1 <= ((double) INFINITY)) {
tmp = 0.5 * (((x * x) / y) + y);
} else {
tmp = t_0;
}
return tmp;
}
public static double code(double x, double y, double z) {
double t_0 = ((z + x) * ((x - z) / y)) * 0.5;
double t_1 = (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
double tmp;
if (t_1 <= -5e-129) {
tmp = t_0;
} else if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = 0.5 * (((x * x) / y) + y);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = ((z + x) * ((x - z) / y)) * 0.5 t_1 = (((x * x) + (y * y)) - (z * z)) / (y * 2.0) tmp = 0 if t_1 <= -5e-129: tmp = t_0 elif t_1 <= math.inf: tmp = 0.5 * (((x * x) / y) + y) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(Float64(z + x) * Float64(Float64(x - z) / y)) * 0.5) t_1 = Float64(Float64(Float64(Float64(x * x) + Float64(y * y)) - Float64(z * z)) / Float64(y * 2.0)) tmp = 0.0 if (t_1 <= -5e-129) tmp = t_0; elseif (t_1 <= Inf) tmp = Float64(0.5 * Float64(Float64(Float64(x * x) / y) + y)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = ((z + x) * ((x - z) / y)) * 0.5; t_1 = (((x * x) + (y * y)) - (z * z)) / (y * 2.0); tmp = 0.0; if (t_1 <= -5e-129) tmp = t_0; elseif (t_1 <= Inf) tmp = 0.5 * (((x * x) / y) + y); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(z + x), $MachinePrecision] * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -5e-129], t$95$0, If[LessEqual[t$95$1, Infinity], N[(0.5 * N[(N[(N[(x * x), $MachinePrecision] / y), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(z + x\right) \cdot \frac{x - z}{y}\right) \cdot 0.5\\
t_1 := \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{-129}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;0.5 \cdot \left(\frac{x \cdot x}{y} + y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y #s(literal 2 binary64))) < -5.00000000000000027e-129 or +inf.0 < (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y #s(literal 2 binary64))) Initial program 63.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
pow2N/A
pow2N/A
difference-of-squaresN/A
lower-*.f64N/A
lower-+.f64N/A
lower--.f64N/A
pow2N/A
lift-*.f6474.9
Applied rewrites74.9%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift--.f6468.1
Applied rewrites68.1%
if -5.00000000000000027e-129 < (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y #s(literal 2 binary64))) < +inf.0Initial program 77.3%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
pow2N/A
div-subN/A
lower--.f64N/A
lower-/.f64N/A
pow2N/A
pow2N/A
+-commutativeN/A
pow2N/A
lower-fma.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f64N/A
Applied rewrites74.8%
Taylor expanded in x around 0
associate--l+N/A
associate-*r/N/A
associate-*r/N/A
div-subN/A
distribute-lft-out--N/A
pow2N/A
pow2N/A
difference-of-squares-revN/A
associate-*r/N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.9%
Taylor expanded in z around 0
distribute-lft-outN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6463.4
Applied rewrites63.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0))))
(if (<= t_0 -5e-129)
(* 0.5 (- y (* z (/ z y))))
(if (<= t_0 INFINITY)
(* 0.5 (+ (/ (* x x) y) y))
(* (* x (/ (- x z) y)) 0.5)))))
double code(double x, double y, double z) {
double t_0 = (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
double tmp;
if (t_0 <= -5e-129) {
tmp = 0.5 * (y - (z * (z / y)));
} else if (t_0 <= ((double) INFINITY)) {
tmp = 0.5 * (((x * x) / y) + y);
} else {
tmp = (x * ((x - z) / y)) * 0.5;
}
return tmp;
}
public static double code(double x, double y, double z) {
double t_0 = (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
double tmp;
if (t_0 <= -5e-129) {
tmp = 0.5 * (y - (z * (z / y)));
} else if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = 0.5 * (((x * x) / y) + y);
} else {
tmp = (x * ((x - z) / y)) * 0.5;
}
return tmp;
}
def code(x, y, z): t_0 = (((x * x) + (y * y)) - (z * z)) / (y * 2.0) tmp = 0 if t_0 <= -5e-129: tmp = 0.5 * (y - (z * (z / y))) elif t_0 <= math.inf: tmp = 0.5 * (((x * x) / y) + y) else: tmp = (x * ((x - z) / y)) * 0.5 return tmp
function code(x, y, z) t_0 = Float64(Float64(Float64(Float64(x * x) + Float64(y * y)) - Float64(z * z)) / Float64(y * 2.0)) tmp = 0.0 if (t_0 <= -5e-129) tmp = Float64(0.5 * Float64(y - Float64(z * Float64(z / y)))); elseif (t_0 <= Inf) tmp = Float64(0.5 * Float64(Float64(Float64(x * x) / y) + y)); else tmp = Float64(Float64(x * Float64(Float64(x - z) / y)) * 0.5); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (((x * x) + (y * y)) - (z * z)) / (y * 2.0); tmp = 0.0; if (t_0 <= -5e-129) tmp = 0.5 * (y - (z * (z / y))); elseif (t_0 <= Inf) tmp = 0.5 * (((x * x) / y) + y); else tmp = (x * ((x - z) / y)) * 0.5; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -5e-129], N[(0.5 * N[(y - N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[(0.5 * N[(N[(N[(x * x), $MachinePrecision] / y), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{-129}:\\
\;\;\;\;0.5 \cdot \left(y - z \cdot \frac{z}{y}\right)\\
\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;0.5 \cdot \left(\frac{x \cdot x}{y} + y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot \frac{x - z}{y}\right) \cdot 0.5\\
\end{array}
\end{array}
if (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y #s(literal 2 binary64))) < -5.00000000000000027e-129Initial program 79.0%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
pow2N/A
div-subN/A
lower--.f64N/A
lower-/.f64N/A
pow2N/A
pow2N/A
+-commutativeN/A
pow2N/A
lower-fma.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f64N/A
Applied rewrites75.1%
Taylor expanded in x around 0
distribute-lft-out--N/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
pow2N/A
lower-*.f6465.2
Applied rewrites65.2%
lift-*.f64N/A
lift-/.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6466.3
Applied rewrites66.3%
if -5.00000000000000027e-129 < (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y #s(literal 2 binary64))) < +inf.0Initial program 77.3%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
pow2N/A
div-subN/A
lower--.f64N/A
lower-/.f64N/A
pow2N/A
pow2N/A
+-commutativeN/A
pow2N/A
lower-fma.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f64N/A
Applied rewrites74.8%
Taylor expanded in x around 0
associate--l+N/A
associate-*r/N/A
associate-*r/N/A
div-subN/A
distribute-lft-out--N/A
pow2N/A
pow2N/A
difference-of-squares-revN/A
associate-*r/N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.9%
Taylor expanded in z around 0
distribute-lft-outN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6463.4
Applied rewrites63.4%
if +inf.0 < (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y #s(literal 2 binary64))) Initial program 0.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
pow2N/A
pow2N/A
difference-of-squaresN/A
lower-*.f64N/A
lower-+.f64N/A
lower--.f64N/A
pow2N/A
lift-*.f6442.3
Applied rewrites42.3%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift--.f6473.3
Applied rewrites73.3%
Taylor expanded in x around inf
Applied rewrites40.9%
(FPCore (x y z) :precision binary64 (if (<= x 7e+53) (* 0.5 (- y (* z (/ z y)))) (* (* x (/ (- x z) y)) 0.5)))
double code(double x, double y, double z) {
double tmp;
if (x <= 7e+53) {
tmp = 0.5 * (y - (z * (z / y)));
} else {
tmp = (x * ((x - z) / y)) * 0.5;
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x <= 7d+53) then
tmp = 0.5d0 * (y - (z * (z / y)))
else
tmp = (x * ((x - z) / y)) * 0.5d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= 7e+53) {
tmp = 0.5 * (y - (z * (z / y)));
} else {
tmp = (x * ((x - z) / y)) * 0.5;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 7e+53: tmp = 0.5 * (y - (z * (z / y))) else: tmp = (x * ((x - z) / y)) * 0.5 return tmp
function code(x, y, z) tmp = 0.0 if (x <= 7e+53) tmp = Float64(0.5 * Float64(y - Float64(z * Float64(z / y)))); else tmp = Float64(Float64(x * Float64(Float64(x - z) / y)) * 0.5); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 7e+53) tmp = 0.5 * (y - (z * (z / y))); else tmp = (x * ((x - z) / y)) * 0.5; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 7e+53], N[(0.5 * N[(y - N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 7 \cdot 10^{+53}:\\
\;\;\;\;0.5 \cdot \left(y - z \cdot \frac{z}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot \frac{x - z}{y}\right) \cdot 0.5\\
\end{array}
\end{array}
if x < 7.00000000000000038e53Initial program 70.7%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
pow2N/A
div-subN/A
lower--.f64N/A
lower-/.f64N/A
pow2N/A
pow2N/A
+-commutativeN/A
pow2N/A
lower-fma.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f64N/A
Applied rewrites70.2%
Taylor expanded in x around 0
distribute-lft-out--N/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
pow2N/A
lower-*.f6469.3
Applied rewrites69.3%
lift-*.f64N/A
lift-/.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6475.3
Applied rewrites75.3%
if 7.00000000000000038e53 < x Initial program 64.4%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
pow2N/A
pow2N/A
difference-of-squaresN/A
lower-*.f64N/A
lower-+.f64N/A
lower--.f64N/A
pow2N/A
lift-*.f6477.2
Applied rewrites77.2%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift--.f6483.7
Applied rewrites83.7%
Taylor expanded in x around inf
Applied rewrites72.0%
(FPCore (x y z) :precision binary64 (if (<= x 2.8e+121) (* 0.5 (- y (* z (/ z y)))) (/ (* x x) (+ y y))))
double code(double x, double y, double z) {
double tmp;
if (x <= 2.8e+121) {
tmp = 0.5 * (y - (z * (z / y)));
} else {
tmp = (x * x) / (y + y);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x <= 2.8d+121) then
tmp = 0.5d0 * (y - (z * (z / y)))
else
tmp = (x * x) / (y + y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= 2.8e+121) {
tmp = 0.5 * (y - (z * (z / y)));
} else {
tmp = (x * x) / (y + y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 2.8e+121: tmp = 0.5 * (y - (z * (z / y))) else: tmp = (x * x) / (y + y) return tmp
function code(x, y, z) tmp = 0.0 if (x <= 2.8e+121) tmp = Float64(0.5 * Float64(y - Float64(z * Float64(z / y)))); else tmp = Float64(Float64(x * x) / Float64(y + y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 2.8e+121) tmp = 0.5 * (y - (z * (z / y))); else tmp = (x * x) / (y + y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 2.8e+121], N[(0.5 * N[(y - N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] / N[(y + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.8 \cdot 10^{+121}:\\
\;\;\;\;0.5 \cdot \left(y - z \cdot \frac{z}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot x}{y + y}\\
\end{array}
\end{array}
if x < 2.80000000000000006e121Initial program 71.2%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
pow2N/A
div-subN/A
lower--.f64N/A
lower-/.f64N/A
pow2N/A
pow2N/A
+-commutativeN/A
pow2N/A
lower-fma.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f64N/A
Applied rewrites70.0%
Taylor expanded in x around 0
distribute-lft-out--N/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
pow2N/A
lower-*.f6468.2
Applied rewrites68.2%
lift-*.f64N/A
lift-/.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6474.2
Applied rewrites74.2%
if 2.80000000000000006e121 < x Initial program 59.6%
Taylor expanded in x around inf
pow2N/A
lift-*.f6466.6
Applied rewrites66.6%
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lift-+.f6466.6
Applied rewrites66.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0))))
(if (<= t_0 -5e-129)
(* -0.5 (/ (* z z) y))
(if (<= t_0 1e+151) (* 0.5 y) (/ (* x x) (+ y y))))))
double code(double x, double y, double z) {
double t_0 = (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
double tmp;
if (t_0 <= -5e-129) {
tmp = -0.5 * ((z * z) / y);
} else if (t_0 <= 1e+151) {
tmp = 0.5 * y;
} else {
tmp = (x * x) / (y + y);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = (((x * x) + (y * y)) - (z * z)) / (y * 2.0d0)
if (t_0 <= (-5d-129)) then
tmp = (-0.5d0) * ((z * z) / y)
else if (t_0 <= 1d+151) then
tmp = 0.5d0 * y
else
tmp = (x * x) / (y + y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
double tmp;
if (t_0 <= -5e-129) {
tmp = -0.5 * ((z * z) / y);
} else if (t_0 <= 1e+151) {
tmp = 0.5 * y;
} else {
tmp = (x * x) / (y + y);
}
return tmp;
}
def code(x, y, z): t_0 = (((x * x) + (y * y)) - (z * z)) / (y * 2.0) tmp = 0 if t_0 <= -5e-129: tmp = -0.5 * ((z * z) / y) elif t_0 <= 1e+151: tmp = 0.5 * y else: tmp = (x * x) / (y + y) return tmp
function code(x, y, z) t_0 = Float64(Float64(Float64(Float64(x * x) + Float64(y * y)) - Float64(z * z)) / Float64(y * 2.0)) tmp = 0.0 if (t_0 <= -5e-129) tmp = Float64(-0.5 * Float64(Float64(z * z) / y)); elseif (t_0 <= 1e+151) tmp = Float64(0.5 * y); else tmp = Float64(Float64(x * x) / Float64(y + y)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (((x * x) + (y * y)) - (z * z)) / (y * 2.0); tmp = 0.0; if (t_0 <= -5e-129) tmp = -0.5 * ((z * z) / y); elseif (t_0 <= 1e+151) tmp = 0.5 * y; else tmp = (x * x) / (y + y); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -5e-129], N[(-0.5 * N[(N[(z * z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e+151], N[(0.5 * y), $MachinePrecision], N[(N[(x * x), $MachinePrecision] / N[(y + y), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{-129}:\\
\;\;\;\;-0.5 \cdot \frac{z \cdot z}{y}\\
\mathbf{elif}\;t\_0 \leq 10^{+151}:\\
\;\;\;\;0.5 \cdot y\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot x}{y + y}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y #s(literal 2 binary64))) < -5.00000000000000027e-129Initial program 79.0%
Taylor expanded in z around inf
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6431.6
Applied rewrites31.6%
if -5.00000000000000027e-129 < (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y #s(literal 2 binary64))) < 1.00000000000000002e151Initial program 90.1%
Taylor expanded in y around inf
lower-*.f6458.9
Applied rewrites58.9%
if 1.00000000000000002e151 < (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y #s(literal 2 binary64))) Initial program 53.3%
Taylor expanded in x around inf
pow2N/A
lift-*.f6435.3
Applied rewrites35.3%
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lift-+.f6435.3
Applied rewrites35.3%
(FPCore (x y z) :precision binary64 (if (<= y 4e+48) (/ (* x x) (+ y y)) (* 0.5 y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 4e+48) {
tmp = (x * x) / (y + y);
} else {
tmp = 0.5 * y;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= 4d+48) then
tmp = (x * x) / (y + y)
else
tmp = 0.5d0 * y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 4e+48) {
tmp = (x * x) / (y + y);
} else {
tmp = 0.5 * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 4e+48: tmp = (x * x) / (y + y) else: tmp = 0.5 * y return tmp
function code(x, y, z) tmp = 0.0 if (y <= 4e+48) tmp = Float64(Float64(x * x) / Float64(y + y)); else tmp = Float64(0.5 * y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 4e+48) tmp = (x * x) / (y + y); else tmp = 0.5 * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 4e+48], N[(N[(x * x), $MachinePrecision] / N[(y + y), $MachinePrecision]), $MachinePrecision], N[(0.5 * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4 \cdot 10^{+48}:\\
\;\;\;\;\frac{x \cdot x}{y + y}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot y\\
\end{array}
\end{array}
if y < 4.00000000000000018e48Initial program 77.2%
Taylor expanded in x around inf
pow2N/A
lift-*.f6436.8
Applied rewrites36.8%
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lift-+.f6436.8
Applied rewrites36.8%
if 4.00000000000000018e48 < y Initial program 40.3%
Taylor expanded in y around inf
lower-*.f6463.5
Applied rewrites63.5%
(FPCore (x y z) :precision binary64 (* 0.5 y))
double code(double x, double y, double z) {
return 0.5 * y;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 0.5d0 * y
end function
public static double code(double x, double y, double z) {
return 0.5 * y;
}
def code(x, y, z): return 0.5 * y
function code(x, y, z) return Float64(0.5 * y) end
function tmp = code(x, y, z) tmp = 0.5 * y; end
code[x_, y_, z_] := N[(0.5 * y), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot y
\end{array}
Initial program 69.4%
Taylor expanded in y around inf
lower-*.f6434.5
Applied rewrites34.5%
herbie shell --seed 2025120
(FPCore (x y z)
:name "Diagrams.TwoD.Apollonian:initialConfig from diagrams-contrib-1.3.0.5, A"
:precision binary64
(/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0)))