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

Percentage Accurate: 92.8% → 97.6%
Time: 9.0s
Alternatives: 9
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 9 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: 97.6% 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 94.6%

    \[x + \frac{y \cdot \left(z - x\right)}{t} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. *-commutative94.6%

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

      \[\leadsto x + \color{blue}{\left(z - x\right) \cdot \frac{y}{t}} \]
  4. Applied egg-rr98.4%

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

Alternative 2: 53.4% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x \cdot \frac{y}{-t}\\ t_2 := y \cdot \frac{z}{t}\\ \mathbf{if}\;y \leq -1.8 \cdot 10^{+17}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;y \leq 4 \cdot 10^{-6}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 4.3 \cdot 10^{+83}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;y \leq 5 \cdot 10^{+127}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;y \leq 1.92 \cdot 10^{+155}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;y \leq 5.2 \cdot 10^{+179}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* x (/ y (- t)))) (t_2 (* y (/ z t))))
   (if (<= y -1.8e+17)
     t_2
     (if (<= y 4e-6)
       x
       (if (<= y 4.3e+83)
         t_2
         (if (<= y 5e+127)
           t_1
           (if (<= y 1.92e+155) t_2 (if (<= y 5.2e+179) x t_1))))))))
double code(double x, double y, double z, double t) {
	double t_1 = x * (y / -t);
	double t_2 = y * (z / t);
	double tmp;
	if (y <= -1.8e+17) {
		tmp = t_2;
	} else if (y <= 4e-6) {
		tmp = x;
	} else if (y <= 4.3e+83) {
		tmp = t_2;
	} else if (y <= 5e+127) {
		tmp = t_1;
	} else if (y <= 1.92e+155) {
		tmp = t_2;
	} else if (y <= 5.2e+179) {
		tmp = x;
	} else {
		tmp = t_1;
	}
	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) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_1 = x * (y / -t)
    t_2 = y * (z / t)
    if (y <= (-1.8d+17)) then
        tmp = t_2
    else if (y <= 4d-6) then
        tmp = x
    else if (y <= 4.3d+83) then
        tmp = t_2
    else if (y <= 5d+127) then
        tmp = t_1
    else if (y <= 1.92d+155) then
        tmp = t_2
    else if (y <= 5.2d+179) then
        tmp = x
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double t_1 = x * (y / -t);
	double t_2 = y * (z / t);
	double tmp;
	if (y <= -1.8e+17) {
		tmp = t_2;
	} else if (y <= 4e-6) {
		tmp = x;
	} else if (y <= 4.3e+83) {
		tmp = t_2;
	} else if (y <= 5e+127) {
		tmp = t_1;
	} else if (y <= 1.92e+155) {
		tmp = t_2;
	} else if (y <= 5.2e+179) {
		tmp = x;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = x * (y / -t)
	t_2 = y * (z / t)
	tmp = 0
	if y <= -1.8e+17:
		tmp = t_2
	elif y <= 4e-6:
		tmp = x
	elif y <= 4.3e+83:
		tmp = t_2
	elif y <= 5e+127:
		tmp = t_1
	elif y <= 1.92e+155:
		tmp = t_2
	elif y <= 5.2e+179:
		tmp = x
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t)
	t_1 = Float64(x * Float64(y / Float64(-t)))
	t_2 = Float64(y * Float64(z / t))
	tmp = 0.0
	if (y <= -1.8e+17)
		tmp = t_2;
	elseif (y <= 4e-6)
		tmp = x;
	elseif (y <= 4.3e+83)
		tmp = t_2;
	elseif (y <= 5e+127)
		tmp = t_1;
	elseif (y <= 1.92e+155)
		tmp = t_2;
	elseif (y <= 5.2e+179)
		tmp = x;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = x * (y / -t);
	t_2 = y * (z / t);
	tmp = 0.0;
	if (y <= -1.8e+17)
		tmp = t_2;
	elseif (y <= 4e-6)
		tmp = x;
	elseif (y <= 4.3e+83)
		tmp = t_2;
	elseif (y <= 5e+127)
		tmp = t_1;
	elseif (y <= 1.92e+155)
		tmp = t_2;
	elseif (y <= 5.2e+179)
		tmp = x;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x * N[(y / (-t)), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.8e+17], t$95$2, If[LessEqual[y, 4e-6], x, If[LessEqual[y, 4.3e+83], t$95$2, If[LessEqual[y, 5e+127], t$95$1, If[LessEqual[y, 1.92e+155], t$95$2, If[LessEqual[y, 5.2e+179], x, t$95$1]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := x \cdot \frac{y}{-t}\\
t_2 := y \cdot \frac{z}{t}\\
\mathbf{if}\;y \leq -1.8 \cdot 10^{+17}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;y \leq 4 \cdot 10^{-6}:\\
\;\;\;\;x\\

\mathbf{elif}\;y \leq 4.3 \cdot 10^{+83}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;y \leq 5 \cdot 10^{+127}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;y \leq 1.92 \cdot 10^{+155}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;y \leq 5.2 \cdot 10^{+179}:\\
\;\;\;\;x\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.8e17 or 3.99999999999999982e-6 < y < 4.3e83 or 5.0000000000000004e127 < y < 1.92000000000000012e155

    1. Initial program 91.7%

      \[x + \frac{y \cdot \left(z - x\right)}{t} \]
    2. Add Preprocessing
    3. Taylor expanded in y around -inf 86.1%

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

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

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

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

    if -1.8e17 < y < 3.99999999999999982e-6 or 1.92000000000000012e155 < y < 5.2000000000000004e179

    1. Initial program 99.0%

      \[x + \frac{y \cdot \left(z - x\right)}{t} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 68.4%

      \[\leadsto \color{blue}{x} \]

    if 4.3e83 < y < 5.0000000000000004e127 or 5.2000000000000004e179 < y

    1. Initial program 84.9%

      \[x + \frac{y \cdot \left(z - x\right)}{t} \]
    2. Add Preprocessing
    3. Taylor expanded in y around -inf 79.0%

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

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

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

        \[\leadsto -\color{blue}{x \cdot \frac{y}{t}} \]
      3. distribute-rgt-neg-in74.9%

        \[\leadsto \color{blue}{x \cdot \left(-\frac{y}{t}\right)} \]
      4. mul-1-neg74.9%

        \[\leadsto x \cdot \color{blue}{\left(-1 \cdot \frac{y}{t}\right)} \]
      5. associate-*r/74.9%

        \[\leadsto x \cdot \color{blue}{\frac{-1 \cdot y}{t}} \]
      6. mul-1-neg74.9%

        \[\leadsto x \cdot \frac{\color{blue}{-y}}{t} \]
    6. Simplified74.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.8 \cdot 10^{+17}:\\ \;\;\;\;y \cdot \frac{z}{t}\\ \mathbf{elif}\;y \leq 4 \cdot 10^{-6}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 4.3 \cdot 10^{+83}:\\ \;\;\;\;y \cdot \frac{z}{t}\\ \mathbf{elif}\;y \leq 5 \cdot 10^{+127}:\\ \;\;\;\;x \cdot \frac{y}{-t}\\ \mathbf{elif}\;y \leq 1.92 \cdot 10^{+155}:\\ \;\;\;\;y \cdot \frac{z}{t}\\ \mathbf{elif}\;y \leq 5.2 \cdot 10^{+179}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y}{-t}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 84.8% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.6 \cdot 10^{+38} \lor \neg \left(x \leq 2.05 \cdot 10^{+130}\right):\\
\;\;\;\;x \cdot \left(1 - \frac{y}{t}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.59999999999999993e38 or 2.04999999999999989e130 < x

    1. Initial program 89.3%

      \[x + \frac{y \cdot \left(z - x\right)}{t} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 95.8%

      \[\leadsto \color{blue}{x \cdot \left(1 + -1 \cdot \frac{y}{t}\right)} \]
    4. Step-by-step derivation
      1. mul-1-neg95.8%

        \[\leadsto x \cdot \left(1 + \color{blue}{\left(-\frac{y}{t}\right)}\right) \]
      2. unsub-neg95.8%

        \[\leadsto x \cdot \color{blue}{\left(1 - \frac{y}{t}\right)} \]
    5. Simplified95.8%

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

    if -1.59999999999999993e38 < x < 2.04999999999999989e130

    1. Initial program 97.8%

      \[x + \frac{y \cdot \left(z - x\right)}{t} \]
    2. Add Preprocessing
    3. Taylor expanded in z around inf 85.8%

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

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

      \[\leadsto x + \color{blue}{y \cdot \frac{z}{t}} \]
    6. Step-by-step derivation
      1. clear-num83.1%

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

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

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

        \[\leadsto x + \color{blue}{\frac{y}{t} \cdot z} \]
    9. Applied egg-rr87.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.6 \cdot 10^{+38} \lor \neg \left(x \leq 2.05 \cdot 10^{+130}\right):\\ \;\;\;\;x \cdot \left(1 - \frac{y}{t}\right)\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \frac{y}{t}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 83.8% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.2 \cdot 10^{+37} \lor \neg \left(x \leq 5.5 \cdot 10^{-61}\right):\\
\;\;\;\;x \cdot \left(1 - \frac{y}{t}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -5.1999999999999998e37 or 5.4999999999999997e-61 < x

    1. Initial program 92.6%

      \[x + \frac{y \cdot \left(z - x\right)}{t} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 90.3%

      \[\leadsto \color{blue}{x \cdot \left(1 + -1 \cdot \frac{y}{t}\right)} \]
    4. Step-by-step derivation
      1. mul-1-neg90.3%

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

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

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

    if -5.1999999999999998e37 < x < 5.4999999999999997e-61

    1. Initial program 97.1%

      \[x + \frac{y \cdot \left(z - x\right)}{t} \]
    2. Add Preprocessing
    3. Taylor expanded in z around inf 87.2%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -5.2 \cdot 10^{+37} \lor \neg \left(x \leq 5.5 \cdot 10^{-61}\right):\\ \;\;\;\;x \cdot \left(1 - \frac{y}{t}\right)\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{z}{t}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 74.0% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.1 \cdot 10^{-72} \lor \neg \left(x \leq 4.6 \cdot 10^{-119}\right):\\
\;\;\;\;x \cdot \left(1 - \frac{y}{t}\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{z \cdot y}{t}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.10000000000000001e-72 or 4.59999999999999987e-119 < x

    1. Initial program 93.0%

      \[x + \frac{y \cdot \left(z - x\right)}{t} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 84.6%

      \[\leadsto \color{blue}{x \cdot \left(1 + -1 \cdot \frac{y}{t}\right)} \]
    4. Step-by-step derivation
      1. mul-1-neg84.6%

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

        \[\leadsto x \cdot \color{blue}{\left(1 - \frac{y}{t}\right)} \]
    5. Simplified84.6%

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

    if -1.10000000000000001e-72 < x < 4.59999999999999987e-119

    1. Initial program 98.2%

      \[x + \frac{y \cdot \left(z - x\right)}{t} \]
    2. Add Preprocessing
    3. Taylor expanded in t around 0 96.5%

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

      \[\leadsto \frac{\color{blue}{y \cdot z}}{t} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification80.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.1 \cdot 10^{-72} \lor \neg \left(x \leq 4.6 \cdot 10^{-119}\right):\\ \;\;\;\;x \cdot \left(1 - \frac{y}{t}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{z \cdot y}{t}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 54.7% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.4 \cdot 10^{+17} \lor \neg \left(y \leq 2.2 \cdot 10^{-5}\right):\\
\;\;\;\;y \cdot \frac{z}{t}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.4e17 or 2.1999999999999999e-5 < y

    1. Initial program 89.7%

      \[x + \frac{y \cdot \left(z - x\right)}{t} \]
    2. Add Preprocessing
    3. Taylor expanded in y around -inf 81.4%

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

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

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

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

    if -1.4e17 < y < 2.1999999999999999e-5

    1. Initial program 99.6%

      \[x + \frac{y \cdot \left(z - x\right)}{t} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 68.4%

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

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

Alternative 7: 52.4% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;t \leq -1 \cdot 10^{+124}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq 4 \cdot 10^{-16}:\\ \;\;\;\;\frac{z \cdot y}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (<= t -1e+124) x (if (<= t 4e-16) (/ (* z y) t) x)))
double code(double x, double y, double z, double t) {
	double tmp;
	if (t <= -1e+124) {
		tmp = x;
	} else if (t <= 4e-16) {
		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 (t <= (-1d+124)) then
        tmp = x
    else if (t <= 4d-16) 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 (t <= -1e+124) {
		tmp = x;
	} else if (t <= 4e-16) {
		tmp = (z * y) / t;
	} else {
		tmp = x;
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if t <= -1e+124:
		tmp = x
	elif t <= 4e-16:
		tmp = (z * y) / t
	else:
		tmp = x
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if (t <= -1e+124)
		tmp = x;
	elseif (t <= 4e-16)
		tmp = Float64(Float64(z * y) / t);
	else
		tmp = x;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (t <= -1e+124)
		tmp = x;
	elseif (t <= 4e-16)
		tmp = (z * y) / t;
	else
		tmp = x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[LessEqual[t, -1e+124], x, If[LessEqual[t, 4e-16], N[(N[(z * y), $MachinePrecision] / t), $MachinePrecision], x]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;t \leq -1 \cdot 10^{+124}:\\
\;\;\;\;x\\

\mathbf{elif}\;t \leq 4 \cdot 10^{-16}:\\
\;\;\;\;\frac{z \cdot y}{t}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -9.99999999999999948e123 or 3.9999999999999999e-16 < t

    1. Initial program 88.8%

      \[x + \frac{y \cdot \left(z - x\right)}{t} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 72.6%

      \[\leadsto \color{blue}{x} \]

    if -9.99999999999999948e123 < t < 3.9999999999999999e-16

    1. Initial program 98.5%

      \[x + \frac{y \cdot \left(z - x\right)}{t} \]
    2. Add Preprocessing
    3. Taylor expanded in t around 0 96.6%

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

      \[\leadsto \frac{\color{blue}{y \cdot z}}{t} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification60.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -1 \cdot 10^{+124}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq 4 \cdot 10^{-16}:\\ \;\;\;\;\frac{z \cdot y}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 38.7% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 2.6 \cdot 10^{-120}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t \cdot \frac{x}{t}\\ \end{array} \end{array} \]
(FPCore (x y z t) :precision binary64 (if (<= x 2.6e-120) x (* t (/ x t))))
double code(double x, double y, double z, double t) {
	double tmp;
	if (x <= 2.6e-120) {
		tmp = x;
	} else {
		tmp = t * (x / 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 (x <= 2.6d-120) then
        tmp = x
    else
        tmp = t * (x / t)
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (x <= 2.6e-120) {
		tmp = x;
	} else {
		tmp = t * (x / t);
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if x <= 2.6e-120:
		tmp = x
	else:
		tmp = t * (x / t)
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if (x <= 2.6e-120)
		tmp = x;
	else
		tmp = Float64(t * Float64(x / t));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (x <= 2.6e-120)
		tmp = x;
	else
		tmp = t * (x / t);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[LessEqual[x, 2.6e-120], x, N[(t * N[(x / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.6 \cdot 10^{-120}:\\
\;\;\;\;x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 2.6000000000000001e-120

    1. Initial program 97.2%

      \[x + \frac{y \cdot \left(z - x\right)}{t} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 39.0%

      \[\leadsto \color{blue}{x} \]

    if 2.6000000000000001e-120 < x

    1. Initial program 90.9%

      \[x + \frac{y \cdot \left(z - x\right)}{t} \]
    2. Add Preprocessing
    3. Taylor expanded in t around 0 75.5%

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

      \[\leadsto \frac{\color{blue}{t \cdot x}}{t} \]
    5. Step-by-step derivation
      1. *-commutative25.1%

        \[\leadsto \frac{\color{blue}{x \cdot t}}{t} \]
    6. Simplified25.1%

      \[\leadsto \frac{\color{blue}{x \cdot t}}{t} \]
    7. Step-by-step derivation
      1. *-commutative25.1%

        \[\leadsto \frac{\color{blue}{t \cdot x}}{t} \]
      2. associate-/l*49.4%

        \[\leadsto \color{blue}{t \cdot \frac{x}{t}} \]
    8. Applied egg-rr49.4%

      \[\leadsto \color{blue}{t \cdot \frac{x}{t}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 9: 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 94.6%

    \[x + \frac{y \cdot \left(z - x\right)}{t} \]
  2. Add Preprocessing
  3. Taylor expanded in y around 0 40.7%

    \[\leadsto \color{blue}{x} \]
  4. Add Preprocessing

Developer target: 90.2% 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 2024087 
(FPCore (x y z t)
  :name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, D"
  :precision binary64

  :alt
  (- x (+ (* x (/ y t)) (* (- z) (/ y t))))

  (+ x (/ (* y (- z x)) t)))