Optimisation.CirclePacking:place from circle-packing-0.1.0.4, D

Percentage Accurate: 92.8% → 98.9%
Time: 7.9s
Alternatives: 8
Speedup: 1.0×

Specification

?
\[\begin{array}{l} \\ x + \frac{y \cdot \left(z - x\right)}{t} \end{array} \]
(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:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 8 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 92.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ x + \frac{y \cdot \left(z - x\right)}{t} \end{array} \]
(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}

Alternative 1: 98.9% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x + \frac{y \cdot \left(z - x\right)}{t}\\ \mathbf{if}\;t_1 \leq -\infty \lor \neg \left(t_1 \leq 5 \cdot 10^{+263}\right):\\ \;\;\;\;x + \left(z - x\right) \cdot \frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (+ x (/ (* y (- z x)) t))))
   (if (or (<= t_1 (- INFINITY)) (not (<= t_1 5e+263)))
     (+ x (* (- z x) (/ y t)))
     t_1)))
double code(double x, double y, double z, double t) {
	double t_1 = x + ((y * (z - x)) / t);
	double tmp;
	if ((t_1 <= -((double) INFINITY)) || !(t_1 <= 5e+263)) {
		tmp = x + ((z - x) * (y / t));
	} else {
		tmp = t_1;
	}
	return tmp;
}
public static double code(double x, double y, double z, double t) {
	double t_1 = x + ((y * (z - x)) / t);
	double tmp;
	if ((t_1 <= -Double.POSITIVE_INFINITY) || !(t_1 <= 5e+263)) {
		tmp = x + ((z - x) * (y / t));
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = x + ((y * (z - x)) / t)
	tmp = 0
	if (t_1 <= -math.inf) or not (t_1 <= 5e+263):
		tmp = x + ((z - x) * (y / t))
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t)
	t_1 = Float64(x + Float64(Float64(y * Float64(z - x)) / t))
	tmp = 0.0
	if ((t_1 <= Float64(-Inf)) || !(t_1 <= 5e+263))
		tmp = Float64(x + Float64(Float64(z - x) * Float64(y / t)));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = x + ((y * (z - x)) / t);
	tmp = 0.0;
	if ((t_1 <= -Inf) || ~((t_1 <= 5e+263)))
		tmp = x + ((z - x) * (y / t));
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x + N[(N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, (-Infinity)], N[Not[LessEqual[t$95$1, 5e+263]], $MachinePrecision]], N[(x + N[(N[(z - x), $MachinePrecision] * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := x + \frac{y \cdot \left(z - x\right)}{t}\\
\mathbf{if}\;t_1 \leq -\infty \lor \neg \left(t_1 \leq 5 \cdot 10^{+263}\right):\\
\;\;\;\;x + \left(z - x\right) \cdot \frac{y}{t}\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (+.f64 x (/.f64 (*.f64 y (-.f64 z x)) t)) < -inf.0 or 5.00000000000000022e263 < (+.f64 x (/.f64 (*.f64 y (-.f64 z x)) t))

    1. Initial program 74.5%

      \[x + \frac{y \cdot \left(z - x\right)}{t} \]
    2. Step-by-step derivation
      1. associate-*l/99.9%

        \[\leadsto x + \color{blue}{\frac{y}{t} \cdot \left(z - x\right)} \]
    3. Simplified99.9%

      \[\leadsto \color{blue}{x + \frac{y}{t} \cdot \left(z - x\right)} \]

    if -inf.0 < (+.f64 x (/.f64 (*.f64 y (-.f64 z x)) t)) < 5.00000000000000022e263

    1. Initial program 99.4%

      \[x + \frac{y \cdot \left(z - x\right)}{t} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x + \frac{y \cdot \left(z - x\right)}{t} \leq -\infty \lor \neg \left(x + \frac{y \cdot \left(z - x\right)}{t} \leq 5 \cdot 10^{+263}\right):\\ \;\;\;\;x + \left(z - x\right) \cdot \frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y \cdot \left(z - x\right)}{t}\\ \end{array} \]

Alternative 2: 84.8% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -7.6 \cdot 10^{-116} \lor \neg \left(z \leq 1.04 \cdot 10^{-10}\right):\\ \;\;\;\;x + z \cdot \frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{\frac{-t}{x}}\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (or (<= z -7.6e-116) (not (<= z 1.04e-10)))
   (+ x (* z (/ y t)))
   (+ x (/ y (/ (- t) x)))))
double code(double x, double y, double z, double t) {
	double tmp;
	if ((z <= -7.6e-116) || !(z <= 1.04e-10)) {
		tmp = x + (z * (y / t));
	} else {
		tmp = x + (y / (-t / 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 ((z <= (-7.6d-116)) .or. (.not. (z <= 1.04d-10))) then
        tmp = x + (z * (y / t))
    else
        tmp = x + (y / (-t / x))
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double tmp;
	if ((z <= -7.6e-116) || !(z <= 1.04e-10)) {
		tmp = x + (z * (y / t));
	} else {
		tmp = x + (y / (-t / x));
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if (z <= -7.6e-116) or not (z <= 1.04e-10):
		tmp = x + (z * (y / t))
	else:
		tmp = x + (y / (-t / x))
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if ((z <= -7.6e-116) || !(z <= 1.04e-10))
		tmp = Float64(x + Float64(z * Float64(y / t)));
	else
		tmp = Float64(x + Float64(y / Float64(Float64(-t) / x)));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if ((z <= -7.6e-116) || ~((z <= 1.04e-10)))
		tmp = x + (z * (y / t));
	else
		tmp = x + (y / (-t / x));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -7.6e-116], N[Not[LessEqual[z, 1.04e-10]], $MachinePrecision]], N[(x + N[(z * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(y / N[((-t) / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -7.6 \cdot 10^{-116} \lor \neg \left(z \leq 1.04 \cdot 10^{-10}\right):\\
\;\;\;\;x + z \cdot \frac{y}{t}\\

\mathbf{else}:\\
\;\;\;\;x + \frac{y}{\frac{-t}{x}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -7.6000000000000003e-116 or 1.04e-10 < z

    1. Initial program 89.5%

      \[x + \frac{y \cdot \left(z - x\right)}{t} \]
    2. Step-by-step derivation
      1. associate-*l/97.3%

        \[\leadsto x + \color{blue}{\frac{y}{t} \cdot \left(z - x\right)} \]
    3. Simplified97.3%

      \[\leadsto \color{blue}{x + \frac{y}{t} \cdot \left(z - x\right)} \]
    4. Taylor expanded in z around inf 85.1%

      \[\leadsto x + \color{blue}{\frac{y \cdot z}{t}} \]
    5. Step-by-step derivation
      1. associate-*l/89.6%

        \[\leadsto x + \color{blue}{\frac{y}{t} \cdot z} \]
      2. *-commutative89.6%

        \[\leadsto x + \color{blue}{z \cdot \frac{y}{t}} \]
    6. Simplified89.6%

      \[\leadsto x + \color{blue}{z \cdot \frac{y}{t}} \]

    if -7.6000000000000003e-116 < z < 1.04e-10

    1. Initial program 94.8%

      \[x + \frac{y \cdot \left(z - x\right)}{t} \]
    2. Step-by-step derivation
      1. associate-/l*98.2%

        \[\leadsto x + \color{blue}{\frac{y}{\frac{t}{z - x}}} \]
    3. Simplified98.2%

      \[\leadsto \color{blue}{x + \frac{y}{\frac{t}{z - x}}} \]
    4. Taylor expanded in z around 0 88.7%

      \[\leadsto x + \frac{y}{\color{blue}{-1 \cdot \frac{t}{x}}} \]
    5. Step-by-step derivation
      1. associate-*r/88.7%

        \[\leadsto x + \frac{y}{\color{blue}{\frac{-1 \cdot t}{x}}} \]
      2. neg-mul-188.7%

        \[\leadsto x + \frac{y}{\frac{\color{blue}{-t}}{x}} \]
    6. Simplified88.7%

      \[\leadsto x + \frac{y}{\color{blue}{\frac{-t}{x}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification89.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -7.6 \cdot 10^{-116} \lor \neg \left(z \leq 1.04 \cdot 10^{-10}\right):\\ \;\;\;\;x + z \cdot \frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{\frac{-t}{x}}\\ \end{array} \]

Alternative 3: 85.9% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -1.25 \cdot 10^{-110} \lor \neg \left(z \leq 4.6 \cdot 10^{-9}\right):\\ \;\;\;\;x + z \cdot \frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;x - x \cdot \frac{y}{t}\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (or (<= z -1.25e-110) (not (<= z 4.6e-9)))
   (+ x (* z (/ y t)))
   (- x (* x (/ y t)))))
double code(double x, double y, double z, double t) {
	double tmp;
	if ((z <= -1.25e-110) || !(z <= 4.6e-9)) {
		tmp = x + (z * (y / t));
	} else {
		tmp = x - (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 ((z <= (-1.25d-110)) .or. (.not. (z <= 4.6d-9))) then
        tmp = x + (z * (y / t))
    else
        tmp = x - (x * (y / t))
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double tmp;
	if ((z <= -1.25e-110) || !(z <= 4.6e-9)) {
		tmp = x + (z * (y / t));
	} else {
		tmp = x - (x * (y / t));
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if (z <= -1.25e-110) or not (z <= 4.6e-9):
		tmp = x + (z * (y / t))
	else:
		tmp = x - (x * (y / t))
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if ((z <= -1.25e-110) || !(z <= 4.6e-9))
		tmp = Float64(x + Float64(z * Float64(y / t)));
	else
		tmp = Float64(x - Float64(x * Float64(y / t)));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if ((z <= -1.25e-110) || ~((z <= 4.6e-9)))
		tmp = x + (z * (y / t));
	else
		tmp = x - (x * (y / t));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -1.25e-110], N[Not[LessEqual[z, 4.6e-9]], $MachinePrecision]], N[(x + N[(z * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(x * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.25 \cdot 10^{-110} \lor \neg \left(z \leq 4.6 \cdot 10^{-9}\right):\\
\;\;\;\;x + z \cdot \frac{y}{t}\\

\mathbf{else}:\\
\;\;\;\;x - x \cdot \frac{y}{t}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.25e-110 or 4.5999999999999998e-9 < z

    1. Initial program 89.5%

      \[x + \frac{y \cdot \left(z - x\right)}{t} \]
    2. Step-by-step derivation
      1. associate-*l/97.3%

        \[\leadsto x + \color{blue}{\frac{y}{t} \cdot \left(z - x\right)} \]
    3. Simplified97.3%

      \[\leadsto \color{blue}{x + \frac{y}{t} \cdot \left(z - x\right)} \]
    4. Taylor expanded in z around inf 85.1%

      \[\leadsto x + \color{blue}{\frac{y \cdot z}{t}} \]
    5. Step-by-step derivation
      1. associate-*l/89.6%

        \[\leadsto x + \color{blue}{\frac{y}{t} \cdot z} \]
      2. *-commutative89.6%

        \[\leadsto x + \color{blue}{z \cdot \frac{y}{t}} \]
    6. Simplified89.6%

      \[\leadsto x + \color{blue}{z \cdot \frac{y}{t}} \]

    if -1.25e-110 < z < 4.5999999999999998e-9

    1. Initial program 94.8%

      \[x + \frac{y \cdot \left(z - x\right)}{t} \]
    2. Step-by-step derivation
      1. associate-*l/95.7%

        \[\leadsto x + \color{blue}{\frac{y}{t} \cdot \left(z - x\right)} \]
    3. Simplified95.7%

      \[\leadsto \color{blue}{x + \frac{y}{t} \cdot \left(z - x\right)} \]
    4. Taylor expanded in z around 0 84.5%

      \[\leadsto x + \color{blue}{-1 \cdot \frac{y \cdot x}{t}} \]
    5. Step-by-step derivation
      1. mul-1-neg84.5%

        \[\leadsto x + \color{blue}{\left(-\frac{y \cdot x}{t}\right)} \]
      2. associate-*l/87.9%

        \[\leadsto x + \left(-\color{blue}{\frac{y}{t} \cdot x}\right) \]
      3. distribute-rgt-neg-out87.9%

        \[\leadsto x + \color{blue}{\frac{y}{t} \cdot \left(-x\right)} \]
    6. Simplified87.9%

      \[\leadsto x + \color{blue}{\frac{y}{t} \cdot \left(-x\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification88.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.25 \cdot 10^{-110} \lor \neg \left(z \leq 4.6 \cdot 10^{-9}\right):\\ \;\;\;\;x + z \cdot \frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;x - x \cdot \frac{y}{t}\\ \end{array} \]

Alternative 4: 53.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -8.8 \cdot 10^{-113} \lor \neg \left(z \leq 10^{+34}\right):\\ \;\;\;\;z \cdot \frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (or (<= z -8.8e-113) (not (<= z 1e+34))) (* z (/ y t)) x))
double code(double x, double y, double z, double t) {
	double tmp;
	if ((z <= -8.8e-113) || !(z <= 1e+34)) {
		tmp = z * (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 ((z <= (-8.8d-113)) .or. (.not. (z <= 1d+34))) then
        tmp = z * (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 ((z <= -8.8e-113) || !(z <= 1e+34)) {
		tmp = z * (y / t);
	} else {
		tmp = x;
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if (z <= -8.8e-113) or not (z <= 1e+34):
		tmp = z * (y / t)
	else:
		tmp = x
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if ((z <= -8.8e-113) || !(z <= 1e+34))
		tmp = Float64(z * Float64(y / t));
	else
		tmp = x;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if ((z <= -8.8e-113) || ~((z <= 1e+34)))
		tmp = z * (y / t);
	else
		tmp = x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -8.8e-113], N[Not[LessEqual[z, 1e+34]], $MachinePrecision]], N[(z * N[(y / t), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -8.8 \cdot 10^{-113} \lor \neg \left(z \leq 10^{+34}\right):\\
\;\;\;\;z \cdot \frac{y}{t}\\

\mathbf{else}:\\
\;\;\;\;x\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -8.80000000000000016e-113 or 9.99999999999999946e33 < z

    1. Initial program 90.0%

      \[x + \frac{y \cdot \left(z - x\right)}{t} \]
    2. Step-by-step derivation
      1. associate-*l/97.0%

        \[\leadsto x + \color{blue}{\frac{y}{t} \cdot \left(z - x\right)} \]
    3. Simplified97.0%

      \[\leadsto \color{blue}{x + \frac{y}{t} \cdot \left(z - x\right)} \]
    4. Taylor expanded in z around inf 85.1%

      \[\leadsto x + \color{blue}{\frac{y \cdot z}{t}} \]
    5. Step-by-step derivation
      1. associate-*l/90.1%

        \[\leadsto x + \color{blue}{\frac{y}{t} \cdot z} \]
      2. *-commutative90.1%

        \[\leadsto x + \color{blue}{z \cdot \frac{y}{t}} \]
    6. Simplified90.1%

      \[\leadsto x + \color{blue}{z \cdot \frac{y}{t}} \]
    7. Step-by-step derivation
      1. associate-*r/85.1%

        \[\leadsto x + \color{blue}{\frac{z \cdot y}{t}} \]
      2. *-commutative85.1%

        \[\leadsto x + \frac{\color{blue}{y \cdot z}}{t} \]
      3. frac-2neg85.1%

        \[\leadsto x + \color{blue}{\frac{-y \cdot z}{-t}} \]
      4. div-inv84.9%

        \[\leadsto x + \color{blue}{\left(-y \cdot z\right) \cdot \frac{1}{-t}} \]
      5. add-sqr-sqrt51.6%

        \[\leadsto x + \left(-y \cdot z\right) \cdot \frac{1}{\color{blue}{\sqrt{-t} \cdot \sqrt{-t}}} \]
      6. sqrt-unprod53.2%

        \[\leadsto x + \left(-y \cdot z\right) \cdot \frac{1}{\color{blue}{\sqrt{\left(-t\right) \cdot \left(-t\right)}}} \]
      7. sqr-neg53.2%

        \[\leadsto x + \left(-y \cdot z\right) \cdot \frac{1}{\sqrt{\color{blue}{t \cdot t}}} \]
      8. sqrt-unprod8.8%

        \[\leadsto x + \left(-y \cdot z\right) \cdot \frac{1}{\color{blue}{\sqrt{t} \cdot \sqrt{t}}} \]
      9. add-sqr-sqrt27.4%

        \[\leadsto x + \left(-y \cdot z\right) \cdot \frac{1}{\color{blue}{t}} \]
      10. cancel-sign-sub-inv27.4%

        \[\leadsto \color{blue}{x - \left(y \cdot z\right) \cdot \frac{1}{t}} \]
      11. div-inv27.4%

        \[\leadsto x - \color{blue}{\frac{y \cdot z}{t}} \]
      12. *-commutative27.4%

        \[\leadsto x - \frac{\color{blue}{z \cdot y}}{t} \]
      13. associate-/l*27.4%

        \[\leadsto x - \color{blue}{\frac{z}{\frac{t}{y}}} \]
    8. Applied egg-rr27.4%

      \[\leadsto \color{blue}{x - \frac{z}{\frac{t}{y}}} \]
    9. Step-by-step derivation
      1. associate-/r/27.3%

        \[\leadsto x - \color{blue}{\frac{z}{t} \cdot y} \]
      2. *-commutative27.3%

        \[\leadsto x - \color{blue}{y \cdot \frac{z}{t}} \]
    10. Simplified27.3%

      \[\leadsto \color{blue}{x - y \cdot \frac{z}{t}} \]
    11. Taylor expanded in x around 0 2.4%

      \[\leadsto \color{blue}{-1 \cdot \frac{y \cdot z}{t}} \]
    12. Step-by-step derivation
      1. mul-1-neg2.4%

        \[\leadsto \color{blue}{-\frac{y \cdot z}{t}} \]
      2. associate-/l*2.4%

        \[\leadsto -\color{blue}{\frac{y}{\frac{t}{z}}} \]
      3. distribute-frac-neg2.4%

        \[\leadsto \color{blue}{\frac{-y}{\frac{t}{z}}} \]
    13. Simplified2.4%

      \[\leadsto \color{blue}{\frac{-y}{\frac{t}{z}}} \]
    14. Step-by-step derivation
      1. add-sqr-sqrt0.8%

        \[\leadsto \frac{\color{blue}{\sqrt{-y} \cdot \sqrt{-y}}}{\frac{t}{z}} \]
      2. sqrt-unprod27.0%

        \[\leadsto \frac{\color{blue}{\sqrt{\left(-y\right) \cdot \left(-y\right)}}}{\frac{t}{z}} \]
      3. sqr-neg27.0%

        \[\leadsto \frac{\sqrt{\color{blue}{y \cdot y}}}{\frac{t}{z}} \]
      4. sqrt-unprod30.9%

        \[\leadsto \frac{\color{blue}{\sqrt{y} \cdot \sqrt{y}}}{\frac{t}{z}} \]
      5. add-sqr-sqrt59.5%

        \[\leadsto \frac{\color{blue}{y}}{\frac{t}{z}} \]
      6. associate-/r/65.2%

        \[\leadsto \color{blue}{\frac{y}{t} \cdot z} \]
    15. Applied egg-rr65.2%

      \[\leadsto \color{blue}{\frac{y}{t} \cdot z} \]

    if -8.80000000000000016e-113 < z < 9.99999999999999946e33

    1. Initial program 93.7%

      \[x + \frac{y \cdot \left(z - x\right)}{t} \]
    2. Step-by-step derivation
      1. associate-*l/96.1%

        \[\leadsto x + \color{blue}{\frac{y}{t} \cdot \left(z - x\right)} \]
    3. Simplified96.1%

      \[\leadsto \color{blue}{x + \frac{y}{t} \cdot \left(z - x\right)} \]
    4. Taylor expanded in z around inf 67.9%

      \[\leadsto x + \color{blue}{\frac{y \cdot z}{t}} \]
    5. Step-by-step derivation
      1. associate-*l/67.6%

        \[\leadsto x + \color{blue}{\frac{y}{t} \cdot z} \]
      2. *-commutative67.6%

        \[\leadsto x + \color{blue}{z \cdot \frac{y}{t}} \]
    6. Simplified67.6%

      \[\leadsto x + \color{blue}{z \cdot \frac{y}{t}} \]
    7. Taylor expanded in x around inf 58.2%

      \[\leadsto \color{blue}{x} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification61.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -8.8 \cdot 10^{-113} \lor \neg \left(z \leq 10^{+34}\right):\\ \;\;\;\;z \cdot \frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]

Alternative 5: 97.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ x + \left(z - x\right) \cdot \frac{y}{t} \end{array} \]
(FPCore (x y z t) :precision binary64 (+ x (* (- z x) (/ y t))))
double code(double x, double y, double z, double t) {
	return x + ((z - x) * (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 + ((z - x) * (y / t))
end function
public static double code(double x, double y, double z, double t) {
	return x + ((z - x) * (y / t));
}
def code(x, y, z, t):
	return x + ((z - x) * (y / t))
function code(x, y, z, t)
	return Float64(x + Float64(Float64(z - x) * Float64(y / t)))
end
function tmp = code(x, y, z, t)
	tmp = x + ((z - x) * (y / t));
end
code[x_, y_, z_, t_] := N[(x + N[(N[(z - x), $MachinePrecision] * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x + \left(z - x\right) \cdot \frac{y}{t}
\end{array}
Derivation
  1. Initial program 91.8%

    \[x + \frac{y \cdot \left(z - x\right)}{t} \]
  2. Step-by-step derivation
    1. associate-*l/96.6%

      \[\leadsto x + \color{blue}{\frac{y}{t} \cdot \left(z - x\right)} \]
  3. Simplified96.6%

    \[\leadsto \color{blue}{x + \frac{y}{t} \cdot \left(z - x\right)} \]
  4. Final simplification96.6%

    \[\leadsto x + \left(z - x\right) \cdot \frac{y}{t} \]

Alternative 6: 73.0% accurate, 1.3× speedup?

\[\begin{array}{l} \\ x + y \cdot \frac{z}{t} \end{array} \]
(FPCore (x y z t) :precision binary64 (+ x (* y (/ z t))))
double code(double x, double y, double z, double t) {
	return x + (y * (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 = x + (y * (z / t))
end function
public static double code(double x, double y, double z, double t) {
	return x + (y * (z / t));
}
def code(x, y, z, t):
	return x + (y * (z / t))
function code(x, y, z, t)
	return Float64(x + Float64(y * Float64(z / t)))
end
function tmp = code(x, y, z, t)
	tmp = x + (y * (z / t));
end
code[x_, y_, z_, t_] := N[(x + N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x + y \cdot \frac{z}{t}
\end{array}
Derivation
  1. Initial program 91.8%

    \[x + \frac{y \cdot \left(z - x\right)}{t} \]
  2. Step-by-step derivation
    1. associate-*l/96.6%

      \[\leadsto x + \color{blue}{\frac{y}{t} \cdot \left(z - x\right)} \]
  3. Simplified96.6%

    \[\leadsto \color{blue}{x + \frac{y}{t} \cdot \left(z - x\right)} \]
  4. Step-by-step derivation
    1. associate-/r/94.2%

      \[\leadsto x + \color{blue}{\frac{y}{\frac{t}{z - x}}} \]
    2. div-inv94.1%

      \[\leadsto x + \frac{y}{\color{blue}{t \cdot \frac{1}{z - x}}} \]
    3. associate-/r*96.5%

      \[\leadsto x + \color{blue}{\frac{\frac{y}{t}}{\frac{1}{z - x}}} \]
  5. Applied egg-rr96.5%

    \[\leadsto x + \color{blue}{\frac{\frac{y}{t}}{\frac{1}{z - x}}} \]
  6. Taylor expanded in z around inf 76.7%

    \[\leadsto x + \color{blue}{\frac{y \cdot z}{t}} \]
  7. Step-by-step derivation
    1. associate-*r/76.0%

      \[\leadsto x + \color{blue}{y \cdot \frac{z}{t}} \]
  8. Simplified76.0%

    \[\leadsto x + \color{blue}{y \cdot \frac{z}{t}} \]
  9. Final simplification76.0%

    \[\leadsto x + y \cdot \frac{z}{t} \]

Alternative 7: 76.6% accurate, 1.3× speedup?

\[\begin{array}{l} \\ x + z \cdot \frac{y}{t} \end{array} \]
(FPCore (x y z t) :precision binary64 (+ x (* z (/ y t))))
double code(double x, double y, double z, double t) {
	return x + (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 + (z * (y / t))
end function
public static double code(double x, double y, double z, double t) {
	return x + (z * (y / t));
}
def code(x, y, z, t):
	return x + (z * (y / t))
function code(x, y, z, t)
	return Float64(x + Float64(z * Float64(y / t)))
end
function tmp = code(x, y, z, t)
	tmp = x + (z * (y / t));
end
code[x_, y_, z_, t_] := N[(x + N[(z * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x + z \cdot \frac{y}{t}
\end{array}
Derivation
  1. Initial program 91.8%

    \[x + \frac{y \cdot \left(z - x\right)}{t} \]
  2. Step-by-step derivation
    1. associate-*l/96.6%

      \[\leadsto x + \color{blue}{\frac{y}{t} \cdot \left(z - x\right)} \]
  3. Simplified96.6%

    \[\leadsto \color{blue}{x + \frac{y}{t} \cdot \left(z - x\right)} \]
  4. Taylor expanded in z around inf 76.7%

    \[\leadsto x + \color{blue}{\frac{y \cdot z}{t}} \]
  5. Step-by-step derivation
    1. associate-*l/79.2%

      \[\leadsto x + \color{blue}{\frac{y}{t} \cdot z} \]
    2. *-commutative79.2%

      \[\leadsto x + \color{blue}{z \cdot \frac{y}{t}} \]
  6. Simplified79.2%

    \[\leadsto x + \color{blue}{z \cdot \frac{y}{t}} \]
  7. Final simplification79.2%

    \[\leadsto x + z \cdot \frac{y}{t} \]

Alternative 8: 37.9% accurate, 9.0× speedup?

\[\begin{array}{l} \\ x \end{array} \]
(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}
Derivation
  1. Initial program 91.8%

    \[x + \frac{y \cdot \left(z - x\right)}{t} \]
  2. Step-by-step derivation
    1. associate-*l/96.6%

      \[\leadsto x + \color{blue}{\frac{y}{t} \cdot \left(z - x\right)} \]
  3. Simplified96.6%

    \[\leadsto \color{blue}{x + \frac{y}{t} \cdot \left(z - x\right)} \]
  4. Taylor expanded in z around inf 76.7%

    \[\leadsto x + \color{blue}{\frac{y \cdot z}{t}} \]
  5. Step-by-step derivation
    1. associate-*l/79.2%

      \[\leadsto x + \color{blue}{\frac{y}{t} \cdot z} \]
    2. *-commutative79.2%

      \[\leadsto x + \color{blue}{z \cdot \frac{y}{t}} \]
  6. Simplified79.2%

    \[\leadsto x + \color{blue}{z \cdot \frac{y}{t}} \]
  7. Taylor expanded in x around inf 42.6%

    \[\leadsto \color{blue}{x} \]
  8. Final simplification42.6%

    \[\leadsto x \]

Developer target: 91.1% accurate, 0.6× speedup?

\[\begin{array}{l} \\ x - \left(x \cdot \frac{y}{t} + \left(-z\right) \cdot \frac{y}{t}\right) \end{array} \]
(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}

Reproduce

?
herbie shell --seed 2023185 
(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)))