
(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 4 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}
t_m = (fabs.f64 t) (FPCore (x y z t_m) :precision binary64 (+ (/ (/ x y) (/ y x)) (* (/ (/ z t_m) (sqrt t_m)) (/ z (sqrt t_m)))))
t_m = fabs(t);
double code(double x, double y, double z, double t_m) {
return ((x / y) / (y / x)) + (((z / t_m) / sqrt(t_m)) * (z / sqrt(t_m)));
}
t_m = abs(t)
real(8) function code(x, y, z, t_m)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t_m
code = ((x / y) / (y / x)) + (((z / t_m) / sqrt(t_m)) * (z / sqrt(t_m)))
end function
t_m = Math.abs(t);
public static double code(double x, double y, double z, double t_m) {
return ((x / y) / (y / x)) + (((z / t_m) / Math.sqrt(t_m)) * (z / Math.sqrt(t_m)));
}
t_m = math.fabs(t) def code(x, y, z, t_m): return ((x / y) / (y / x)) + (((z / t_m) / math.sqrt(t_m)) * (z / math.sqrt(t_m)))
t_m = abs(t) function code(x, y, z, t_m) return Float64(Float64(Float64(x / y) / Float64(y / x)) + Float64(Float64(Float64(z / t_m) / sqrt(t_m)) * Float64(z / sqrt(t_m)))) end
t_m = abs(t); function tmp = code(x, y, z, t_m) tmp = ((x / y) / (y / x)) + (((z / t_m) / sqrt(t_m)) * (z / sqrt(t_m))); end
t_m = N[Abs[t], $MachinePrecision] code[x_, y_, z_, t$95$m_] := N[(N[(N[(x / y), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(z / t$95$m), $MachinePrecision] / N[Sqrt[t$95$m], $MachinePrecision]), $MachinePrecision] * N[(z / N[Sqrt[t$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
t_m = \left|t\right|
\\
\frac{\frac{x}{y}}{\frac{y}{x}} + \frac{\frac{z}{t\_m}}{\sqrt{t\_m}} \cdot \frac{z}{\sqrt{t\_m}}
\end{array}
Initial program 67.6%
associate-/l*75.9%
Simplified75.9%
associate-*r/67.6%
times-frac85.8%
clear-num85.8%
un-div-inv85.9%
Applied egg-rr85.9%
frac-times99.7%
associate-*r/98.6%
add-sqr-sqrt51.4%
times-frac52.1%
Applied egg-rr52.1%
t_m = (fabs.f64 t) (FPCore (x y z t_m) :precision binary64 (fma (/ x y) (/ x y) (* (/ z t_m) (/ z t_m))))
t_m = fabs(t);
double code(double x, double y, double z, double t_m) {
return fma((x / y), (x / y), ((z / t_m) * (z / t_m)));
}
t_m = abs(t) function code(x, y, z, t_m) return fma(Float64(x / y), Float64(x / y), Float64(Float64(z / t_m) * Float64(z / t_m))) end
t_m = N[Abs[t], $MachinePrecision] code[x_, y_, z_, t$95$m_] := N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision] + N[(N[(z / t$95$m), $MachinePrecision] * N[(z / t$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
t_m = \left|t\right|
\\
\mathsf{fma}\left(\frac{x}{y}, \frac{x}{y}, \frac{z}{t\_m} \cdot \frac{z}{t\_m}\right)
\end{array}
Initial program 67.6%
times-frac85.8%
fma-define85.8%
times-frac99.7%
Simplified99.7%
t_m = (fabs.f64 t) (FPCore (x y z t_m) :precision binary64 (+ (* (/ z t_m) (/ z t_m)) (* (/ x y) (/ x y))))
t_m = fabs(t);
double code(double x, double y, double z, double t_m) {
return ((z / t_m) * (z / t_m)) + ((x / y) * (x / y));
}
t_m = abs(t)
real(8) function code(x, y, z, t_m)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t_m
code = ((z / t_m) * (z / t_m)) + ((x / y) * (x / y))
end function
t_m = Math.abs(t);
public static double code(double x, double y, double z, double t_m) {
return ((z / t_m) * (z / t_m)) + ((x / y) * (x / y));
}
t_m = math.fabs(t) def code(x, y, z, t_m): return ((z / t_m) * (z / t_m)) + ((x / y) * (x / y))
t_m = abs(t) function code(x, y, z, t_m) return Float64(Float64(Float64(z / t_m) * Float64(z / t_m)) + Float64(Float64(x / y) * Float64(x / y))) end
t_m = abs(t); function tmp = code(x, y, z, t_m) tmp = ((z / t_m) * (z / t_m)) + ((x / y) * (x / y)); end
t_m = N[Abs[t], $MachinePrecision] code[x_, y_, z_, t$95$m_] := N[(N[(N[(z / t$95$m), $MachinePrecision] * N[(z / t$95$m), $MachinePrecision]), $MachinePrecision] + N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
t_m = \left|t\right|
\\
\frac{z}{t\_m} \cdot \frac{z}{t\_m} + \frac{x}{y} \cdot \frac{x}{y}
\end{array}
Initial program 67.6%
frac-times78.7%
Applied egg-rr78.7%
times-frac99.7%
Applied egg-rr99.7%
Final simplification99.7%
t_m = (fabs.f64 t) (FPCore (x y z t_m) :precision binary64 (+ (* (/ z t_m) (/ z t_m)) (* x (/ x (* y y)))))
t_m = fabs(t);
double code(double x, double y, double z, double t_m) {
return ((z / t_m) * (z / t_m)) + (x * (x / (y * y)));
}
t_m = abs(t)
real(8) function code(x, y, z, t_m)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t_m
code = ((z / t_m) * (z / t_m)) + (x * (x / (y * y)))
end function
t_m = Math.abs(t);
public static double code(double x, double y, double z, double t_m) {
return ((z / t_m) * (z / t_m)) + (x * (x / (y * y)));
}
t_m = math.fabs(t) def code(x, y, z, t_m): return ((z / t_m) * (z / t_m)) + (x * (x / (y * y)))
t_m = abs(t) function code(x, y, z, t_m) return Float64(Float64(Float64(z / t_m) * Float64(z / t_m)) + Float64(x * Float64(x / Float64(y * y)))) end
t_m = abs(t); function tmp = code(x, y, z, t_m) tmp = ((z / t_m) * (z / t_m)) + (x * (x / (y * y))); end
t_m = N[Abs[t], $MachinePrecision] code[x_, y_, z_, t$95$m_] := N[(N[(N[(z / t$95$m), $MachinePrecision] * N[(z / t$95$m), $MachinePrecision]), $MachinePrecision] + N[(x * N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
t_m = \left|t\right|
\\
\frac{z}{t\_m} \cdot \frac{z}{t\_m} + x \cdot \frac{x}{y \cdot y}
\end{array}
Initial program 67.6%
associate-/l*75.9%
Simplified75.9%
frac-times78.7%
Applied egg-rr87.9%
Final simplification87.9%
(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 2024101
(FPCore (x y z t)
:name "Graphics.Rasterific.Svg.PathConverter:arcToSegments from rasterific-svg-0.2.3.1"
:precision binary64
:alt
(+ (pow (/ x y) 2.0) (pow (/ z t) 2.0))
(+ (/ (* x x) (* y y)) (/ (* z z) (* t t))))