
(FPCore (x y z t a b) :precision binary64 (/ (+ (* x y) (* z (- t a))) (+ y (* z (- b y)))))
double code(double x, double y, double z, double t, double a, double b) {
return ((x * y) + (z * (t - a))) / (y + (z * (b - y)));
}
real(8) function code(x, y, z, t, a, b)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((x * y) + (z * (t - a))) / (y + (z * (b - y)))
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return ((x * y) + (z * (t - a))) / (y + (z * (b - y)));
}
def code(x, y, z, t, a, b): return ((x * y) + (z * (t - a))) / (y + (z * (b - y)))
function code(x, y, z, t, a, b) return Float64(Float64(Float64(x * y) + Float64(z * Float64(t - a))) / Float64(y + Float64(z * Float64(b - y)))) end
function tmp = code(x, y, z, t, a, b) tmp = ((x * y) + (z * (t - a))) / (y + (z * (b - y))); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(x * y), $MachinePrecision] + N[(z * N[(t - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y + N[(z * N[(b - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a b) :precision binary64 (/ (+ (* x y) (* z (- t a))) (+ y (* z (- b y)))))
double code(double x, double y, double z, double t, double a, double b) {
return ((x * y) + (z * (t - a))) / (y + (z * (b - y)));
}
real(8) function code(x, y, z, t, a, b)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((x * y) + (z * (t - a))) / (y + (z * (b - y)))
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return ((x * y) + (z * (t - a))) / (y + (z * (b - y)));
}
def code(x, y, z, t, a, b): return ((x * y) + (z * (t - a))) / (y + (z * (b - y)))
function code(x, y, z, t, a, b) return Float64(Float64(Float64(x * y) + Float64(z * Float64(t - a))) / Float64(y + Float64(z * Float64(b - y)))) end
function tmp = code(x, y, z, t, a, b) tmp = ((x * y) + (z * (t - a))) / (y + (z * (b - y))); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(x * y), $MachinePrecision] + N[(z * N[(t - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y + N[(z * N[(b - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)}
\end{array}
(FPCore (x y z t a b) :precision binary64 (/ (+ (* x y) (* z (- t a))) (+ y (* z (- b y)))))
double code(double x, double y, double z, double t, double a, double b) {
return ((x * y) + (z * (t - a))) / (y + (z * (b - y)));
}
real(8) function code(x, y, z, t, a, b)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((x * y) + (z * (t - a))) / (y + (z * (b - y)))
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return ((x * y) + (z * (t - a))) / (y + (z * (b - y)));
}
def code(x, y, z, t, a, b): return ((x * y) + (z * (t - a))) / (y + (z * (b - y)))
function code(x, y, z, t, a, b) return Float64(Float64(Float64(x * y) + Float64(z * Float64(t - a))) / Float64(y + Float64(z * Float64(b - y)))) end
function tmp = code(x, y, z, t, a, b) tmp = ((x * y) + (z * (t - a))) / (y + (z * (b - y))); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(x * y), $MachinePrecision] + N[(z * N[(t - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y + N[(z * N[(b - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)}
\end{array}
Initial program 67.4%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (+ y (* z (- b y)))) (t_2 (/ (* z (- t a)) t_1))) (if (<= z -5.8e-152) t_2 (if (<= z 7.5e-131) (/ (* x y) t_1) t_2))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = y + (z * (b - y));
double t_2 = (z * (t - a)) / t_1;
double tmp;
if (z <= -5.8e-152) {
tmp = t_2;
} else if (z <= 7.5e-131) {
tmp = (x * y) / t_1;
} else {
tmp = t_2;
}
return tmp;
}
real(8) function code(x, y, z, t, a, b)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = y + (z * (b - y))
t_2 = (z * (t - a)) / t_1
if (z <= (-5.8d-152)) then
tmp = t_2
else if (z <= 7.5d-131) then
tmp = (x * y) / t_1
else
tmp = t_2
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
double t_1 = y + (z * (b - y));
double t_2 = (z * (t - a)) / t_1;
double tmp;
if (z <= -5.8e-152) {
tmp = t_2;
} else if (z <= 7.5e-131) {
tmp = (x * y) / t_1;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = y + (z * (b - y)) t_2 = (z * (t - a)) / t_1 tmp = 0 if z <= -5.8e-152: tmp = t_2 elif z <= 7.5e-131: tmp = (x * y) / t_1 else: tmp = t_2 return tmp
function code(x, y, z, t, a, b) t_1 = Float64(y + Float64(z * Float64(b - y))) t_2 = Float64(Float64(z * Float64(t - a)) / t_1) tmp = 0.0 if (z <= -5.8e-152) tmp = t_2; elseif (z <= 7.5e-131) tmp = Float64(Float64(x * y) / t_1); else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = y + (z * (b - y)); t_2 = (z * (t - a)) / t_1; tmp = 0.0; if (z <= -5.8e-152) tmp = t_2; elseif (z <= 7.5e-131) tmp = (x * y) / t_1; else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(y + N[(z * N[(b - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(z * N[(t - a), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]}, If[LessEqual[z, -5.8e-152], t$95$2, If[LessEqual[z, 7.5e-131], N[(N[(x * y), $MachinePrecision] / t$95$1), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := y + z \cdot \left(b - y\right)\\
t_2 := \frac{z \cdot \left(t - a\right)}{t\_1}\\
\mathbf{if}\;z \leq -5.8 \cdot 10^{-152}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;z \leq 7.5 \cdot 10^{-131}:\\
\;\;\;\;\frac{x \cdot y}{t\_1}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if z < -5.8000000000000003e-152 or 7.49999999999999964e-131 < z Initial program 58.4%
Taylor expanded in x around 0
Applied rewrites45.7%
if -5.8000000000000003e-152 < z < 7.49999999999999964e-131Initial program 89.5%
Taylor expanded in x around 0
Applied rewrites65.1%
(FPCore (x y z t a b) :precision binary64 (/ (* x y) (+ y (* z (- b y)))))
double code(double x, double y, double z, double t, double a, double b) {
return (x * y) / (y + (z * (b - y)));
}
real(8) function code(x, y, z, t, a, b)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (x * y) / (y + (z * (b - y)))
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return (x * y) / (y + (z * (b - y)));
}
def code(x, y, z, t, a, b): return (x * y) / (y + (z * (b - y)))
function code(x, y, z, t, a, b) return Float64(Float64(x * y) / Float64(y + Float64(z * Float64(b - y)))) end
function tmp = code(x, y, z, t, a, b) tmp = (x * y) / (y + (z * (b - y))); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(x * y), $MachinePrecision] / N[(y + N[(z * N[(b - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot y}{y + z \cdot \left(b - y\right)}
\end{array}
Initial program 67.4%
Taylor expanded in x around 0
Applied rewrites32.1%
(FPCore (x y z t a b) :precision binary64 (/ (- t a) (+ y (* z (- b y)))))
double code(double x, double y, double z, double t, double a, double b) {
return (t - a) / (y + (z * (b - y)));
}
real(8) function code(x, y, z, t, a, b)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (t - a) / (y + (z * (b - y)))
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return (t - a) / (y + (z * (b - y)));
}
def code(x, y, z, t, a, b): return (t - a) / (y + (z * (b - y)))
function code(x, y, z, t, a, b) return Float64(Float64(t - a) / Float64(y + Float64(z * Float64(b - y)))) end
function tmp = code(x, y, z, t, a, b) tmp = (t - a) / (y + (z * (b - y))); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(t - a), $MachinePrecision] / N[(y + N[(z * N[(b - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{t - a}{y + z \cdot \left(b - y\right)}
\end{array}
Initial program 67.4%
Taylor expanded in x around 0
Applied rewrites40.1%
Taylor expanded in x around 0
Applied rewrites6.6%
(FPCore (x y z t a b) :precision binary64 (* z (- t a)))
double code(double x, double y, double z, double t, double a, double b) {
return z * (t - a);
}
real(8) function code(x, y, z, t, a, b)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
code = z * (t - a)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return z * (t - a);
}
def code(x, y, z, t, a, b): return z * (t - a)
function code(x, y, z, t, a, b) return Float64(z * Float64(t - a)) end
function tmp = code(x, y, z, t, a, b) tmp = z * (t - a); end
code[x_, y_, z_, t_, a_, b_] := N[(z * N[(t - a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
z \cdot \left(t - a\right)
\end{array}
Initial program 67.4%
Taylor expanded in x around 0
Applied rewrites40.1%
Taylor expanded in x around 0
Applied rewrites4.2%
(FPCore (x y z t a b) :precision binary64 (* x y))
double code(double x, double y, double z, double t, double a, double b) {
return x * y;
}
real(8) function code(x, y, z, t, a, b)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
code = x * y
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return x * y;
}
def code(x, y, z, t, a, b): return x * y
function code(x, y, z, t, a, b) return Float64(x * y) end
function tmp = code(x, y, z, t, a, b) tmp = x * y; end
code[x_, y_, z_, t_, a_, b_] := N[(x * y), $MachinePrecision]
\begin{array}{l}
\\
x \cdot y
\end{array}
Initial program 67.4%
Taylor expanded in x around 0
Applied rewrites40.1%
Taylor expanded in y around 0
Applied rewrites3.7%
(FPCore (x y z t a b) :precision binary64 (- b y))
double code(double x, double y, double z, double t, double a, double b) {
return b - y;
}
real(8) function code(x, y, z, t, a, b)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
code = b - y
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return b - y;
}
def code(x, y, z, t, a, b): return b - y
function code(x, y, z, t, a, b) return Float64(b - y) end
function tmp = code(x, y, z, t, a, b) tmp = b - y; end
code[x_, y_, z_, t_, a_, b_] := N[(b - y), $MachinePrecision]
\begin{array}{l}
\\
b - y
\end{array}
Initial program 67.4%
Taylor expanded in x around 0
Applied rewrites40.1%
Taylor expanded in x around inf
Applied rewrites2.6%
(FPCore (x y z t a b) :precision binary64 (- (/ (+ (* z t) (* y x)) (+ y (* z (- b y)))) (/ a (+ (- b y) (/ y z)))))
double code(double x, double y, double z, double t, double a, double b) {
return (((z * t) + (y * x)) / (y + (z * (b - y)))) - (a / ((b - y) + (y / z)));
}
real(8) function code(x, y, z, t, a, b)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (((z * t) + (y * x)) / (y + (z * (b - y)))) - (a / ((b - y) + (y / z)))
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return (((z * t) + (y * x)) / (y + (z * (b - y)))) - (a / ((b - y) + (y / z)));
}
def code(x, y, z, t, a, b): return (((z * t) + (y * x)) / (y + (z * (b - y)))) - (a / ((b - y) + (y / z)))
function code(x, y, z, t, a, b) return Float64(Float64(Float64(Float64(z * t) + Float64(y * x)) / Float64(y + Float64(z * Float64(b - y)))) - Float64(a / Float64(Float64(b - y) + Float64(y / z)))) end
function tmp = code(x, y, z, t, a, b) tmp = (((z * t) + (y * x)) / (y + (z * (b - y)))) - (a / ((b - y) + (y / z))); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(N[(z * t), $MachinePrecision] + N[(y * x), $MachinePrecision]), $MachinePrecision] / N[(y + N[(z * N[(b - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(a / N[(N[(b - y), $MachinePrecision] + N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{z \cdot t + y \cdot x}{y + z \cdot \left(b - y\right)} - \frac{a}{\left(b - y\right) + \frac{y}{z}}
\end{array}
herbie shell --seed 2024313
(FPCore (x y z t a b)
:name "Development.Shake.Progress:decay from shake-0.15.5"
:precision binary64
:alt
(! :herbie-platform default (- (/ (+ (* z t) (* y x)) (+ y (* z (- b y)))) (/ a (+ (- b y) (/ y z)))))
(/ (+ (* x y) (* z (- t a))) (+ y (* z (- b y)))))