
(FPCore (x y z t) :precision binary64 (+ (/ (* x x) (* y y)) (/ (* z z) (* t t))))
double code(double x, double y, double z, double t) {
return ((x * x) / (y * y)) + ((z * z) / (t * t));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = ((x * x) / (y * y)) + ((z * z) / (t * t))
end function
public static double code(double x, double y, double z, double t) {
return ((x * x) / (y * y)) + ((z * z) / (t * t));
}
def code(x, y, z, t): return ((x * x) / (y * y)) + ((z * z) / (t * t))
function code(x, y, z, t) return Float64(Float64(Float64(x * x) / Float64(y * y)) + Float64(Float64(z * z) / Float64(t * t))) end
function tmp = code(x, y, z, t) tmp = ((x * x) / (y * y)) + ((z * z) / (t * t)); end
code[x_, y_, z_, t_] := N[(N[(N[(x * x), $MachinePrecision] / N[(y * y), $MachinePrecision]), $MachinePrecision] + N[(N[(z * z), $MachinePrecision] / N[(t * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t}
\end{array}
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (+ (/ (* x x) (* y y)) (/ (* z z) (* t t))))
double code(double x, double y, double z, double t) {
return ((x * x) / (y * y)) + ((z * z) / (t * t));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = ((x * x) / (y * y)) + ((z * z) / (t * t))
end function
public static double code(double x, double y, double z, double t) {
return ((x * x) / (y * y)) + ((z * z) / (t * t));
}
def code(x, y, z, t): return ((x * x) / (y * y)) + ((z * z) / (t * t))
function code(x, y, z, t) return Float64(Float64(Float64(x * x) / Float64(y * y)) + Float64(Float64(z * z) / Float64(t * t))) end
function tmp = code(x, y, z, t) tmp = ((x * x) / (y * y)) + ((z * z) / (t * t)); end
code[x_, y_, z_, t_] := N[(N[(N[(x * x), $MachinePrecision] / N[(y * y), $MachinePrecision]), $MachinePrecision] + N[(N[(z * z), $MachinePrecision] / N[(t * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t}
\end{array}
(FPCore (x y z t) :precision binary64 (fma (/ x y) (/ x y) (/ (* (/ z t) z) t)))
double code(double x, double y, double z, double t) {
return fma((x / y), (x / y), (((z / t) * z) / t));
}
function code(x, y, z, t) return fma(Float64(x / y), Float64(x / y), Float64(Float64(Float64(z / t) * z) / t)) end
code[x_, y_, z_, t_] := N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision] + N[(N[(N[(z / t), $MachinePrecision] * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{x}{y}, \frac{x}{y}, \frac{\frac{z}{t} \cdot z}{t}\right)
\end{array}
Initial program 66.7%
Applied rewrites88.9%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
pow2N/A
associate-/r*N/A
lower-/.f64N/A
pow2N/A
associate-*l/N/A
lower-*.f64N/A
lift-/.f6496.7
Applied rewrites96.7%
(FPCore (x y z t) :precision binary64 (fma (/ x y) (/ x y) (* (/ (/ z t) t) z)))
double code(double x, double y, double z, double t) {
return fma((x / y), (x / y), (((z / t) / t) * z));
}
function code(x, y, z, t) return fma(Float64(x / y), Float64(x / y), Float64(Float64(Float64(z / t) / t) * z)) end
code[x_, y_, z_, t_] := N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision] + N[(N[(N[(z / t), $MachinePrecision] / t), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{x}{y}, \frac{x}{y}, \frac{\frac{z}{t}}{t} \cdot z\right)
\end{array}
Initial program 66.7%
Applied rewrites88.9%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lift-/.f6496.5
Applied rewrites96.5%
(FPCore (x y z t) :precision binary64 (if (<= (/ (* x x) (* y y)) 2e+283) (fma (/ z t) (/ z t) (* (/ x (* y y)) x)) (fma (/ x y) (/ x y) (* (/ z (* t t)) z))))
double code(double x, double y, double z, double t) {
double tmp;
if (((x * x) / (y * y)) <= 2e+283) {
tmp = fma((z / t), (z / t), ((x / (y * y)) * x));
} else {
tmp = fma((x / y), (x / y), ((z / (t * t)) * z));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(Float64(x * x) / Float64(y * y)) <= 2e+283) tmp = fma(Float64(z / t), Float64(z / t), Float64(Float64(x / Float64(y * y)) * x)); else tmp = fma(Float64(x / y), Float64(x / y), Float64(Float64(z / Float64(t * t)) * z)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(N[(x * x), $MachinePrecision] / N[(y * y), $MachinePrecision]), $MachinePrecision], 2e+283], N[(N[(z / t), $MachinePrecision] * N[(z / t), $MachinePrecision] + N[(N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision] + N[(N[(z / N[(t * t), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x \cdot x}{y \cdot y} \leq 2 \cdot 10^{+283}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \frac{x}{y \cdot y} \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{y}, \frac{x}{y}, \frac{z}{t \cdot t} \cdot z\right)\\
\end{array}
\end{array}
if (/.f64 (*.f64 x x) (*.f64 y y)) < 1.99999999999999991e283Initial program 73.6%
Applied rewrites97.6%
if 1.99999999999999991e283 < (/.f64 (*.f64 x x) (*.f64 y y)) Initial program 58.7%
Applied rewrites95.4%
(FPCore (x y z t) :precision binary64 (if (<= (/ (* x x) (* y y)) 0.0) (* (/ (* (/ 1.0 t) z) t) z) (fma (/ x y) (/ x y) (* (/ z (* t t)) z))))
double code(double x, double y, double z, double t) {
double tmp;
if (((x * x) / (y * y)) <= 0.0) {
tmp = (((1.0 / t) * z) / t) * z;
} else {
tmp = fma((x / y), (x / y), ((z / (t * t)) * z));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(Float64(x * x) / Float64(y * y)) <= 0.0) tmp = Float64(Float64(Float64(Float64(1.0 / t) * z) / t) * z); else tmp = fma(Float64(x / y), Float64(x / y), Float64(Float64(z / Float64(t * t)) * z)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(N[(x * x), $MachinePrecision] / N[(y * y), $MachinePrecision]), $MachinePrecision], 0.0], N[(N[(N[(N[(1.0 / t), $MachinePrecision] * z), $MachinePrecision] / t), $MachinePrecision] * z), $MachinePrecision], N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision] + N[(N[(z / N[(t * t), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x \cdot x}{y \cdot y} \leq 0:\\
\;\;\;\;\frac{\frac{1}{t} \cdot z}{t} \cdot z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{y}, \frac{x}{y}, \frac{z}{t \cdot t} \cdot z\right)\\
\end{array}
\end{array}
if (/.f64 (*.f64 x x) (*.f64 y y)) < 0.0Initial program 70.7%
Taylor expanded in x around 0
pow2N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6475.5
Applied rewrites75.5%
lift-*.f64N/A
lift-/.f64N/A
pow2N/A
frac-2negN/A
frac-2negN/A
remove-double-negN/A
*-lft-identityN/A
remove-double-negN/A
associate-*l/N/A
pow2N/A
associate-/r*N/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f6488.1
Applied rewrites88.1%
if 0.0 < (/.f64 (*.f64 x x) (*.f64 y y)) Initial program 64.6%
Applied rewrites92.7%
(FPCore (x y z t)
:precision binary64
(if (<= y 7.5e-158)
(* (* (/ 1.0 y) (/ x y)) x)
(if (<= y 1.25e+154)
(fma (/ z (* t t)) z (* (/ x (* y y)) x))
(* (/ (/ z t) t) z))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 7.5e-158) {
tmp = ((1.0 / y) * (x / y)) * x;
} else if (y <= 1.25e+154) {
tmp = fma((z / (t * t)), z, ((x / (y * y)) * x));
} else {
tmp = ((z / t) / t) * z;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 7.5e-158) tmp = Float64(Float64(Float64(1.0 / y) * Float64(x / y)) * x); elseif (y <= 1.25e+154) tmp = fma(Float64(z / Float64(t * t)), z, Float64(Float64(x / Float64(y * y)) * x)); else tmp = Float64(Float64(Float64(z / t) / t) * z); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 7.5e-158], N[(N[(N[(1.0 / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[y, 1.25e+154], N[(N[(z / N[(t * t), $MachinePrecision]), $MachinePrecision] * z + N[(N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], N[(N[(N[(z / t), $MachinePrecision] / t), $MachinePrecision] * z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 7.5 \cdot 10^{-158}:\\
\;\;\;\;\left(\frac{1}{y} \cdot \frac{x}{y}\right) \cdot x\\
\mathbf{elif}\;y \leq 1.25 \cdot 10^{+154}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{t \cdot t}, z, \frac{x}{y \cdot y} \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{z}{t}}{t} \cdot z\\
\end{array}
\end{array}
if y < 7.5e-158Initial program 65.2%
Taylor expanded in x around inf
pow2N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6456.4
Applied rewrites56.4%
lift-*.f64N/A
lift-/.f64N/A
remove-double-negN/A
pow2N/A
distribute-neg-frac2N/A
*-lft-identityN/A
distribute-neg-frac2N/A
pow2N/A
frac-timesN/A
lift-/.f64N/A
distribute-rgt-neg-inN/A
distribute-rgt-neg-outN/A
remove-double-negN/A
lower-*.f64N/A
lift-/.f6460.8
Applied rewrites60.8%
if 7.5e-158 < y < 1.25000000000000001e154Initial program 76.5%
Applied rewrites88.7%
if 1.25000000000000001e154 < y Initial program 54.0%
Taylor expanded in x around 0
pow2N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6468.2
Applied rewrites68.2%
lift-*.f64N/A
lift-/.f64N/A
associate-/l/N/A
lift-/.f64N/A
lift-/.f6479.6
Applied rewrites79.6%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ (* z z) (* t t))))
(if (<= t_1 2e+80)
(* (/ x y) (/ x y))
(if (<= t_1 INFINITY) (* (/ (* (/ 1.0 t) z) t) z) (* (/ (/ x y) y) x)))))
double code(double x, double y, double z, double t) {
double t_1 = (z * z) / (t * t);
double tmp;
if (t_1 <= 2e+80) {
tmp = (x / y) * (x / y);
} else if (t_1 <= ((double) INFINITY)) {
tmp = (((1.0 / t) * z) / t) * z;
} else {
tmp = ((x / y) / y) * x;
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double t_1 = (z * z) / (t * t);
double tmp;
if (t_1 <= 2e+80) {
tmp = (x / y) * (x / y);
} else if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = (((1.0 / t) * z) / t) * z;
} else {
tmp = ((x / y) / y) * x;
}
return tmp;
}
def code(x, y, z, t): t_1 = (z * z) / (t * t) tmp = 0 if t_1 <= 2e+80: tmp = (x / y) * (x / y) elif t_1 <= math.inf: tmp = (((1.0 / t) * z) / t) * z else: tmp = ((x / y) / y) * x return tmp
function code(x, y, z, t) t_1 = Float64(Float64(z * z) / Float64(t * t)) tmp = 0.0 if (t_1 <= 2e+80) tmp = Float64(Float64(x / y) * Float64(x / y)); elseif (t_1 <= Inf) tmp = Float64(Float64(Float64(Float64(1.0 / t) * z) / t) * z); else tmp = Float64(Float64(Float64(x / y) / y) * x); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (z * z) / (t * t); tmp = 0.0; if (t_1 <= 2e+80) tmp = (x / y) * (x / y); elseif (t_1 <= Inf) tmp = (((1.0 / t) * z) / t) * z; else tmp = ((x / y) / y) * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(z * z), $MachinePrecision] / N[(t * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 2e+80], N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(N[(N[(N[(1.0 / t), $MachinePrecision] * z), $MachinePrecision] / t), $MachinePrecision] * z), $MachinePrecision], N[(N[(N[(x / y), $MachinePrecision] / y), $MachinePrecision] * x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{z \cdot z}{t \cdot t}\\
\mathbf{if}\;t\_1 \leq 2 \cdot 10^{+80}:\\
\;\;\;\;\frac{x}{y} \cdot \frac{x}{y}\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\frac{\frac{1}{t} \cdot z}{t} \cdot z\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{y} \cdot x\\
\end{array}
\end{array}
if (/.f64 (*.f64 z z) (*.f64 t t)) < 2e80Initial program 73.8%
Taylor expanded in x around inf
pow2N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6469.3
Applied rewrites69.3%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
pow2N/A
pow2N/A
associate-/r*N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-/.f6484.7
Applied rewrites84.7%
if 2e80 < (/.f64 (*.f64 z z) (*.f64 t t)) < +inf.0Initial program 78.7%
Taylor expanded in x around 0
pow2N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6486.4
Applied rewrites86.4%
lift-*.f64N/A
lift-/.f64N/A
pow2N/A
frac-2negN/A
frac-2negN/A
remove-double-negN/A
*-lft-identityN/A
remove-double-negN/A
associate-*l/N/A
pow2N/A
associate-/r*N/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f6487.8
Applied rewrites87.8%
if +inf.0 < (/.f64 (*.f64 z z) (*.f64 t t)) Initial program 0.0%
Taylor expanded in x around inf
pow2N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6441.8
Applied rewrites41.8%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lift-/.f6447.1
Applied rewrites47.1%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ (* z z) (* t t))))
(if (<= t_1 2e+80)
(* (/ x y) (/ x y))
(if (<= t_1 INFINITY) (* (/ (/ z t) t) z) (* (/ (/ x y) y) x)))))
double code(double x, double y, double z, double t) {
double t_1 = (z * z) / (t * t);
double tmp;
if (t_1 <= 2e+80) {
tmp = (x / y) * (x / y);
} else if (t_1 <= ((double) INFINITY)) {
tmp = ((z / t) / t) * z;
} else {
tmp = ((x / y) / y) * x;
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double t_1 = (z * z) / (t * t);
double tmp;
if (t_1 <= 2e+80) {
tmp = (x / y) * (x / y);
} else if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = ((z / t) / t) * z;
} else {
tmp = ((x / y) / y) * x;
}
return tmp;
}
def code(x, y, z, t): t_1 = (z * z) / (t * t) tmp = 0 if t_1 <= 2e+80: tmp = (x / y) * (x / y) elif t_1 <= math.inf: tmp = ((z / t) / t) * z else: tmp = ((x / y) / y) * x return tmp
function code(x, y, z, t) t_1 = Float64(Float64(z * z) / Float64(t * t)) tmp = 0.0 if (t_1 <= 2e+80) tmp = Float64(Float64(x / y) * Float64(x / y)); elseif (t_1 <= Inf) tmp = Float64(Float64(Float64(z / t) / t) * z); else tmp = Float64(Float64(Float64(x / y) / y) * x); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (z * z) / (t * t); tmp = 0.0; if (t_1 <= 2e+80) tmp = (x / y) * (x / y); elseif (t_1 <= Inf) tmp = ((z / t) / t) * z; else tmp = ((x / y) / y) * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(z * z), $MachinePrecision] / N[(t * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 2e+80], N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(N[(N[(z / t), $MachinePrecision] / t), $MachinePrecision] * z), $MachinePrecision], N[(N[(N[(x / y), $MachinePrecision] / y), $MachinePrecision] * x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{z \cdot z}{t \cdot t}\\
\mathbf{if}\;t\_1 \leq 2 \cdot 10^{+80}:\\
\;\;\;\;\frac{x}{y} \cdot \frac{x}{y}\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\frac{\frac{z}{t}}{t} \cdot z\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{y} \cdot x\\
\end{array}
\end{array}
if (/.f64 (*.f64 z z) (*.f64 t t)) < 2e80Initial program 73.8%
Taylor expanded in x around inf
pow2N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6469.3
Applied rewrites69.3%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
pow2N/A
pow2N/A
associate-/r*N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-/.f6484.7
Applied rewrites84.7%
if 2e80 < (/.f64 (*.f64 z z) (*.f64 t t)) < +inf.0Initial program 78.7%
Taylor expanded in x around 0
pow2N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6486.4
Applied rewrites86.4%
lift-*.f64N/A
lift-/.f64N/A
associate-/l/N/A
lift-/.f64N/A
lift-/.f6487.9
Applied rewrites87.9%
if +inf.0 < (/.f64 (*.f64 z z) (*.f64 t t)) Initial program 0.0%
Taylor expanded in x around inf
pow2N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6441.8
Applied rewrites41.8%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lift-/.f6447.1
Applied rewrites47.1%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ (* z z) (* t t))))
(if (<= t_1 2e+80)
(* (/ x y) (/ x y))
(if (<= t_1 INFINITY) (* (/ z (* t t)) z) (* (/ (/ x y) y) x)))))
double code(double x, double y, double z, double t) {
double t_1 = (z * z) / (t * t);
double tmp;
if (t_1 <= 2e+80) {
tmp = (x / y) * (x / y);
} else if (t_1 <= ((double) INFINITY)) {
tmp = (z / (t * t)) * z;
} else {
tmp = ((x / y) / y) * x;
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double t_1 = (z * z) / (t * t);
double tmp;
if (t_1 <= 2e+80) {
tmp = (x / y) * (x / y);
} else if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = (z / (t * t)) * z;
} else {
tmp = ((x / y) / y) * x;
}
return tmp;
}
def code(x, y, z, t): t_1 = (z * z) / (t * t) tmp = 0 if t_1 <= 2e+80: tmp = (x / y) * (x / y) elif t_1 <= math.inf: tmp = (z / (t * t)) * z else: tmp = ((x / y) / y) * x return tmp
function code(x, y, z, t) t_1 = Float64(Float64(z * z) / Float64(t * t)) tmp = 0.0 if (t_1 <= 2e+80) tmp = Float64(Float64(x / y) * Float64(x / y)); elseif (t_1 <= Inf) tmp = Float64(Float64(z / Float64(t * t)) * z); else tmp = Float64(Float64(Float64(x / y) / y) * x); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (z * z) / (t * t); tmp = 0.0; if (t_1 <= 2e+80) tmp = (x / y) * (x / y); elseif (t_1 <= Inf) tmp = (z / (t * t)) * z; else tmp = ((x / y) / y) * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(z * z), $MachinePrecision] / N[(t * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 2e+80], N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(N[(z / N[(t * t), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision], N[(N[(N[(x / y), $MachinePrecision] / y), $MachinePrecision] * x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{z \cdot z}{t \cdot t}\\
\mathbf{if}\;t\_1 \leq 2 \cdot 10^{+80}:\\
\;\;\;\;\frac{x}{y} \cdot \frac{x}{y}\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\frac{z}{t \cdot t} \cdot z\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{y} \cdot x\\
\end{array}
\end{array}
if (/.f64 (*.f64 z z) (*.f64 t t)) < 2e80Initial program 73.8%
Taylor expanded in x around inf
pow2N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6469.3
Applied rewrites69.3%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
pow2N/A
pow2N/A
associate-/r*N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-/.f6484.7
Applied rewrites84.7%
if 2e80 < (/.f64 (*.f64 z z) (*.f64 t t)) < +inf.0Initial program 78.7%
Taylor expanded in x around 0
pow2N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6486.4
Applied rewrites86.4%
if +inf.0 < (/.f64 (*.f64 z z) (*.f64 t t)) Initial program 0.0%
Taylor expanded in x around inf
pow2N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6441.8
Applied rewrites41.8%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lift-/.f6447.1
Applied rewrites47.1%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (/ (* z z) (* t t))) (t_2 (* (/ x y) (/ x y)))) (if (<= t_1 2e+80) t_2 (if (<= t_1 INFINITY) (* (/ z (* t t)) z) t_2))))
double code(double x, double y, double z, double t) {
double t_1 = (z * z) / (t * t);
double t_2 = (x / y) * (x / y);
double tmp;
if (t_1 <= 2e+80) {
tmp = t_2;
} else if (t_1 <= ((double) INFINITY)) {
tmp = (z / (t * t)) * z;
} else {
tmp = t_2;
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double t_1 = (z * z) / (t * t);
double t_2 = (x / y) * (x / y);
double tmp;
if (t_1 <= 2e+80) {
tmp = t_2;
} else if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = (z / (t * t)) * z;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t): t_1 = (z * z) / (t * t) t_2 = (x / y) * (x / y) tmp = 0 if t_1 <= 2e+80: tmp = t_2 elif t_1 <= math.inf: tmp = (z / (t * t)) * z else: tmp = t_2 return tmp
function code(x, y, z, t) t_1 = Float64(Float64(z * z) / Float64(t * t)) t_2 = Float64(Float64(x / y) * Float64(x / y)) tmp = 0.0 if (t_1 <= 2e+80) tmp = t_2; elseif (t_1 <= Inf) tmp = Float64(Float64(z / Float64(t * t)) * z); else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (z * z) / (t * t); t_2 = (x / y) * (x / y); tmp = 0.0; if (t_1 <= 2e+80) tmp = t_2; elseif (t_1 <= Inf) tmp = (z / (t * t)) * z; else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(z * z), $MachinePrecision] / N[(t * t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 2e+80], t$95$2, If[LessEqual[t$95$1, Infinity], N[(N[(z / N[(t * t), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{z \cdot z}{t \cdot t}\\
t_2 := \frac{x}{y} \cdot \frac{x}{y}\\
\mathbf{if}\;t\_1 \leq 2 \cdot 10^{+80}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\frac{z}{t \cdot t} \cdot z\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (/.f64 (*.f64 z z) (*.f64 t t)) < 2e80 or +inf.0 < (/.f64 (*.f64 z z) (*.f64 t t)) Initial program 58.5%
Taylor expanded in x around inf
pow2N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6463.6
Applied rewrites63.6%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
pow2N/A
pow2N/A
associate-/r*N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-/.f6477.5
Applied rewrites77.5%
if 2e80 < (/.f64 (*.f64 z z) (*.f64 t t)) < +inf.0Initial program 78.7%
Taylor expanded in x around 0
pow2N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6486.4
Applied rewrites86.4%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (/ (* z z) (* t t))) (t_2 (* (/ x (* y y)) x))) (if (<= t_1 2e+80) t_2 (if (<= t_1 INFINITY) (* (/ z (* t t)) z) t_2))))
double code(double x, double y, double z, double t) {
double t_1 = (z * z) / (t * t);
double t_2 = (x / (y * y)) * x;
double tmp;
if (t_1 <= 2e+80) {
tmp = t_2;
} else if (t_1 <= ((double) INFINITY)) {
tmp = (z / (t * t)) * z;
} else {
tmp = t_2;
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double t_1 = (z * z) / (t * t);
double t_2 = (x / (y * y)) * x;
double tmp;
if (t_1 <= 2e+80) {
tmp = t_2;
} else if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = (z / (t * t)) * z;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t): t_1 = (z * z) / (t * t) t_2 = (x / (y * y)) * x tmp = 0 if t_1 <= 2e+80: tmp = t_2 elif t_1 <= math.inf: tmp = (z / (t * t)) * z else: tmp = t_2 return tmp
function code(x, y, z, t) t_1 = Float64(Float64(z * z) / Float64(t * t)) t_2 = Float64(Float64(x / Float64(y * y)) * x) tmp = 0.0 if (t_1 <= 2e+80) tmp = t_2; elseif (t_1 <= Inf) tmp = Float64(Float64(z / Float64(t * t)) * z); else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (z * z) / (t * t); t_2 = (x / (y * y)) * x; tmp = 0.0; if (t_1 <= 2e+80) tmp = t_2; elseif (t_1 <= Inf) tmp = (z / (t * t)) * z; else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(z * z), $MachinePrecision] / N[(t * t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[t$95$1, 2e+80], t$95$2, If[LessEqual[t$95$1, Infinity], N[(N[(z / N[(t * t), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{z \cdot z}{t \cdot t}\\
t_2 := \frac{x}{y \cdot y} \cdot x\\
\mathbf{if}\;t\_1 \leq 2 \cdot 10^{+80}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\frac{z}{t \cdot t} \cdot z\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (/.f64 (*.f64 z z) (*.f64 t t)) < 2e80 or +inf.0 < (/.f64 (*.f64 z z) (*.f64 t t)) Initial program 58.5%
Taylor expanded in x around inf
pow2N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6463.6
Applied rewrites63.6%
if 2e80 < (/.f64 (*.f64 z z) (*.f64 t t)) < +inf.0Initial program 78.7%
Taylor expanded in x around 0
pow2N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6486.4
Applied rewrites86.4%
(FPCore (x y z t) :precision binary64 (* (/ x (* y y)) x))
double code(double x, double y, double z, double t) {
return (x / (y * y)) * x;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (x / (y * y)) * x
end function
public static double code(double x, double y, double z, double t) {
return (x / (y * y)) * x;
}
def code(x, y, z, t): return (x / (y * y)) * x
function code(x, y, z, t) return Float64(Float64(x / Float64(y * y)) * x) end
function tmp = code(x, y, z, t) tmp = (x / (y * y)) * x; end
code[x_, y_, z_, t_] := N[(N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{y \cdot y} \cdot x
\end{array}
Initial program 66.7%
Taylor expanded in x around inf
pow2N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6452.6
Applied rewrites52.6%
herbie shell --seed 2025130
(FPCore (x y z t)
:name "Graphics.Rasterific.Svg.PathConverter:arcToSegments from rasterific-svg-0.2.3.1"
:precision binary64
(+ (/ (* x x) (* y y)) (/ (* z z) (* t t))))