?

Average Error: 6.4 → 1.4
Time: 11.0s
Precision: binary64
Cost: 841

?

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

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.4
Target2.1
Herbie1.4
\[\begin{array}{l} \mathbf{if}\;x < -9.025511195533005 \cdot 10^{-135}:\\ \;\;\;\;x - \frac{z}{t} \cdot \left(x - y\right)\\ \mathbf{elif}\;x < 4.275032163700715 \cdot 10^{-250}:\\ \;\;\;\;x + \frac{y - x}{t} \cdot z\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y - x}{\frac{t}{z}}\\ \end{array} \]

Derivation?

  1. Split input into 2 regimes
  2. if z < -8.5000000000000003e-65 or 2.0000000000000002e-15 < z

    1. Initial program 13.1

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

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

      [Start]13.1

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

      associate-*l/ [<=]2.0

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

    if -8.5000000000000003e-65 < z < 2.0000000000000002e-15

    1. Initial program 1.0

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

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

Alternatives

Alternative 1
Error0.8
Cost1865
\[\begin{array}{l} t_1 := x + \frac{\left(y - x\right) \cdot z}{t}\\ \mathbf{if}\;t_1 \leq -\infty \lor \neg \left(t_1 \leq 2 \cdot 10^{+288}\right):\\ \;\;\;\;x + \frac{y - x}{\frac{t}{z}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error27.4
Cost1379
\[\begin{array}{l} \mathbf{if}\;x \leq -2.5 \cdot 10^{-167}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -6.5 \cdot 10^{-270} \lor \neg \left(x \leq -2.8 \cdot 10^{-300}\right) \land \left(x \leq 7.5 \cdot 10^{-107} \lor \neg \left(x \leq 7.2 \cdot 10^{-92}\right) \land \left(x \leq 2.05 \cdot 10^{-66} \lor \neg \left(x \leq 1.65 \cdot 10^{+50}\right) \land x \leq 1.6 \cdot 10^{+86}\right)\right):\\ \;\;\;\;z \cdot \frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Error27.9
Cost1376
\[\begin{array}{l} t_1 := \frac{z}{\frac{t}{y}}\\ \mathbf{if}\;x \leq -1.85 \cdot 10^{-168}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -6.5 \cdot 10^{-270}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -2.8 \cdot 10^{-300}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 7 \cdot 10^{-107}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 9.6 \cdot 10^{-91}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 4.2 \cdot 10^{-10}:\\ \;\;\;\;\frac{y}{\frac{t}{z}}\\ \mathbf{elif}\;x \leq 1.56 \cdot 10^{+50}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.6 \cdot 10^{+86}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 4
Error27.7
Cost1376
\[\begin{array}{l} t_1 := \frac{z}{\frac{t}{y}}\\ \mathbf{if}\;x \leq -6.7 \cdot 10^{-167}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -1.8 \cdot 10^{-269}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -2.8 \cdot 10^{-300}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 2.15 \cdot 10^{-103}:\\ \;\;\;\;\frac{y \cdot z}{t}\\ \mathbf{elif}\;x \leq 8.5 \cdot 10^{-90}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.5 \cdot 10^{-13}:\\ \;\;\;\;\frac{y}{\frac{t}{z}}\\ \mathbf{elif}\;x \leq 1.32 \cdot 10^{+50}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.6 \cdot 10^{+86}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 5
Error4.2
Cost841
\[\begin{array}{l} \mathbf{if}\;z \leq -1 \cdot 10^{-178} \lor \neg \left(z \leq 4.2 \cdot 10^{-132}\right):\\ \;\;\;\;x + z \cdot \frac{y - x}{t}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y \cdot z}{t}\\ \end{array} \]
Alternative 6
Error19.5
Cost713
\[\begin{array}{l} \mathbf{if}\;y \leq -3.3 \cdot 10^{+103} \lor \neg \left(y \leq 1.5 \cdot 10^{+69}\right):\\ \;\;\;\;\frac{y}{\frac{t}{z}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - \frac{z}{t}\right)\\ \end{array} \]
Alternative 7
Error8.3
Cost713
\[\begin{array}{l} \mathbf{if}\;y \leq -6.8 \cdot 10^{-171} \lor \neg \left(y \leq 9.8 \cdot 10^{-58}\right):\\ \;\;\;\;x + y \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - \frac{z}{t}\right)\\ \end{array} \]
Alternative 8
Error8.4
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -1 \cdot 10^{-171}:\\ \;\;\;\;x + \frac{y}{\frac{t}{z}}\\ \mathbf{elif}\;y \leq 8 \cdot 10^{-59}:\\ \;\;\;\;x \cdot \left(1 - \frac{z}{t}\right)\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{z}{t}\\ \end{array} \]
Alternative 9
Error8.3
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -1.35 \cdot 10^{-170}:\\ \;\;\;\;x + \frac{y}{\frac{t}{z}}\\ \mathbf{elif}\;y \leq 2.8 \cdot 10^{-58}:\\ \;\;\;\;x - x \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{z}{t}\\ \end{array} \]
Alternative 10
Error28.5
Cost585
\[\begin{array}{l} \mathbf{if}\;y \leq -4.4 \cdot 10^{+101} \lor \neg \left(y \leq 2.6 \cdot 10^{+69}\right):\\ \;\;\;\;\frac{y}{\frac{t}{z}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 11
Error31.3
Cost64
\[x \]

Error

Reproduce?

herbie shell --seed 2023060 
(FPCore (x y z t)
  :name "Numeric.Histogram:binBounds from Chart-1.5.3"
  :precision binary64

  :herbie-target
  (if (< x -9.025511195533005e-135) (- x (* (/ z t) (- x y))) (if (< x 4.275032163700715e-250) (+ x (* (/ (- y x) t) z)) (+ x (/ (- y x) (/ t z)))))

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