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

?

Percentage Accurate: 92.7% → 97.5%
Time: 14.3s
Precision: binary64
Cost: 576

?

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

Local Percentage Accuracy?

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.

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original92.7%
Target90.0%
Herbie97.5%
\[x - \left(x \cdot \frac{y}{t} + \left(-z\right) \cdot \frac{y}{t}\right) \]

Derivation?

  1. Initial program 94.7%

    \[x + \frac{y \cdot \left(z - x\right)}{t} \]
  2. Simplified97.7%

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

    [Start]94.7

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

    associate-*l/ [<=]97.7

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

    \[\leadsto x + \color{blue}{\frac{z - x}{\frac{t}{y}}} \]
    Step-by-step derivation

    [Start]97.7

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

    *-commutative [=>]97.7

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

    clear-num [=>]97.2

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

    un-div-inv [=>]98.0

    \[ x + \color{blue}{\frac{z - x}{\frac{t}{y}}} \]
  4. Final simplification98.0%

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

Alternatives

Alternative 1
Accuracy51.3%
Cost1176
\[\begin{array}{l} t_1 := y \cdot \frac{-x}{t}\\ \mathbf{if}\;x \leq -3.6 \cdot 10^{+15}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -3.1 \cdot 10^{-54}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 860000000:\\ \;\;\;\;\frac{z}{\frac{t}{y}}\\ \mathbf{elif}\;x \leq 1.9 \cdot 10^{+56}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 3.5 \cdot 10^{+83}:\\ \;\;\;\;z \cdot \frac{y}{t}\\ \mathbf{elif}\;x \leq 3.9 \cdot 10^{+219}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Accuracy49.4%
Cost1176
\[\begin{array}{l} t_1 := x \cdot \left(-\frac{y}{t}\right)\\ \mathbf{if}\;x \leq -6.2 \cdot 10^{+177}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -1.95 \cdot 10^{-54}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 650000000:\\ \;\;\;\;\frac{z}{\frac{t}{y}}\\ \mathbf{elif}\;x \leq 1.55 \cdot 10^{+56}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 2.15 \cdot 10^{+84}:\\ \;\;\;\;z \cdot \frac{y}{t}\\ \mathbf{elif}\;x \leq 5 \cdot 10^{+124}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Accuracy49.5%
Cost1176
\[\begin{array}{l} \mathbf{if}\;x \leq -2.3 \cdot 10^{+179}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -3 \cdot 10^{-54}:\\ \;\;\;\;\frac{-x}{\frac{t}{y}}\\ \mathbf{elif}\;x \leq 640000000:\\ \;\;\;\;\frac{z}{\frac{t}{y}}\\ \mathbf{elif}\;x \leq 1.7 \cdot 10^{+56}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.75 \cdot 10^{+83}:\\ \;\;\;\;z \cdot \frac{y}{t}\\ \mathbf{elif}\;x \leq 2.3 \cdot 10^{+124}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(-\frac{y}{t}\right)\\ \end{array} \]
Alternative 4
Accuracy49.2%
Cost1176
\[\begin{array}{l} \mathbf{if}\;x \leq -7.2 \cdot 10^{+177}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -2 \cdot 10^{-54}:\\ \;\;\;\;\frac{x \cdot y}{-t}\\ \mathbf{elif}\;x \leq 780000000:\\ \;\;\;\;\frac{z}{\frac{t}{y}}\\ \mathbf{elif}\;x \leq 1.9 \cdot 10^{+56}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 3.5 \cdot 10^{+83}:\\ \;\;\;\;z \cdot \frac{y}{t}\\ \mathbf{elif}\;x \leq 1.65 \cdot 10^{+126}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(-\frac{y}{t}\right)\\ \end{array} \]
Alternative 5
Accuracy72.9%
Cost978
\[\begin{array}{l} \mathbf{if}\;x \leq -2.85 \cdot 10^{-98} \lor \neg \left(x \leq 2.75 \cdot 10^{-108}\right) \land \left(x \leq 1.92 \cdot 10^{+56} \lor \neg \left(x \leq 7 \cdot 10^{+93}\right)\right):\\ \;\;\;\;x \cdot \left(1 - \frac{y}{t}\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \frac{y}{t}\\ \end{array} \]
Alternative 6
Accuracy76.1%
Cost978
\[\begin{array}{l} \mathbf{if}\;x \leq -3.8 \cdot 10^{-11} \lor \neg \left(x \leq 31000000 \lor \neg \left(x \leq 1.92 \cdot 10^{+56}\right) \land x \leq 7.3 \cdot 10^{+93}\right):\\ \;\;\;\;x \cdot \left(1 - \frac{y}{t}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(z - x\right) \cdot \frac{y}{t}\\ \end{array} \]
Alternative 7
Accuracy75.4%
Cost977
\[\begin{array}{l} t_1 := x \cdot \left(1 - \frac{y}{t}\right)\\ \mathbf{if}\;x \leq -2.35 \cdot 10^{-11}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 3.6 \cdot 10^{-18}:\\ \;\;\;\;y \cdot \frac{z - x}{t}\\ \mathbf{elif}\;x \leq 1.92 \cdot 10^{+56} \lor \neg \left(x \leq 7 \cdot 10^{+93}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;z \cdot \frac{y}{t}\\ \end{array} \]
Alternative 8
Accuracy81.8%
Cost976
\[\begin{array}{l} t_1 := x + y \cdot \frac{z}{t}\\ t_2 := x \cdot \left(1 - \frac{y}{t}\right)\\ \mathbf{if}\;x \leq -1.22 \cdot 10^{-54}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 3.6 \cdot 10^{-97}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 640000000:\\ \;\;\;\;\left(z - x\right) \cdot \frac{y}{t}\\ \mathbf{elif}\;x \leq 6.5 \cdot 10^{+147}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 9
Accuracy83.0%
Cost976
\[\begin{array}{l} t_1 := x + z \cdot \frac{y}{t}\\ t_2 := x \cdot \left(1 - \frac{y}{t}\right)\\ \mathbf{if}\;x \leq -3.1 \cdot 10^{-54}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 2.7 \cdot 10^{-97}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 680000000:\\ \;\;\;\;\left(z - x\right) \cdot \frac{y}{t}\\ \mathbf{elif}\;x \leq 6.2 \cdot 10^{+147}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 10
Accuracy83.0%
Cost976
\[\begin{array}{l} t_1 := x + z \cdot \frac{y}{t}\\ t_2 := x - \frac{x}{\frac{t}{y}}\\ \mathbf{if}\;x \leq -1.2 \cdot 10^{-54}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 3.3 \cdot 10^{-97}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 580000000:\\ \;\;\;\;\left(z - x\right) \cdot \frac{y}{t}\\ \mathbf{elif}\;x \leq 6.5 \cdot 10^{+147}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 11
Accuracy50.3%
Cost849
\[\begin{array}{l} \mathbf{if}\;t \leq -7 \cdot 10^{+166}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq -5 \cdot 10^{+72} \lor \neg \left(t \leq -3.6 \cdot 10^{-25}\right) \land t \leq 4.8 \cdot 10^{+124}:\\ \;\;\;\;y \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 12
Accuracy53.8%
Cost848
\[\begin{array}{l} \mathbf{if}\;t \leq -1.18 \cdot 10^{+170}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq -2.4 \cdot 10^{+68}:\\ \;\;\;\;y \cdot \frac{z}{t}\\ \mathbf{elif}\;t \leq -2.05 \cdot 10^{-19}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq 5.5 \cdot 10^{+119}:\\ \;\;\;\;z \cdot \frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 13
Accuracy53.6%
Cost848
\[\begin{array}{l} \mathbf{if}\;t \leq -2.35 \cdot 10^{+166}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq -1.6 \cdot 10^{+72}:\\ \;\;\;\;y \cdot \frac{z}{t}\\ \mathbf{elif}\;t \leq -3.15 \cdot 10^{-16}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq 4.1 \cdot 10^{+124}:\\ \;\;\;\;\frac{z}{\frac{t}{y}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 14
Accuracy97.5%
Cost576
\[x + \left(z - x\right) \cdot \frac{y}{t} \]
Alternative 15
Accuracy38.4%
Cost64
\[x \]

Error

Reproduce?

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