?

Average Error: 6.9 → 2.0
Time: 9.1s
Precision: binary64
Cost: 8008

?

\[ \begin{array}{c}[y, t] = \mathsf{sort}([y, t])\\ \end{array} \]
\[\left(x \cdot y - z \cdot y\right) \cdot t \]
\[\begin{array}{l} t_1 := x \cdot y - y \cdot z\\ \mathbf{if}\;t_1 \leq -4 \cdot 10^{+197}:\\ \;\;\;\;\left(x - z\right) \cdot \left(y \cdot t\right)\\ \mathbf{elif}\;t_1 \leq 5 \cdot 10^{+96}:\\ \;\;\;\;t_1 \cdot t\\ \mathbf{else}:\\ \;\;\;\;\frac{t}{-{y}^{-1}} \cdot \left(z - x\right)\\ \end{array} \]
(FPCore (x y z t) :precision binary64 (* (- (* x y) (* z y)) t))
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (- (* x y) (* y z))))
   (if (<= t_1 -4e+197)
     (* (- x z) (* y t))
     (if (<= t_1 5e+96) (* t_1 t) (* (/ t (- (pow y -1.0))) (- z x))))))
double code(double x, double y, double z, double t) {
	return ((x * y) - (z * y)) * t;
}
double code(double x, double y, double z, double t) {
	double t_1 = (x * y) - (y * z);
	double tmp;
	if (t_1 <= -4e+197) {
		tmp = (x - z) * (y * t);
	} else if (t_1 <= 5e+96) {
		tmp = t_1 * t;
	} else {
		tmp = (t / -pow(y, -1.0)) * (z - 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
    code = ((x * y) - (z * y)) * 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 * y) - (y * z)
    if (t_1 <= (-4d+197)) then
        tmp = (x - z) * (y * t)
    else if (t_1 <= 5d+96) then
        tmp = t_1 * t
    else
        tmp = (t / -(y ** (-1.0d0))) * (z - x)
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	return ((x * y) - (z * y)) * t;
}
public static double code(double x, double y, double z, double t) {
	double t_1 = (x * y) - (y * z);
	double tmp;
	if (t_1 <= -4e+197) {
		tmp = (x - z) * (y * t);
	} else if (t_1 <= 5e+96) {
		tmp = t_1 * t;
	} else {
		tmp = (t / -Math.pow(y, -1.0)) * (z - x);
	}
	return tmp;
}
def code(x, y, z, t):
	return ((x * y) - (z * y)) * t
def code(x, y, z, t):
	t_1 = (x * y) - (y * z)
	tmp = 0
	if t_1 <= -4e+197:
		tmp = (x - z) * (y * t)
	elif t_1 <= 5e+96:
		tmp = t_1 * t
	else:
		tmp = (t / -math.pow(y, -1.0)) * (z - x)
	return tmp
function code(x, y, z, t)
	return Float64(Float64(Float64(x * y) - Float64(z * y)) * t)
end
function code(x, y, z, t)
	t_1 = Float64(Float64(x * y) - Float64(y * z))
	tmp = 0.0
	if (t_1 <= -4e+197)
		tmp = Float64(Float64(x - z) * Float64(y * t));
	elseif (t_1 <= 5e+96)
		tmp = Float64(t_1 * t);
	else
		tmp = Float64(Float64(t / Float64(-(y ^ -1.0))) * Float64(z - x));
	end
	return tmp
end
function tmp = code(x, y, z, t)
	tmp = ((x * y) - (z * y)) * t;
end
function tmp_2 = code(x, y, z, t)
	t_1 = (x * y) - (y * z);
	tmp = 0.0;
	if (t_1 <= -4e+197)
		tmp = (x - z) * (y * t);
	elseif (t_1 <= 5e+96)
		tmp = t_1 * t;
	else
		tmp = (t / -(y ^ -1.0)) * (z - x);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := N[(N[(N[(x * y), $MachinePrecision] - N[(z * y), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x * y), $MachinePrecision] - N[(y * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -4e+197], N[(N[(x - z), $MachinePrecision] * N[(y * t), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e+96], N[(t$95$1 * t), $MachinePrecision], N[(N[(t / (-N[Power[y, -1.0], $MachinePrecision])), $MachinePrecision] * N[(z - x), $MachinePrecision]), $MachinePrecision]]]]
\left(x \cdot y - z \cdot y\right) \cdot t
\begin{array}{l}
t_1 := x \cdot y - y \cdot z\\
\mathbf{if}\;t_1 \leq -4 \cdot 10^{+197}:\\
\;\;\;\;\left(x - z\right) \cdot \left(y \cdot t\right)\\

\mathbf{elif}\;t_1 \leq 5 \cdot 10^{+96}:\\
\;\;\;\;t_1 \cdot t\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.9
Target3.2
Herbie2.0
\[\begin{array}{l} \mathbf{if}\;t < -9.231879582886777 \cdot 10^{-80}:\\ \;\;\;\;\left(y \cdot t\right) \cdot \left(x - z\right)\\ \mathbf{elif}\;t < 2.543067051564877 \cdot 10^{+83}:\\ \;\;\;\;y \cdot \left(t \cdot \left(x - z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(y \cdot \left(x - z\right)\right) \cdot t\\ \end{array} \]

Derivation?

  1. Split input into 3 regimes
  2. if (-.f64 (*.f64 x y) (*.f64 z y)) < -3.9999999999999998e197

    1. Initial program 26.6

      \[\left(x \cdot y - z \cdot y\right) \cdot t \]
    2. Simplified1.2

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

      [Start]26.6

      \[ \left(x \cdot y - z \cdot y\right) \cdot t \]

      distribute-rgt-out-- [=>]26.6

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

      associate-*l* [=>]1.2

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

      *-commutative [=>]1.2

      \[ y \cdot \color{blue}{\left(t \cdot \left(x - z\right)\right)} \]
    3. Taylor expanded in x around 0 1.2

      \[\leadsto \color{blue}{y \cdot \left(t \cdot x\right) + -1 \cdot \left(y \cdot \left(t \cdot z\right)\right)} \]
    4. Simplified1.6

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

      [Start]1.2

      \[ y \cdot \left(t \cdot x\right) + -1 \cdot \left(y \cdot \left(t \cdot z\right)\right) \]

      mul-1-neg [=>]1.2

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

      unsub-neg [=>]1.2

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

      associate-*r* [=>]1.8

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

      associate-*r* [=>]1.6

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

      distribute-lft-out-- [=>]1.6

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

      *-commutative [=>]1.6

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

    if -3.9999999999999998e197 < (-.f64 (*.f64 x y) (*.f64 z y)) < 5.0000000000000004e96

    1. Initial program 1.8

      \[\left(x \cdot y - z \cdot y\right) \cdot t \]

    if 5.0000000000000004e96 < (-.f64 (*.f64 x y) (*.f64 z y))

    1. Initial program 16.7

      \[\left(x \cdot y - z \cdot y\right) \cdot t \]
    2. Applied egg-rr16.8

      \[\leadsto \color{blue}{\frac{t}{\frac{1}{y \cdot \left(x - z\right)}}} \]
    3. Applied egg-rr3.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y - y \cdot z \leq -4 \cdot 10^{+197}:\\ \;\;\;\;\left(x - z\right) \cdot \left(y \cdot t\right)\\ \mathbf{elif}\;x \cdot y - y \cdot z \leq 5 \cdot 10^{+96}:\\ \;\;\;\;\left(x \cdot y - y \cdot z\right) \cdot t\\ \mathbf{else}:\\ \;\;\;\;\frac{t}{-{y}^{-1}} \cdot \left(z - x\right)\\ \end{array} \]

Alternatives

Alternative 1
Error2.0
Cost1609
\[\begin{array}{l} t_1 := x \cdot y - y \cdot z\\ \mathbf{if}\;t_1 \leq -4 \cdot 10^{+197} \lor \neg \left(t_1 \leq 5 \cdot 10^{+96}\right):\\ \;\;\;\;\left(x - z\right) \cdot \left(y \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;t_1 \cdot t\\ \end{array} \]
Alternative 2
Error8.3
Cost845
\[\begin{array}{l} \mathbf{if}\;x \leq -1.9 \cdot 10^{+265}:\\ \;\;\;\;t \cdot \left(x \cdot y\right)\\ \mathbf{elif}\;x \leq -1.75 \cdot 10^{+231} \lor \neg \left(x \leq -2.1 \cdot 10^{+99}\right):\\ \;\;\;\;y \cdot \left(\left(x - z\right) \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot t\right)\\ \end{array} \]
Alternative 3
Error20.5
Cost648
\[\begin{array}{l} \mathbf{if}\;x \leq -0.0125:\\ \;\;\;\;x \cdot \left(y \cdot t\right)\\ \mathbf{elif}\;x \leq 3 \cdot 10^{+77}:\\ \;\;\;\;y \cdot \left(z \cdot \left(-t\right)\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(x \cdot t\right)\\ \end{array} \]
Alternative 4
Error2.6
Cost580
\[\begin{array}{l} \mathbf{if}\;y \leq -1.15 \cdot 10^{+51}:\\ \;\;\;\;y \cdot \left(\left(x - z\right) \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;t \cdot \left(y \cdot \left(x - z\right)\right)\\ \end{array} \]
Alternative 5
Error2.5
Cost580
\[\begin{array}{l} \mathbf{if}\;t \leq 5.175 \cdot 10^{-48}:\\ \;\;\;\;y \cdot \left(\left(x - z\right) \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x - z\right) \cdot \left(y \cdot t\right)\\ \end{array} \]
Alternative 6
Error29.6
Cost452
\[\begin{array}{l} \mathbf{if}\;t \leq 1.35 \cdot 10^{+72}:\\ \;\;\;\;y \cdot \left(x \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot t\right)\\ \end{array} \]
Alternative 7
Error29.5
Cost452
\[\begin{array}{l} \mathbf{if}\;y \leq -1.25 \cdot 10^{+51}:\\ \;\;\;\;y \cdot \left(x \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;t \cdot \left(x \cdot y\right)\\ \end{array} \]
Alternative 8
Error31.9
Cost320
\[y \cdot \left(x \cdot t\right) \]

Error

Reproduce?

herbie shell --seed 2023039 
(FPCore (x y z t)
  :name "Linear.Projection:inverseInfinitePerspective from linear-1.19.1.3"
  :precision binary64

  :herbie-target
  (if (< t -9.231879582886777e-80) (* (* y t) (- x z)) (if (< t 2.543067051564877e+83) (* y (* t (- x z))) (* (* y (- x z)) t)))

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