?

Average Error: 6.5 → 3.1
Time: 15.6s
Precision: binary64
Cost: 840

?

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

\mathbf{elif}\;y \leq -1.2 \cdot 10^{-201}:\\
\;\;\;\;x + \frac{y \cdot \left(z - x\right)}{t}\\

\mathbf{else}:\\
\;\;\;\;x + \left(z - x\right) \cdot \frac{y}{t}\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.5
Target2.0
Herbie3.1
\[x - \left(x \cdot \frac{y}{t} + \left(-z\right) \cdot \frac{y}{t}\right) \]

Derivation?

  1. Split input into 3 regimes
  2. if y < -1.30000000000000001e195

    1. Initial program 25.6

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

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

      [Start]25.6

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

      rational.json-simplify-2 [=>]25.6

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

      rational.json-simplify-49 [=>]4.1

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

    if -1.30000000000000001e195 < y < -1.20000000000000004e-201

    1. Initial program 5.0

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

    if -1.20000000000000004e-201 < y

    1. Initial program 5.6

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

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

      [Start]5.6

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

      rational.json-simplify-49 [=>]1.9

      \[ x + \color{blue}{\left(z - x\right) \cdot \frac{y}{t}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification3.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.3 \cdot 10^{+195}:\\ \;\;\;\;x + y \cdot \frac{z - x}{t}\\ \mathbf{elif}\;y \leq -1.2 \cdot 10^{-201}:\\ \;\;\;\;x + \frac{y \cdot \left(z - x\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x + \left(z - x\right) \cdot \frac{y}{t}\\ \end{array} \]

Alternatives

Alternative 1
Error20.4
Cost1240
\[\begin{array}{l} t_1 := z \cdot \frac{y}{t}\\ t_2 := x \cdot \left(1 - \frac{y}{t}\right)\\ \mathbf{if}\;z \leq -1.7 \cdot 10^{+219}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -5 \cdot 10^{+149}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -2.5 \cdot 10^{+99}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2.6 \cdot 10^{-21}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 3.8 \cdot 10^{+28}:\\ \;\;\;\;\frac{y \cdot z}{t}\\ \mathbf{elif}\;z \leq 4.2 \cdot 10^{+167}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error30.0
Cost1112
\[\begin{array}{l} t_1 := z \cdot \frac{y}{t}\\ \mathbf{if}\;z \leq -1.02 \cdot 10^{+219}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -4.5 \cdot 10^{+149}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -2.1 \cdot 10^{+99}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2.8 \cdot 10^{-28}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 4.5 \cdot 10^{+29}:\\ \;\;\;\;y \cdot \frac{z}{t}\\ \mathbf{elif}\;z \leq 4.1 \cdot 10^{+167}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error30.0
Cost1112
\[\begin{array}{l} t_1 := z \cdot \frac{y}{t}\\ \mathbf{if}\;z \leq -1.02 \cdot 10^{+219}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -5 \cdot 10^{+149}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -2.5 \cdot 10^{+99}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.1 \cdot 10^{-28}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 4.4 \cdot 10^{+28}:\\ \;\;\;\;\frac{y \cdot z}{t}\\ \mathbf{elif}\;z \leq 2 \cdot 10^{+168}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error10.2
Cost1108
\[\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 \cdot 10^{+57}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 3 \cdot 10^{-117}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 5.2 \cdot 10^{-61}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 6.8 \cdot 10^{-13}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 55000:\\ \;\;\;\;y \cdot \frac{z - x}{t}\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 5
Error10.2
Cost1108
\[\begin{array}{l} t_1 := x + z \cdot \frac{y}{t}\\ t_2 := x - \frac{x}{\frac{t}{y}}\\ \mathbf{if}\;x \leq -8.5 \cdot 10^{+58}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 3.5 \cdot 10^{-117}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 5.5 \cdot 10^{-61}:\\ \;\;\;\;x \cdot \left(1 - \frac{y}{t}\right)\\ \mathbf{elif}\;x \leq 6.8 \cdot 10^{-13}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 24000000:\\ \;\;\;\;y \cdot \frac{z - x}{t}\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 6
Error18.8
Cost976
\[\begin{array}{l} t_1 := x \cdot \left(1 - \frac{y}{t}\right)\\ t_2 := y \cdot \frac{z - x}{t}\\ \mathbf{if}\;y \leq -3.65 \cdot 10^{+205}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq -8.8 \cdot 10^{+100}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -1.42 \cdot 10^{+20}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 7 \cdot 10^{+33}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 7
Error29.1
Cost848
\[\begin{array}{l} t_1 := y \cdot \frac{z}{t}\\ \mathbf{if}\;y \leq -6.4 \cdot 10^{+204}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -1.85 \cdot 10^{+100}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -1.4 \cdot 10^{+20}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 6.8 \cdot 10^{+33}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error4.7
Cost840
\[\begin{array}{l} t_1 := x + z \cdot \frac{y}{t}\\ \mathbf{if}\;z \leq -8.5 \cdot 10^{+127}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 7.2 \cdot 10^{+86}:\\ \;\;\;\;x + y \cdot \frac{z - x}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error2.0
Cost576
\[x + \left(z - x\right) \cdot \frac{y}{t} \]
Alternative 10
Error1.9
Cost576
\[x + \frac{z - x}{\frac{t}{y}} \]
Alternative 11
Error32.1
Cost64
\[x \]

Error

Reproduce?

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