
(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 10 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 (fma (/ z t) (/ z t) (* (/ x y) (/ x y))))
double code(double x, double y, double z, double t) {
return fma((z / t), (z / t), ((x / y) * (x / y)));
}
function code(x, y, z, t) return fma(Float64(z / t), Float64(z / t), Float64(Float64(x / y) * Float64(x / y))) end
code[x_, y_, z_, t_] := N[(N[(z / t), $MachinePrecision] * N[(z / t), $MachinePrecision] + N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \frac{x}{y} \cdot \frac{x}{y}\right)
\end{array}
Initial program 63.8%
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-/.f6476.0
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
pow2N/A
lower-pow.f64N/A
lower-/.f6499.7
Applied rewrites99.7%
lift-pow.f64N/A
unpow2N/A
lower-*.f6499.7
Applied rewrites99.7%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ (* x x) (* y y))) (t_2 (/ (/ z t) (/ t z))))
(if (<= t_1 0.0)
t_2
(if (<= t_1 5e+173)
(+ t_1 (/ (* z z) (* t t)))
(if (<= t_1 INFINITY) (/ (* (* (- x) t) x) (* (* t y) (- y))) 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 <= 0.0) {
tmp = t_2;
} else if (t_1 <= 5e+173) {
tmp = t_1 + ((z * z) / (t * t));
} else if (t_1 <= ((double) INFINITY)) {
tmp = ((-x * t) * x) / ((t * y) * -y);
} 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 <= 0.0) {
tmp = t_2;
} else if (t_1 <= 5e+173) {
tmp = t_1 + ((z * z) / (t * t));
} else if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = ((-x * t) * x) / ((t * y) * -y);
} 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 <= 0.0: tmp = t_2 elif t_1 <= 5e+173: tmp = t_1 + ((z * z) / (t * t)) elif t_1 <= math.inf: tmp = ((-x * t) * x) / ((t * y) * -y) 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 / t) / Float64(t / z)) tmp = 0.0 if (t_1 <= 0.0) tmp = t_2; elseif (t_1 <= 5e+173) tmp = Float64(t_1 + Float64(Float64(z * z) / Float64(t * t))); elseif (t_1 <= Inf) tmp = Float64(Float64(Float64(Float64(-x) * t) * x) / Float64(Float64(t * y) * Float64(-y))); 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 <= 0.0) tmp = t_2; elseif (t_1 <= 5e+173) tmp = t_1 + ((z * z) / (t * t)); elseif (t_1 <= Inf) tmp = ((-x * t) * x) / ((t * y) * -y); 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 / t), $MachinePrecision] / N[(t / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 0.0], t$95$2, If[LessEqual[t$95$1, 5e+173], N[(t$95$1 + N[(N[(z * z), $MachinePrecision] / N[(t * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(N[(N[((-x) * t), $MachinePrecision] * x), $MachinePrecision] / N[(N[(t * y), $MachinePrecision] * (-y)), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{x \cdot x}{y \cdot y}\\
t_2 := \frac{\frac{z}{t}}{\frac{t}{z}}\\
\mathbf{if}\;t\_1 \leq 0:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+173}:\\
\;\;\;\;t\_1 + \frac{z \cdot z}{t \cdot t}\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\frac{\left(\left(-x\right) \cdot t\right) \cdot x}{\left(t \cdot y\right) \cdot \left(-y\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (/.f64 (*.f64 x x) (*.f64 y y)) < 0.0 or +inf.0 < (/.f64 (*.f64 x x) (*.f64 y y)) Initial program 46.3%
Taylor expanded in x around 0
unpow2N/A
associate-*l/N/A
lower-*.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6474.2
Applied rewrites74.2%
Applied rewrites79.1%
if 0.0 < (/.f64 (*.f64 x x) (*.f64 y y)) < 5.00000000000000034e173Initial program 88.7%
if 5.00000000000000034e173 < (/.f64 (*.f64 x x) (*.f64 y y)) < +inf.0Initial program 79.2%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lift-/.f64N/A
frac-2negN/A
frac-addN/A
lower-/.f64N/A
Applied rewrites88.9%
Taylor expanded in x around inf
associate-*r*N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
neg-mul-1N/A
lower-*.f64N/A
lower-neg.f6485.5
Applied rewrites85.5%
Final simplification82.7%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ (* z z) (* t t))))
(if (<= t_1 5e+305)
(+ (* (/ x y) (/ x y)) t_1)
(if (<= t_1 INFINITY)
(* (/ z t) (/ z t))
(fma (/ z t) (/ z t) (/ (* x x) (* y y)))))))
double code(double x, double y, double z, double t) {
double t_1 = (z * z) / (t * t);
double tmp;
if (t_1 <= 5e+305) {
tmp = ((x / y) * (x / y)) + t_1;
} else if (t_1 <= ((double) INFINITY)) {
tmp = (z / t) * (z / t);
} else {
tmp = fma((z / t), (z / t), ((x * x) / (y * y)));
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(z * z) / Float64(t * t)) tmp = 0.0 if (t_1 <= 5e+305) tmp = Float64(Float64(Float64(x / y) * Float64(x / y)) + t_1); elseif (t_1 <= Inf) tmp = Float64(Float64(z / t) * Float64(z / t)); else tmp = fma(Float64(z / t), Float64(z / t), Float64(Float64(x * x) / Float64(y * 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, 5e+305], N[(N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(N[(z / t), $MachinePrecision] * N[(z / t), $MachinePrecision]), $MachinePrecision], N[(N[(z / t), $MachinePrecision] * N[(z / t), $MachinePrecision] + N[(N[(x * x), $MachinePrecision] / N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{z \cdot z}{t \cdot t}\\
\mathbf{if}\;t\_1 \leq 5 \cdot 10^{+305}:\\
\;\;\;\;\frac{x}{y} \cdot \frac{x}{y} + t\_1\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\frac{z}{t} \cdot \frac{z}{t}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \frac{x \cdot x}{y \cdot y}\right)\\
\end{array}
\end{array}
if (/.f64 (*.f64 z z) (*.f64 t t)) < 5.00000000000000009e305Initial program 70.1%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6496.2
Applied rewrites96.2%
if 5.00000000000000009e305 < (/.f64 (*.f64 z z) (*.f64 t t)) < +inf.0Initial program 72.2%
Taylor expanded in x around 0
unpow2N/A
associate-*l/N/A
lower-*.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6492.3
Applied rewrites92.3%
Applied rewrites96.1%
if +inf.0 < (/.f64 (*.f64 z z) (*.f64 t t)) Initial program 0.0%
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-/.f6480.3
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
pow2N/A
lower-pow.f64N/A
lower-/.f6499.5
Applied rewrites99.5%
lift-pow.f64N/A
unpow2N/A
lift-/.f64N/A
lift-/.f64N/A
times-fracN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f6480.3
Applied rewrites80.3%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ (* z z) (* t t))))
(if (<= t_1 5e+305)
(+ (* (/ (/ x y) y) x) t_1)
(if (<= t_1 INFINITY)
(* (/ z t) (/ z t))
(fma (/ z t) (/ z t) (/ (* x x) (* y y)))))))
double code(double x, double y, double z, double t) {
double t_1 = (z * z) / (t * t);
double tmp;
if (t_1 <= 5e+305) {
tmp = (((x / y) / y) * x) + t_1;
} else if (t_1 <= ((double) INFINITY)) {
tmp = (z / t) * (z / t);
} else {
tmp = fma((z / t), (z / t), ((x * x) / (y * y)));
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(z * z) / Float64(t * t)) tmp = 0.0 if (t_1 <= 5e+305) tmp = Float64(Float64(Float64(Float64(x / y) / y) * x) + t_1); elseif (t_1 <= Inf) tmp = Float64(Float64(z / t) * Float64(z / t)); else tmp = fma(Float64(z / t), Float64(z / t), Float64(Float64(x * x) / Float64(y * 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, 5e+305], N[(N[(N[(N[(x / y), $MachinePrecision] / y), $MachinePrecision] * x), $MachinePrecision] + t$95$1), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(N[(z / t), $MachinePrecision] * N[(z / t), $MachinePrecision]), $MachinePrecision], N[(N[(z / t), $MachinePrecision] * N[(z / t), $MachinePrecision] + N[(N[(x * x), $MachinePrecision] / N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{z \cdot z}{t \cdot t}\\
\mathbf{if}\;t\_1 \leq 5 \cdot 10^{+305}:\\
\;\;\;\;\frac{\frac{x}{y}}{y} \cdot x + t\_1\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\frac{z}{t} \cdot \frac{z}{t}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \frac{x \cdot x}{y \cdot y}\right)\\
\end{array}
\end{array}
if (/.f64 (*.f64 z z) (*.f64 t t)) < 5.00000000000000009e305Initial program 70.1%
Taylor expanded in x around 0
unpow2N/A
associate-*l/N/A
lower-*.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6489.5
Applied rewrites89.5%
if 5.00000000000000009e305 < (/.f64 (*.f64 z z) (*.f64 t t)) < +inf.0Initial program 72.2%
Taylor expanded in x around 0
unpow2N/A
associate-*l/N/A
lower-*.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6492.3
Applied rewrites92.3%
Applied rewrites96.1%
if +inf.0 < (/.f64 (*.f64 z z) (*.f64 t t)) Initial program 0.0%
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-/.f6480.3
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
pow2N/A
lower-pow.f64N/A
lower-/.f6499.5
Applied rewrites99.5%
lift-pow.f64N/A
unpow2N/A
lift-/.f64N/A
lift-/.f64N/A
times-fracN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f6480.3
Applied rewrites80.3%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ (* z z) (* t t))))
(if (<= t_1 0.0)
(+ (* (/ x y) (/ x y)) t_1)
(fma (/ (/ 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 <= 0.0) {
tmp = ((x / y) * (x / y)) + t_1;
} else {
tmp = fma(((z / t) / t), z, (((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 <= 0.0) tmp = Float64(Float64(Float64(x / y) * Float64(x / y)) + t_1); else tmp = fma(Float64(Float64(z / t) / t), z, Float64(Float64(Float64(x / y) / y) * x)); 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, 0.0], N[(N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision], N[(N[(N[(z / t), $MachinePrecision] / t), $MachinePrecision] * z + N[(N[(N[(x / y), $MachinePrecision] / y), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{z \cdot z}{t \cdot t}\\
\mathbf{if}\;t\_1 \leq 0:\\
\;\;\;\;\frac{x}{y} \cdot \frac{x}{y} + t\_1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\frac{z}{t}}{t}, z, \frac{\frac{x}{y}}{y} \cdot x\right)\\
\end{array}
\end{array}
if (/.f64 (*.f64 z z) (*.f64 t t)) < 0.0Initial program 63.8%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6495.3
Applied rewrites95.3%
if 0.0 < (/.f64 (*.f64 z z) (*.f64 t t)) Initial program 63.8%
Taylor expanded in x around 0
+-commutativeN/A
unpow2N/A
associate-*l/N/A
lower-fma.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
unpow2N/A
associate-*l/N/A
lower-*.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6494.7
Applied rewrites94.7%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (/ (* x x) (* y y)))) (if (<= t_1 INFINITY) (fma (/ z t) (/ z t) t_1) (/ (/ z t) (/ t z)))))
double code(double x, double y, double z, double t) {
double t_1 = (x * x) / (y * y);
double tmp;
if (t_1 <= ((double) INFINITY)) {
tmp = fma((z / t), (z / t), t_1);
} else {
tmp = (z / t) / (t / z);
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(x * x) / Float64(y * y)) tmp = 0.0 if (t_1 <= Inf) tmp = fma(Float64(z / t), Float64(z / t), t_1); else tmp = Float64(Float64(z / t) / Float64(t / z)); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x * x), $MachinePrecision] / N[(y * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, Infinity], N[(N[(z / t), $MachinePrecision] * N[(z / t), $MachinePrecision] + t$95$1), $MachinePrecision], N[(N[(z / t), $MachinePrecision] / N[(t / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{x \cdot x}{y \cdot y}\\
\mathbf{if}\;t\_1 \leq \infty:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, t\_1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{z}{t}}{\frac{t}{z}}\\
\end{array}
\end{array}
if (/.f64 (*.f64 x x) (*.f64 y y)) < +inf.0Initial program 75.9%
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-/.f6490.5
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
pow2N/A
lower-pow.f64N/A
lower-/.f6499.7
Applied rewrites99.7%
lift-pow.f64N/A
unpow2N/A
lift-/.f64N/A
lift-/.f64N/A
times-fracN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f6490.5
Applied rewrites90.5%
if +inf.0 < (/.f64 (*.f64 x x) (*.f64 y y)) Initial program 0.0%
Taylor expanded in x around 0
unpow2N/A
associate-*l/N/A
lower-*.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6454.7
Applied rewrites54.7%
Applied rewrites57.0%
(FPCore (x y z t) :precision binary64 (if (<= (/ (* z z) (* t t)) 4e-64) (/ (* (* (- x) t) x) (* (* t y) (- y))) (/ (/ z t) (/ t z))))
double code(double x, double y, double z, double t) {
double tmp;
if (((z * z) / (t * t)) <= 4e-64) {
tmp = ((-x * t) * x) / ((t * y) * -y);
} else {
tmp = (z / t) / (t / z);
}
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 (((z * z) / (t * t)) <= 4d-64) then
tmp = ((-x * t) * x) / ((t * y) * -y)
else
tmp = (z / t) / (t / z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (((z * z) / (t * t)) <= 4e-64) {
tmp = ((-x * t) * x) / ((t * y) * -y);
} else {
tmp = (z / t) / (t / z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if ((z * z) / (t * t)) <= 4e-64: tmp = ((-x * t) * x) / ((t * y) * -y) else: tmp = (z / t) / (t / z) return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(Float64(z * z) / Float64(t * t)) <= 4e-64) tmp = Float64(Float64(Float64(Float64(-x) * t) * x) / Float64(Float64(t * y) * Float64(-y))); else tmp = Float64(Float64(z / t) / Float64(t / z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (((z * z) / (t * t)) <= 4e-64) tmp = ((-x * t) * x) / ((t * y) * -y); else tmp = (z / t) / (t / z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(N[(z * z), $MachinePrecision] / N[(t * t), $MachinePrecision]), $MachinePrecision], 4e-64], N[(N[(N[((-x) * t), $MachinePrecision] * x), $MachinePrecision] / N[(N[(t * y), $MachinePrecision] * (-y)), $MachinePrecision]), $MachinePrecision], N[(N[(z / t), $MachinePrecision] / N[(t / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{z \cdot z}{t \cdot t} \leq 4 \cdot 10^{-64}:\\
\;\;\;\;\frac{\left(\left(-x\right) \cdot t\right) \cdot x}{\left(t \cdot y\right) \cdot \left(-y\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{z}{t}}{\frac{t}{z}}\\
\end{array}
\end{array}
if (/.f64 (*.f64 z z) (*.f64 t t)) < 3.99999999999999986e-64Initial program 66.7%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lift-/.f64N/A
frac-2negN/A
frac-addN/A
lower-/.f64N/A
Applied rewrites65.3%
Taylor expanded in x around inf
associate-*r*N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
neg-mul-1N/A
lower-*.f64N/A
lower-neg.f6464.5
Applied rewrites64.5%
if 3.99999999999999986e-64 < (/.f64 (*.f64 z z) (*.f64 t t)) Initial program 61.7%
Taylor expanded in x around 0
unpow2N/A
associate-*l/N/A
lower-*.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6482.5
Applied rewrites82.5%
Applied rewrites84.3%
Final simplification76.1%
(FPCore (x y z t) :precision binary64 (/ (/ z t) (/ t z)))
double code(double x, double y, double z, double t) {
return (z / t) / (t / z);
}
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 = (z / t) / (t / z)
end function
public static double code(double x, double y, double z, double t) {
return (z / t) / (t / z);
}
def code(x, y, z, t): return (z / t) / (t / z)
function code(x, y, z, t) return Float64(Float64(z / t) / Float64(t / z)) end
function tmp = code(x, y, z, t) tmp = (z / t) / (t / z); end
code[x_, y_, z_, t_] := N[(N[(z / t), $MachinePrecision] / N[(t / z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{z}{t}}{\frac{t}{z}}
\end{array}
Initial program 63.8%
Taylor expanded in x around 0
unpow2N/A
associate-*l/N/A
lower-*.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6457.2
Applied rewrites57.2%
Applied rewrites58.9%
(FPCore (x y z t) :precision binary64 (* (/ z t) (/ z t)))
double code(double x, double y, double z, double t) {
return (z / t) * (z / 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 = (z / t) * (z / t)
end function
public static double code(double x, double y, double z, double t) {
return (z / t) * (z / t);
}
def code(x, y, z, t): return (z / t) * (z / t)
function code(x, y, z, t) return Float64(Float64(z / t) * Float64(z / t)) end
function tmp = code(x, y, z, t) tmp = (z / t) * (z / t); end
code[x_, y_, z_, t_] := N[(N[(z / t), $MachinePrecision] * N[(z / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{z}{t} \cdot \frac{z}{t}
\end{array}
Initial program 63.8%
Taylor expanded in x around 0
unpow2N/A
associate-*l/N/A
lower-*.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6457.2
Applied rewrites57.2%
Applied rewrites58.8%
(FPCore (x y z t) :precision binary64 (* (/ z (* t t)) z))
double code(double x, double y, double z, double t) {
return (z / (t * t)) * z;
}
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 = (z / (t * t)) * z
end function
public static double code(double x, double y, double z, double t) {
return (z / (t * t)) * z;
}
def code(x, y, z, t): return (z / (t * t)) * z
function code(x, y, z, t) return Float64(Float64(z / Float64(t * t)) * z) end
function tmp = code(x, y, z, t) tmp = (z / (t * t)) * z; end
code[x_, y_, z_, t_] := N[(N[(z / N[(t * t), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]
\begin{array}{l}
\\
\frac{z}{t \cdot t} \cdot z
\end{array}
Initial program 63.8%
Taylor expanded in x around 0
unpow2N/A
associate-*l/N/A
lower-*.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6457.2
Applied rewrites57.2%
Applied rewrites51.6%
(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 2024313
(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))))