
(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));
}
real(8) function code(x, y, z, t)
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}
Sampling outcomes in binary64 precision:
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));
}
real(8) function code(x, y, z, t)
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 (if (<= (/ (* z z) (* t t)) 2e+121) (fma (/ x y) (/ x y) (* (/ z (* t t)) z)) (fma (/ z t) (/ z t) (/ x (/ (* y y) x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (((z * z) / (t * t)) <= 2e+121) {
tmp = fma((x / y), (x / y), ((z / (t * t)) * z));
} else {
tmp = fma((z / t), (z / t), (x / ((y * y) / x)));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(Float64(z * z) / Float64(t * t)) <= 2e+121) tmp = fma(Float64(x / y), Float64(x / y), Float64(Float64(z / Float64(t * t)) * z)); else tmp = fma(Float64(z / t), Float64(z / t), Float64(x / Float64(Float64(y * y) / x))); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(N[(z * z), $MachinePrecision] / N[(t * t), $MachinePrecision]), $MachinePrecision], 2e+121], N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision] + N[(N[(z / N[(t * t), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], N[(N[(z / t), $MachinePrecision] * N[(z / t), $MachinePrecision] + N[(x / N[(N[(y * y), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{z \cdot z}{t \cdot t} \leq 2 \cdot 10^{+121}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{y}, \frac{x}{y}, \frac{z}{t \cdot t} \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \frac{x}{\frac{y \cdot y}{x}}\right)\\
\end{array}
\end{array}
if (/.f64 (*.f64 z z) (*.f64 t t)) < 2.00000000000000007e121Initial program 71.3%
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f6494.7
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6496.3
Applied rewrites96.3%
if 2.00000000000000007e121 < (/.f64 (*.f64 z z) (*.f64 t t)) Initial program 56.4%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f6485.2
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6497.7
Applied rewrites97.7%
lift-*.f64N/A
lift-/.f64N/A
clear-numN/A
associate-*l/N/A
*-lft-identityN/A
lower-/.f64N/A
lower-/.f6497.7
Applied rewrites97.7%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ (* z z) (* t t))))
(if (<= t_1 2e-277)
(* (/ x y) (/ x y))
(if (<= t_1 INFINITY)
(fma (/ z (* t t)) z (* (/ x (* y y)) x))
(/ x (* (/ y x) y))))))
double code(double x, double y, double z, double t) {
double t_1 = (z * z) / (t * t);
double tmp;
if (t_1 <= 2e-277) {
tmp = (x / y) * (x / y);
} else if (t_1 <= ((double) INFINITY)) {
tmp = fma((z / (t * t)), z, ((x / (y * y)) * x));
} else {
tmp = x / ((y / x) * y);
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(z * z) / Float64(t * t)) tmp = 0.0 if (t_1 <= 2e-277) tmp = Float64(Float64(x / y) * Float64(x / y)); elseif (t_1 <= Inf) tmp = fma(Float64(z / Float64(t * t)), z, Float64(Float64(x / Float64(y * y)) * x)); else tmp = Float64(x / Float64(Float64(y / x) * y)); end return 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-277], 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 + N[(N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], N[(x / N[(N[(y / x), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{z \cdot z}{t \cdot t}\\
\mathbf{if}\;t\_1 \leq 2 \cdot 10^{-277}:\\
\;\;\;\;\frac{x}{y} \cdot \frac{x}{y}\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{t \cdot t}, z, \frac{x}{y \cdot y} \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{y}{x} \cdot y}\\
\end{array}
\end{array}
if (/.f64 (*.f64 z z) (*.f64 t t)) < 1.99999999999999994e-277Initial program 69.9%
Taylor expanded in t around inf
unpow2N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6473.5
Applied rewrites73.5%
Applied rewrites93.2%
if 1.99999999999999994e-277 < (/.f64 (*.f64 z z) (*.f64 t t)) < +inf.0Initial program 75.2%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6478.1
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6489.7
Applied rewrites89.7%
if +inf.0 < (/.f64 (*.f64 z z) (*.f64 t t)) Initial program 0.0%
Taylor expanded in t around inf
unpow2N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6447.2
Applied rewrites47.2%
Applied rewrites47.2%
Applied rewrites55.9%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ (* z z) (* t t))))
(if (<= t_1 2e-118)
(* (/ x y) (/ x y))
(if (<= t_1 INFINITY) (/ (* (/ z t) z) t) (/ x (* (/ y x) y))))))
double code(double x, double y, double z, double t) {
double t_1 = (z * z) / (t * t);
double tmp;
if (t_1 <= 2e-118) {
tmp = (x / y) * (x / y);
} else if (t_1 <= ((double) INFINITY)) {
tmp = ((z / t) * z) / t;
} else {
tmp = x / ((y / x) * y);
}
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-118) {
tmp = (x / y) * (x / y);
} else if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = ((z / t) * z) / t;
} else {
tmp = x / ((y / x) * y);
}
return tmp;
}
def code(x, y, z, t): t_1 = (z * z) / (t * t) tmp = 0 if t_1 <= 2e-118: tmp = (x / y) * (x / y) elif t_1 <= math.inf: tmp = ((z / t) * z) / t else: tmp = x / ((y / x) * y) return tmp
function code(x, y, z, t) t_1 = Float64(Float64(z * z) / Float64(t * t)) tmp = 0.0 if (t_1 <= 2e-118) tmp = Float64(Float64(x / y) * Float64(x / y)); elseif (t_1 <= Inf) tmp = Float64(Float64(Float64(z / t) * z) / t); else tmp = Float64(x / Float64(Float64(y / x) * y)); 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-118) tmp = (x / y) * (x / y); elseif (t_1 <= Inf) tmp = ((z / t) * z) / t; else tmp = x / ((y / x) * y); 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-118], N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(N[(N[(z / t), $MachinePrecision] * z), $MachinePrecision] / t), $MachinePrecision], N[(x / N[(N[(y / x), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{z \cdot z}{t \cdot t}\\
\mathbf{if}\;t\_1 \leq 2 \cdot 10^{-118}:\\
\;\;\;\;\frac{x}{y} \cdot \frac{x}{y}\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\frac{\frac{z}{t} \cdot z}{t}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{y}{x} \cdot y}\\
\end{array}
\end{array}
if (/.f64 (*.f64 z z) (*.f64 t t)) < 1.99999999999999997e-118Initial program 70.3%
Taylor expanded in t around inf
unpow2N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6470.8
Applied rewrites70.8%
Applied rewrites90.0%
if 1.99999999999999997e-118 < (/.f64 (*.f64 z z) (*.f64 t t)) < +inf.0Initial program 75.3%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f6482.9
Applied rewrites82.9%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f6496.8
Applied rewrites96.8%
Taylor expanded in t around 0
unpow2N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6481.0
Applied rewrites81.0%
Applied rewrites87.8%
if +inf.0 < (/.f64 (*.f64 z z) (*.f64 t t)) Initial program 0.0%
Taylor expanded in t around inf
unpow2N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6447.2
Applied rewrites47.2%
Applied rewrites47.2%
Applied rewrites55.9%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ (* z z) (* t t))))
(if (<= t_1 2e-118)
(* (/ x y) (/ x y))
(if (<= t_1 INFINITY) t_1 (/ x (* (/ y x) y))))))
double code(double x, double y, double z, double t) {
double t_1 = (z * z) / (t * t);
double tmp;
if (t_1 <= 2e-118) {
tmp = (x / y) * (x / y);
} else if (t_1 <= ((double) INFINITY)) {
tmp = t_1;
} else {
tmp = x / ((y / x) * y);
}
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-118) {
tmp = (x / y) * (x / y);
} else if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = t_1;
} else {
tmp = x / ((y / x) * y);
}
return tmp;
}
def code(x, y, z, t): t_1 = (z * z) / (t * t) tmp = 0 if t_1 <= 2e-118: tmp = (x / y) * (x / y) elif t_1 <= math.inf: tmp = t_1 else: tmp = x / ((y / x) * y) return tmp
function code(x, y, z, t) t_1 = Float64(Float64(z * z) / Float64(t * t)) tmp = 0.0 if (t_1 <= 2e-118) tmp = Float64(Float64(x / y) * Float64(x / y)); elseif (t_1 <= Inf) tmp = t_1; else tmp = Float64(x / Float64(Float64(y / x) * y)); 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-118) tmp = (x / y) * (x / y); elseif (t_1 <= Inf) tmp = t_1; else tmp = x / ((y / x) * y); 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-118], N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], t$95$1, N[(x / N[(N[(y / x), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{z \cdot z}{t \cdot t}\\
\mathbf{if}\;t\_1 \leq 2 \cdot 10^{-118}:\\
\;\;\;\;\frac{x}{y} \cdot \frac{x}{y}\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{y}{x} \cdot y}\\
\end{array}
\end{array}
if (/.f64 (*.f64 z z) (*.f64 t t)) < 1.99999999999999997e-118Initial program 70.3%
Taylor expanded in t around inf
unpow2N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6470.8
Applied rewrites70.8%
Applied rewrites90.0%
if 1.99999999999999997e-118 < (/.f64 (*.f64 z z) (*.f64 t t)) < +inf.0Initial program 75.3%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f6482.9
Applied rewrites82.9%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f6496.8
Applied rewrites96.8%
Taylor expanded in t around 0
unpow2N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6481.0
Applied rewrites81.0%
Applied rewrites82.5%
if +inf.0 < (/.f64 (*.f64 z z) (*.f64 t t)) Initial program 0.0%
Taylor expanded in t around inf
unpow2N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6447.2
Applied rewrites47.2%
Applied rewrites47.2%
Applied rewrites55.9%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (/ (* z z) (* t t))) (t_2 (* (/ x y) (/ x y)))) (if (<= t_1 2e-118) t_2 (if (<= t_1 INFINITY) t_1 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-118) {
tmp = t_2;
} else if (t_1 <= ((double) INFINITY)) {
tmp = t_1;
} 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-118) {
tmp = t_2;
} else if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = t_1;
} 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-118: tmp = t_2 elif t_1 <= math.inf: tmp = t_1 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-118) tmp = t_2; elseif (t_1 <= Inf) tmp = t_1; 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-118) tmp = t_2; elseif (t_1 <= Inf) tmp = t_1; 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-118], t$95$2, If[LessEqual[t$95$1, Infinity], t$95$1, 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^{-118}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (/.f64 (*.f64 z z) (*.f64 t t)) < 1.99999999999999997e-118 or +inf.0 < (/.f64 (*.f64 z z) (*.f64 t t)) Initial program 52.3%
Taylor expanded in t around inf
unpow2N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6464.8
Applied rewrites64.8%
Applied rewrites81.2%
if 1.99999999999999997e-118 < (/.f64 (*.f64 z z) (*.f64 t t)) < +inf.0Initial program 75.3%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f6482.9
Applied rewrites82.9%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f6496.8
Applied rewrites96.8%
Taylor expanded in t around 0
unpow2N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6481.0
Applied rewrites81.0%
Applied rewrites82.5%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (/ (* x x) (* y y))) (t_2 (* (* (/ 1.0 (* t t)) z) z))) (if (<= t_1 2e-117) t_2 (if (<= t_1 INFINITY) (* (/ x (* y y)) x) t_2))))
double code(double x, double y, double z, double t) {
double t_1 = (x * x) / (y * y);
double t_2 = ((1.0 / (t * t)) * z) * z;
double tmp;
if (t_1 <= 2e-117) {
tmp = t_2;
} else if (t_1 <= ((double) INFINITY)) {
tmp = (x / (y * y)) * x;
} else {
tmp = t_2;
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double t_1 = (x * x) / (y * y);
double t_2 = ((1.0 / (t * t)) * z) * z;
double tmp;
if (t_1 <= 2e-117) {
tmp = t_2;
} else if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = (x / (y * y)) * x;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t): t_1 = (x * x) / (y * y) t_2 = ((1.0 / (t * t)) * z) * z tmp = 0 if t_1 <= 2e-117: tmp = t_2 elif t_1 <= math.inf: tmp = (x / (y * y)) * x else: tmp = t_2 return tmp
function code(x, y, z, t) t_1 = Float64(Float64(x * x) / Float64(y * y)) t_2 = Float64(Float64(Float64(1.0 / Float64(t * t)) * z) * z) tmp = 0.0 if (t_1 <= 2e-117) tmp = t_2; elseif (t_1 <= Inf) tmp = Float64(Float64(x / Float64(y * y)) * x); else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (x * x) / (y * y); t_2 = ((1.0 / (t * t)) * z) * z; tmp = 0.0; if (t_1 <= 2e-117) tmp = t_2; elseif (t_1 <= Inf) tmp = (x / (y * y)) * x; else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x * x), $MachinePrecision] / N[(y * y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(1.0 / N[(t * t), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[t$95$1, 2e-117], t$95$2, If[LessEqual[t$95$1, Infinity], N[(N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{x \cdot x}{y \cdot y}\\
t_2 := \left(\frac{1}{t \cdot t} \cdot z\right) \cdot z\\
\mathbf{if}\;t\_1 \leq 2 \cdot 10^{-117}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\frac{x}{y \cdot y} \cdot x\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (/.f64 (*.f64 x x) (*.f64 y y)) < 2.00000000000000006e-117 or +inf.0 < (/.f64 (*.f64 x x) (*.f64 y y)) Initial program 51.6%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f6468.4
Applied rewrites68.4%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f6492.2
Applied rewrites92.2%
Taylor expanded in t around 0
unpow2N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6464.9
Applied rewrites64.9%
Applied rewrites65.0%
if 2.00000000000000006e-117 < (/.f64 (*.f64 x x) (*.f64 y y)) < +inf.0Initial program 77.2%
Taylor expanded in t around inf
unpow2N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6484.8
Applied rewrites84.8%
(FPCore (x y z t) :precision binary64 (if (<= (/ (* z z) (* t t)) 2e+121) (fma (/ x y) (/ x y) (* (/ z (* t t)) z)) (fma (/ z t) (/ z t) (* (/ x (* y y)) x))))
double code(double x, double y, double z, double t) {
double tmp;
if (((z * z) / (t * t)) <= 2e+121) {
tmp = fma((x / y), (x / y), ((z / (t * t)) * z));
} else {
tmp = fma((z / t), (z / t), ((x / (y * y)) * x));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(Float64(z * z) / Float64(t * t)) <= 2e+121) tmp = fma(Float64(x / y), Float64(x / y), Float64(Float64(z / Float64(t * t)) * z)); else tmp = fma(Float64(z / t), Float64(z / t), Float64(Float64(x / Float64(y * y)) * x)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(N[(z * z), $MachinePrecision] / N[(t * t), $MachinePrecision]), $MachinePrecision], 2e+121], N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision] + N[(N[(z / N[(t * t), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], N[(N[(z / t), $MachinePrecision] * N[(z / t), $MachinePrecision] + N[(N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{z \cdot z}{t \cdot t} \leq 2 \cdot 10^{+121}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{y}, \frac{x}{y}, \frac{z}{t \cdot t} \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \frac{x}{y \cdot y} \cdot x\right)\\
\end{array}
\end{array}
if (/.f64 (*.f64 z z) (*.f64 t t)) < 2.00000000000000007e121Initial program 71.3%
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f6494.7
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6496.3
Applied rewrites96.3%
if 2.00000000000000007e121 < (/.f64 (*.f64 z z) (*.f64 t t)) Initial program 56.4%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f6485.2
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6497.7
Applied rewrites97.7%
(FPCore (x y z t) :precision binary64 (if (<= (/ (* x x) (* y y)) 0.0) (/ (/ z t) (/ 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 = (z / t) / (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(z / t) / Float64(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[(z / t), $MachinePrecision] / N[(t / z), $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 0:\\
\;\;\;\;\frac{\frac{z}{t}}{\frac{t}{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 67.1%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f6490.8
Applied rewrites90.8%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f6497.6
Applied rewrites97.6%
Taylor expanded in t around 0
unpow2N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6473.0
Applied rewrites73.0%
Applied rewrites92.9%
if 0.0 < (/.f64 (*.f64 x x) (*.f64 y y)) Initial program 61.4%
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f6483.4
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6491.3
Applied rewrites91.3%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (/ (* x x) (* y y))) (t_2 (* (/ z (* t t)) z))) (if (<= t_1 2e-117) t_2 (if (<= t_1 INFINITY) (* (/ x (* y y)) x) t_2))))
double code(double x, double y, double z, double t) {
double t_1 = (x * x) / (y * y);
double t_2 = (z / (t * t)) * z;
double tmp;
if (t_1 <= 2e-117) {
tmp = t_2;
} else if (t_1 <= ((double) INFINITY)) {
tmp = (x / (y * y)) * x;
} else {
tmp = t_2;
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double t_1 = (x * x) / (y * y);
double t_2 = (z / (t * t)) * z;
double tmp;
if (t_1 <= 2e-117) {
tmp = t_2;
} else if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = (x / (y * y)) * x;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t): t_1 = (x * x) / (y * y) t_2 = (z / (t * t)) * z tmp = 0 if t_1 <= 2e-117: tmp = t_2 elif t_1 <= math.inf: tmp = (x / (y * y)) * x else: tmp = t_2 return tmp
function code(x, y, z, t) t_1 = Float64(Float64(x * x) / Float64(y * y)) t_2 = Float64(Float64(z / Float64(t * t)) * z) tmp = 0.0 if (t_1 <= 2e-117) tmp = t_2; elseif (t_1 <= Inf) tmp = Float64(Float64(x / Float64(y * y)) * x); else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (x * x) / (y * y); t_2 = (z / (t * t)) * z; tmp = 0.0; if (t_1 <= 2e-117) tmp = t_2; elseif (t_1 <= Inf) tmp = (x / (y * y)) * x; else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x * x), $MachinePrecision] / N[(y * y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(z / N[(t * t), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[t$95$1, 2e-117], t$95$2, If[LessEqual[t$95$1, Infinity], N[(N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{x \cdot x}{y \cdot y}\\
t_2 := \frac{z}{t \cdot t} \cdot z\\
\mathbf{if}\;t\_1 \leq 2 \cdot 10^{-117}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\frac{x}{y \cdot y} \cdot x\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (/.f64 (*.f64 x x) (*.f64 y y)) < 2.00000000000000006e-117 or +inf.0 < (/.f64 (*.f64 x x) (*.f64 y y)) Initial program 51.6%
Taylor expanded in t around 0
unpow2N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6464.9
Applied rewrites64.9%
if 2.00000000000000006e-117 < (/.f64 (*.f64 x x) (*.f64 y y)) < +inf.0Initial program 77.2%
Taylor expanded in t around inf
unpow2N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6484.8
Applied rewrites84.8%
(FPCore (x y z t) :precision binary64 (if (<= (/ (* x x) (* y y)) 4e-115) (* (/ z t) (/ z t)) (* (/ x y) (/ x y))))
double code(double x, double y, double z, double t) {
double tmp;
if (((x * x) / (y * y)) <= 4e-115) {
tmp = (z / t) * (z / t);
} else {
tmp = (x / y) * (x / y);
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (((x * x) / (y * y)) <= 4d-115) then
tmp = (z / t) * (z / t)
else
tmp = (x / y) * (x / y)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (((x * x) / (y * y)) <= 4e-115) {
tmp = (z / t) * (z / t);
} else {
tmp = (x / y) * (x / y);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if ((x * x) / (y * y)) <= 4e-115: tmp = (z / t) * (z / t) else: tmp = (x / y) * (x / y) return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(Float64(x * x) / Float64(y * y)) <= 4e-115) tmp = Float64(Float64(z / t) * Float64(z / t)); else tmp = Float64(Float64(x / y) * Float64(x / y)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (((x * x) / (y * y)) <= 4e-115) tmp = (z / t) * (z / t); else tmp = (x / y) * (x / y); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(N[(x * x), $MachinePrecision] / N[(y * y), $MachinePrecision]), $MachinePrecision], 4e-115], N[(N[(z / t), $MachinePrecision] * N[(z / t), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x \cdot x}{y \cdot y} \leq 4 \cdot 10^{-115}:\\
\;\;\;\;\frac{z}{t} \cdot \frac{z}{t}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y} \cdot \frac{x}{y}\\
\end{array}
\end{array}
if (/.f64 (*.f64 x x) (*.f64 y y)) < 4.0000000000000002e-115Initial program 68.4%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f6490.6
Applied rewrites90.6%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f6496.2
Applied rewrites96.2%
Taylor expanded in t around 0
unpow2N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6468.1
Applied rewrites68.1%
Applied rewrites88.9%
if 4.0000000000000002e-115 < (/.f64 (*.f64 x x) (*.f64 y y)) Initial program 59.9%
Taylor expanded in t around inf
unpow2N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6470.9
Applied rewrites70.9%
Applied rewrites78.5%
(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;
}
real(8) function code(x, y, z, t)
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 63.3%
Taylor expanded in t around inf
unpow2N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6452.7
Applied rewrites52.7%
(FPCore (x y z t) :precision binary64 (+ (pow (/ x y) 2.0) (pow (/ z t) 2.0)))
double code(double x, double y, double z, double t) {
return pow((x / y), 2.0) + pow((z / t), 2.0);
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = ((x / y) ** 2.0d0) + ((z / t) ** 2.0d0)
end function
public static double code(double x, double y, double z, double t) {
return Math.pow((x / y), 2.0) + Math.pow((z / t), 2.0);
}
def code(x, y, z, t): return math.pow((x / y), 2.0) + math.pow((z / t), 2.0)
function code(x, y, z, t) return Float64((Float64(x / y) ^ 2.0) + (Float64(z / t) ^ 2.0)) end
function tmp = code(x, y, z, t) tmp = ((x / y) ^ 2.0) + ((z / t) ^ 2.0); end
code[x_, y_, z_, t_] := N[(N[Power[N[(x / y), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(z / t), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(\frac{x}{y}\right)}^{2} + {\left(\frac{z}{t}\right)}^{2}
\end{array}
herbie shell --seed 2024235
(FPCore (x y z t)
:name "Graphics.Rasterific.Svg.PathConverter:arcToSegments from rasterific-svg-0.2.3.1"
:precision binary64
:alt
(! :herbie-platform default (+ (pow (/ x y) 2) (pow (/ z t) 2)))
(+ (/ (* x x) (* y y)) (/ (* z z) (* t t))))