Average Error: 6.1 → 10.2
Time: 5.5s
Precision: binary64
Cost: 712
\[x + \frac{y \cdot \left(z - x\right)}{t} \]
\[\begin{array}{l} t_1 := x - x \cdot \frac{y}{t}\\ \mathbf{if}\;x \leq -4.0386396882280984 \cdot 10^{+22}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 5.886882456897662 \cdot 10^{-45}:\\ \;\;\;\;x + y \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
(FPCore (x y z t) :precision binary64 (+ x (/ (* y (- z x)) t)))
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (- x (* x (/ y t)))))
   (if (<= x -4.0386396882280984e+22)
     t_1
     (if (<= x 5.886882456897662e-45) (+ x (* y (/ z t))) t_1))))
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 t_1 = x - (x * (y / t));
	double tmp;
	if (x <= -4.0386396882280984e+22) {
		tmp = t_1;
	} else if (x <= 5.886882456897662e-45) {
		tmp = x + (y * (z / t));
	} 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
    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) :: t_1
    real(8) :: tmp
    t_1 = x - (x * (y / t))
    if (x <= (-4.0386396882280984d+22)) then
        tmp = t_1
    else if (x <= 5.886882456897662d-45) then
        tmp = x + (y * (z / t))
    else
        tmp = t_1
    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 t_1 = x - (x * (y / t));
	double tmp;
	if (x <= -4.0386396882280984e+22) {
		tmp = t_1;
	} else if (x <= 5.886882456897662e-45) {
		tmp = x + (y * (z / t));
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t):
	return x + ((y * (z - x)) / t)
def code(x, y, z, t):
	t_1 = x - (x * (y / t))
	tmp = 0
	if x <= -4.0386396882280984e+22:
		tmp = t_1
	elif x <= 5.886882456897662e-45:
		tmp = x + (y * (z / t))
	else:
		tmp = t_1
	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)
	t_1 = Float64(x - Float64(x * Float64(y / t)))
	tmp = 0.0
	if (x <= -4.0386396882280984e+22)
		tmp = t_1;
	elseif (x <= 5.886882456897662e-45)
		tmp = Float64(x + Float64(y * Float64(z / t)));
	else
		tmp = t_1;
	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)
	t_1 = x - (x * (y / t));
	tmp = 0.0;
	if (x <= -4.0386396882280984e+22)
		tmp = t_1;
	elseif (x <= 5.886882456897662e-45)
		tmp = x + (y * (z / t));
	else
		tmp = t_1;
	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_] := Block[{t$95$1 = N[(x - N[(x * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -4.0386396882280984e+22], t$95$1, If[LessEqual[x, 5.886882456897662e-45], N[(x + N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
x + \frac{y \cdot \left(z - x\right)}{t}
\begin{array}{l}
t_1 := x - x \cdot \frac{y}{t}\\
\mathbf{if}\;x \leq -4.0386396882280984 \cdot 10^{+22}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq 5.886882456897662 \cdot 10^{-45}:\\
\;\;\;\;x + y \cdot \frac{z}{t}\\

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


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Split input into 2 regimes
  2. if x < -4.03863968822809843e22 or 5.8868824568976616e-45 < x

    1. Initial program 8.4

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(z - x, \frac{y}{t}, x\right)} \]
    3. Applied egg-rr0.1

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

      \[\leadsto \color{blue}{\left(1 + -1 \cdot \frac{y}{t}\right) \cdot x} \]
    5. Simplified7.9

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

    if -4.03863968822809843e22 < x < 5.8868824568976616e-45

    1. Initial program 4.1

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(z - x, \frac{y}{t}, x\right)} \]
    3. Applied egg-rr3.9

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

      \[\leadsto x + \color{blue}{\frac{y \cdot z}{t}} \]
    5. Simplified12.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4.0386396882280984 \cdot 10^{+22}:\\ \;\;\;\;x - x \cdot \frac{y}{t}\\ \mathbf{elif}\;x \leq 5.886882456897662 \cdot 10^{-45}:\\ \;\;\;\;x + y \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;x - x \cdot \frac{y}{t}\\ \end{array} \]

Alternatives

Alternative 1
Error13.6
Cost712
\[\begin{array}{l} t_1 := x + y \cdot \frac{z}{t}\\ \mathbf{if}\;t \leq -3.242559312295858 \cdot 10^{+33}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 10^{-297}:\\ \;\;\;\;x + \frac{y \cdot z}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error11.9
Cost712
\[\begin{array}{l} t_1 := y \cdot \frac{z - x}{t}\\ \mathbf{if}\;y \leq -4.6 \cdot 10^{+156}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.4 \cdot 10^{-16}:\\ \;\;\;\;x + \frac{y \cdot z}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error26.5
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -8.489853564299164 \cdot 10^{-59}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.2430023284023754 \cdot 10^{-54}:\\ \;\;\;\;\frac{y}{t} \cdot z\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 4
Error26.5
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -8.489853564299164 \cdot 10^{-59}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.2430023284023754 \cdot 10^{-54}:\\ \;\;\;\;\frac{z}{\frac{t}{y}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 5
Error14.6
Cost580
\[\begin{array}{l} \mathbf{if}\;y \leq -4.6 \cdot 10^{+156}:\\ \;\;\;\;\frac{z}{\frac{t}{y}}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y \cdot z}{t}\\ \end{array} \]
Alternative 6
Error31.9
Cost64
\[x \]

Error

Reproduce

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