
(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 7 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 94.7%
associate-*l/98.1%
Simplified98.1%
Final simplification98.1%
(FPCore (x y z t) :precision binary64 (if (or (<= z -6.1e+97) (not (<= z 6.6e-56))) (+ x (* (/ y t) z)) (* x (- 1.0 (/ y t)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -6.1e+97) || !(z <= 6.6e-56)) {
tmp = x + ((y / t) * z);
} else {
tmp = x * (1.0 - (y / t));
}
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 <= (-6.1d+97)) .or. (.not. (z <= 6.6d-56))) then
tmp = x + ((y / t) * z)
else
tmp = x * (1.0d0 - (y / t))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -6.1e+97) || !(z <= 6.6e-56)) {
tmp = x + ((y / t) * z);
} else {
tmp = x * (1.0 - (y / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -6.1e+97) or not (z <= 6.6e-56): tmp = x + ((y / t) * z) else: tmp = x * (1.0 - (y / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -6.1e+97) || !(z <= 6.6e-56)) tmp = Float64(x + Float64(Float64(y / t) * z)); else tmp = Float64(x * Float64(1.0 - Float64(y / t))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -6.1e+97) || ~((z <= 6.6e-56))) tmp = x + ((y / t) * z); else tmp = x * (1.0 - (y / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -6.1e+97], N[Not[LessEqual[z, 6.6e-56]], $MachinePrecision]], N[(x + N[(N[(y / t), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.1 \cdot 10^{+97} \lor \neg \left(z \leq 6.6 \cdot 10^{-56}\right):\\
\;\;\;\;x + \frac{y}{t} \cdot z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - \frac{y}{t}\right)\\
\end{array}
\end{array}
if z < -6.1e97 or 6.59999999999999967e-56 < z Initial program 93.5%
associate-*l/99.1%
Simplified99.1%
Taylor expanded in z around inf 87.1%
associate-*l/91.2%
*-commutative91.2%
Simplified91.2%
if -6.1e97 < z < 6.59999999999999967e-56Initial program 95.8%
associate-*l/97.1%
Simplified97.1%
Taylor expanded in x around inf 88.3%
mul-1-neg88.3%
unsub-neg88.3%
Simplified88.3%
Final simplification89.8%
(FPCore (x y z t) :precision binary64 (if (<= z -1.05e+97) (+ x (* (/ y t) z)) (if (<= z 1.46e-55) (* x (- 1.0 (/ y t))) (+ x (/ z (/ t y))))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.05e+97) {
tmp = x + ((y / t) * z);
} else if (z <= 1.46e-55) {
tmp = x * (1.0 - (y / t));
} else {
tmp = x + (z / (t / 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 (z <= (-1.05d+97)) then
tmp = x + ((y / t) * z)
else if (z <= 1.46d-55) then
tmp = x * (1.0d0 - (y / t))
else
tmp = x + (z / (t / y))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.05e+97) {
tmp = x + ((y / t) * z);
} else if (z <= 1.46e-55) {
tmp = x * (1.0 - (y / t));
} else {
tmp = x + (z / (t / y));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -1.05e+97: tmp = x + ((y / t) * z) elif z <= 1.46e-55: tmp = x * (1.0 - (y / t)) else: tmp = x + (z / (t / y)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -1.05e+97) tmp = Float64(x + Float64(Float64(y / t) * z)); elseif (z <= 1.46e-55) tmp = Float64(x * Float64(1.0 - Float64(y / t))); else tmp = Float64(x + Float64(z / Float64(t / y))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -1.05e+97) tmp = x + ((y / t) * z); elseif (z <= 1.46e-55) tmp = x * (1.0 - (y / t)); else tmp = x + (z / (t / y)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -1.05e+97], N[(x + N[(N[(y / t), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.46e-55], N[(x * N[(1.0 - N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z / N[(t / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.05 \cdot 10^{+97}:\\
\;\;\;\;x + \frac{y}{t} \cdot z\\
\mathbf{elif}\;z \leq 1.46 \cdot 10^{-55}:\\
\;\;\;\;x \cdot \left(1 - \frac{y}{t}\right)\\
\mathbf{else}:\\
\;\;\;\;x + \frac{z}{\frac{t}{y}}\\
\end{array}
\end{array}
if z < -1.05000000000000006e97Initial program 91.6%
associate-*l/99.8%
Simplified99.8%
Taylor expanded in z around inf 89.5%
associate-*l/97.7%
*-commutative97.7%
Simplified97.7%
if -1.05000000000000006e97 < z < 1.46000000000000009e-55Initial program 95.8%
associate-*l/97.1%
Simplified97.1%
Taylor expanded in x around inf 88.3%
mul-1-neg88.3%
unsub-neg88.3%
Simplified88.3%
if 1.46000000000000009e-55 < z Initial program 94.5%
associate-*l/98.7%
Simplified98.7%
Taylor expanded in z around inf 85.7%
associate-*l/87.5%
*-commutative87.5%
Simplified87.5%
clear-num87.5%
div-inv87.6%
Applied egg-rr87.6%
Final simplification89.8%
(FPCore (x y z t) :precision binary64 (if (or (<= y -3.2e-7) (not (<= y 1.32e+110))) (* x (/ (- y) t)) x))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -3.2e-7) || !(y <= 1.32e+110)) {
tmp = x * (-y / t);
} else {
tmp = x;
}
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 ((y <= (-3.2d-7)) .or. (.not. (y <= 1.32d+110))) then
tmp = x * (-y / t)
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -3.2e-7) || !(y <= 1.32e+110)) {
tmp = x * (-y / t);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -3.2e-7) or not (y <= 1.32e+110): tmp = x * (-y / t) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -3.2e-7) || !(y <= 1.32e+110)) tmp = Float64(x * Float64(Float64(-y) / t)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= -3.2e-7) || ~((y <= 1.32e+110))) tmp = x * (-y / t); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -3.2e-7], N[Not[LessEqual[y, 1.32e+110]], $MachinePrecision]], N[(x * N[((-y) / t), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.2 \cdot 10^{-7} \lor \neg \left(y \leq 1.32 \cdot 10^{+110}\right):\\
\;\;\;\;x \cdot \frac{-y}{t}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -3.2000000000000001e-7 or 1.32e110 < y Initial program 88.6%
associate-*l/95.9%
Simplified95.9%
Taylor expanded in x around inf 67.2%
mul-1-neg67.2%
unsub-neg67.2%
Simplified67.2%
Taylor expanded in y around inf 58.9%
mul-1-neg58.9%
distribute-frac-neg58.9%
Simplified58.9%
if -3.2000000000000001e-7 < y < 1.32e110Initial program 98.1%
associate-*l/99.3%
Simplified99.3%
Taylor expanded in y around 0 58.2%
Final simplification58.4%
(FPCore (x y z t) :precision binary64 (if (<= y -5e-7) (* y (/ (- x) t)) (if (<= y 1.25e+110) x (* x (/ (- y) t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -5e-7) {
tmp = y * (-x / t);
} else if (y <= 1.25e+110) {
tmp = x;
} else {
tmp = x * (-y / t);
}
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 (y <= (-5d-7)) then
tmp = y * (-x / t)
else if (y <= 1.25d+110) then
tmp = x
else
tmp = x * (-y / t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -5e-7) {
tmp = y * (-x / t);
} else if (y <= 1.25e+110) {
tmp = x;
} else {
tmp = x * (-y / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -5e-7: tmp = y * (-x / t) elif y <= 1.25e+110: tmp = x else: tmp = x * (-y / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -5e-7) tmp = Float64(y * Float64(Float64(-x) / t)); elseif (y <= 1.25e+110) tmp = x; else tmp = Float64(x * Float64(Float64(-y) / t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -5e-7) tmp = y * (-x / t); elseif (y <= 1.25e+110) tmp = x; else tmp = x * (-y / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -5e-7], N[(y * N[((-x) / t), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.25e+110], x, N[(x * N[((-y) / t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5 \cdot 10^{-7}:\\
\;\;\;\;y \cdot \frac{-x}{t}\\
\mathbf{elif}\;y \leq 1.25 \cdot 10^{+110}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{-y}{t}\\
\end{array}
\end{array}
if y < -4.99999999999999977e-7Initial program 91.9%
associate-*l/93.6%
Simplified93.6%
Taylor expanded in x around inf 64.2%
mul-1-neg64.2%
unsub-neg64.2%
Simplified64.2%
Taylor expanded in y around inf 58.6%
associate-*r/58.6%
*-commutative58.6%
neg-mul-158.6%
distribute-rgt-neg-in58.6%
associate-*r/60.2%
Simplified60.2%
if -4.99999999999999977e-7 < y < 1.24999999999999995e110Initial program 98.1%
associate-*l/99.3%
Simplified99.3%
Taylor expanded in y around 0 58.2%
if 1.24999999999999995e110 < y Initial program 82.7%
associate-*l/99.9%
Simplified99.9%
Taylor expanded in x around inf 72.6%
mul-1-neg72.6%
unsub-neg72.6%
Simplified72.6%
Taylor expanded in y around inf 62.2%
mul-1-neg62.2%
distribute-frac-neg62.2%
Simplified62.2%
Final simplification59.2%
(FPCore (x y z t) :precision binary64 (* x (- 1.0 (/ y t))))
double code(double x, double y, double z, double t) {
return x * (1.0 - (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 * (1.0d0 - (y / t))
end function
public static double code(double x, double y, double z, double t) {
return x * (1.0 - (y / t));
}
def code(x, y, z, t): return x * (1.0 - (y / t))
function code(x, y, z, t) return Float64(x * Float64(1.0 - Float64(y / t))) end
function tmp = code(x, y, z, t) tmp = x * (1.0 - (y / t)); end
code[x_, y_, z_, t_] := N[(x * N[(1.0 - N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 - \frac{y}{t}\right)
\end{array}
Initial program 94.7%
associate-*l/98.1%
Simplified98.1%
Taylor expanded in x around inf 68.7%
mul-1-neg68.7%
unsub-neg68.7%
Simplified68.7%
Final simplification68.7%
(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 94.7%
associate-*l/98.1%
Simplified98.1%
Taylor expanded in y around 0 41.0%
Final simplification41.0%
(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 2024026
(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)))