
(FPCore (x y z t) :precision binary64 (+ x (/ (* y (- z x)) t)))
double code(double x, double y, double z, double t) {
return x + ((y * (z - x)) / 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 + ((y * (z - x)) / t)
end function
public static double code(double x, double y, double z, double t) {
return x + ((y * (z - x)) / t);
}
def code(x, y, z, t): return x + ((y * (z - x)) / t)
function code(x, y, z, t) return Float64(x + Float64(Float64(y * Float64(z - x)) / t)) end
function tmp = code(x, y, z, t) tmp = x + ((y * (z - x)) / t); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y \cdot \left(z - x\right)}{t}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 5 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (+ x (/ (* y (- z x)) t)))
double code(double x, double y, double z, double t) {
return x + ((y * (z - x)) / 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 + ((y * (z - x)) / t)
end function
public static double code(double x, double y, double z, double t) {
return x + ((y * (z - x)) / t);
}
def code(x, y, z, t): return x + ((y * (z - x)) / t)
function code(x, y, z, t) return Float64(x + Float64(Float64(y * Float64(z - x)) / t)) end
function tmp = code(x, y, z, t) tmp = x + ((y * (z - x)) / t); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y \cdot \left(z - x\right)}{t}
\end{array}
(FPCore (x y z t) :precision binary64 (+ x (* (/ y t) (- z x))))
double code(double x, double y, double z, double t) {
return x + ((y / t) * (z - 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 / t) * (z - x))
end function
public static double code(double x, double y, double z, double t) {
return x + ((y / t) * (z - x));
}
def code(x, y, z, t): return x + ((y / t) * (z - x))
function code(x, y, z, t) return Float64(x + Float64(Float64(y / t) * Float64(z - x))) end
function tmp = code(x, y, z, t) tmp = x + ((y / t) * (z - x)); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y / t), $MachinePrecision] * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y}{t} \cdot \left(z - x\right)
\end{array}
Initial program 92.1%
associate-*l/97.3%
Simplified97.3%
Final simplification97.3%
(FPCore (x y z t) :precision binary64 (if (or (<= x -1.15e-10) (not (<= x 3.8e+47))) (- x (* x (/ y t))) (+ x (/ y (/ t z)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -1.15e-10) || !(x <= 3.8e+47)) {
tmp = x - (x * (y / t));
} else {
tmp = x + (y / (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 ((x <= (-1.15d-10)) .or. (.not. (x <= 3.8d+47))) then
tmp = x - (x * (y / t))
else
tmp = x + (y / (t / z))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -1.15e-10) || !(x <= 3.8e+47)) {
tmp = x - (x * (y / t));
} else {
tmp = x + (y / (t / z));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x <= -1.15e-10) or not (x <= 3.8e+47): tmp = x - (x * (y / t)) else: tmp = x + (y / (t / z)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((x <= -1.15e-10) || !(x <= 3.8e+47)) tmp = Float64(x - Float64(x * Float64(y / t))); else tmp = Float64(x + Float64(y / Float64(t / z))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x <= -1.15e-10) || ~((x <= 3.8e+47))) tmp = x - (x * (y / t)); else tmp = x + (y / (t / z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -1.15e-10], N[Not[LessEqual[x, 3.8e+47]], $MachinePrecision]], N[(x - N[(x * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(y / N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.15 \cdot 10^{-10} \lor \neg \left(x \leq 3.8 \cdot 10^{+47}\right):\\
\;\;\;\;x - x \cdot \frac{y}{t}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{y}{\frac{t}{z}}\\
\end{array}
\end{array}
if x < -1.15000000000000004e-10 or 3.8000000000000003e47 < x Initial program 88.4%
associate-*l/99.9%
Simplified99.9%
Taylor expanded in z around 0 82.8%
associate-*r/92.2%
associate-*l*92.2%
neg-mul-192.2%
*-commutative92.2%
Simplified92.2%
if -1.15000000000000004e-10 < x < 3.8000000000000003e47Initial program 95.5%
associate-/l*96.8%
Simplified96.8%
Taylor expanded in z around inf 85.4%
Final simplification88.6%
(FPCore (x y z t) :precision binary64 (if (<= z -3.3e-90) (+ x (/ y (/ t z))) (if (<= z 4.6e-135) (- x (* y (/ x t))) (+ x (* (/ y t) z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -3.3e-90) {
tmp = x + (y / (t / z));
} else if (z <= 4.6e-135) {
tmp = x - (y * (x / t));
} else {
tmp = x + ((y / 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 <= (-3.3d-90)) then
tmp = x + (y / (t / z))
else if (z <= 4.6d-135) then
tmp = x - (y * (x / t))
else
tmp = x + ((y / t) * z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -3.3e-90) {
tmp = x + (y / (t / z));
} else if (z <= 4.6e-135) {
tmp = x - (y * (x / t));
} else {
tmp = x + ((y / t) * z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -3.3e-90: tmp = x + (y / (t / z)) elif z <= 4.6e-135: tmp = x - (y * (x / t)) else: tmp = x + ((y / t) * z) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -3.3e-90) tmp = Float64(x + Float64(y / Float64(t / z))); elseif (z <= 4.6e-135) tmp = Float64(x - Float64(y * Float64(x / t))); else tmp = Float64(x + Float64(Float64(y / t) * z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -3.3e-90) tmp = x + (y / (t / z)); elseif (z <= 4.6e-135) tmp = x - (y * (x / t)); else tmp = x + ((y / t) * z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -3.3e-90], N[(x + N[(y / N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 4.6e-135], N[(x - N[(y * N[(x / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(y / t), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.3 \cdot 10^{-90}:\\
\;\;\;\;x + \frac{y}{\frac{t}{z}}\\
\mathbf{elif}\;z \leq 4.6 \cdot 10^{-135}:\\
\;\;\;\;x - y \cdot \frac{x}{t}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{y}{t} \cdot z\\
\end{array}
\end{array}
if z < -3.3e-90Initial program 91.2%
associate-/l*92.7%
Simplified92.7%
Taylor expanded in z around inf 85.2%
if -3.3e-90 < z < 4.5999999999999998e-135Initial program 91.8%
associate-/l*96.2%
Simplified96.2%
Taylor expanded in z around 0 92.2%
associate-*r/92.2%
neg-mul-192.2%
Simplified92.2%
associate-/r/93.3%
*-commutative93.3%
add-sqr-sqrt39.0%
sqrt-unprod61.2%
sqr-neg61.2%
sqrt-unprod26.3%
add-sqr-sqrt48.7%
clear-num48.7%
div-inv48.7%
frac-2neg48.7%
associate-/r/44.6%
add-sqr-sqrt20.9%
sqrt-unprod62.8%
sqr-neg62.8%
sqrt-unprod51.7%
add-sqr-sqrt89.6%
Applied egg-rr89.6%
if 4.5999999999999998e-135 < z Initial program 93.1%
associate-*l/98.9%
Simplified98.9%
Taylor expanded in z around inf 82.1%
associate-*l/86.0%
*-commutative86.0%
Simplified86.0%
Final simplification86.8%
(FPCore (x y z t) :precision binary64 (+ x (* (/ y t) z)))
double code(double x, double y, double z, double t) {
return x + ((y / 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 = x + ((y / t) * z)
end function
public static double code(double x, double y, double z, double t) {
return x + ((y / t) * z);
}
def code(x, y, z, t): return x + ((y / t) * z)
function code(x, y, z, t) return Float64(x + Float64(Float64(y / t) * z)) end
function tmp = code(x, y, z, t) tmp = x + ((y / t) * z); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y / t), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y}{t} \cdot z
\end{array}
Initial program 92.1%
associate-*l/97.3%
Simplified97.3%
Taylor expanded in z around inf 74.1%
associate-*l/76.8%
*-commutative76.8%
Simplified76.8%
Final simplification76.8%
(FPCore (x y z t) :precision binary64 x)
double code(double x, double y, double z, double t) {
return 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
end function
public static double code(double x, double y, double z, double t) {
return x;
}
def code(x, y, z, t): return x
function code(x, y, z, t) return x end
function tmp = code(x, y, z, t) tmp = x; end
code[x_, y_, z_, t_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 92.1%
associate-*l/97.3%
Simplified97.3%
Taylor expanded in z around inf 74.1%
associate-*l/76.8%
*-commutative76.8%
Simplified76.8%
Taylor expanded in x around inf 42.4%
Final simplification42.4%
(FPCore (x y z t) :precision binary64 (- x (+ (* x (/ y t)) (* (- z) (/ y t)))))
double code(double x, double y, double z, double t) {
return x - ((x * (y / t)) + (-z * (y / 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 / t)) + (-z * (y / t)))
end function
public static double code(double x, double y, double z, double t) {
return x - ((x * (y / t)) + (-z * (y / t)));
}
def code(x, y, z, t): return x - ((x * (y / t)) + (-z * (y / t)))
function code(x, y, z, t) return Float64(x - Float64(Float64(x * Float64(y / t)) + Float64(Float64(-z) * Float64(y / t)))) end
function tmp = code(x, y, z, t) tmp = x - ((x * (y / t)) + (-z * (y / t))); end
code[x_, y_, z_, t_] := N[(x - N[(N[(x * N[(y / t), $MachinePrecision]), $MachinePrecision] + N[((-z) * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \left(x \cdot \frac{y}{t} + \left(-z\right) \cdot \frac{y}{t}\right)
\end{array}
herbie shell --seed 2023322
(FPCore (x y z t)
:name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, D"
:precision binary64
:herbie-target
(- x (+ (* x (/ y t)) (* (- z) (/ y t))))
(+ x (/ (* y (- z x)) t)))