?

Average Error: 7.1 → 0.7
Time: 10.5s
Precision: binary64
Cost: 2640

?

\[ \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 - z \cdot y\\ t_2 := \left(x - z\right) \cdot \left(y \cdot t\right)\\ \mathbf{if}\;t_1 \leq -1 \cdot 10^{+219}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_1 \leq -1 \cdot 10^{-236}:\\ \;\;\;\;\left(y \cdot \left(x - z\right)\right) \cdot t\\ \mathbf{elif}\;t_1 \leq 0:\\ \;\;\;\;y \cdot \left(\left(x - z\right) \cdot t\right)\\ \mathbf{elif}\;t_1 \leq 10^{+154}:\\ \;\;\;\;t_1 \cdot t\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \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) (* z y))) (t_2 (* (- x z) (* y t))))
   (if (<= t_1 -1e+219)
     t_2
     (if (<= t_1 -1e-236)
       (* (* y (- x z)) t)
       (if (<= t_1 0.0)
         (* y (* (- x z) t))
         (if (<= t_1 1e+154) (* t_1 t) t_2))))))
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) - (z * y);
	double t_2 = (x - z) * (y * t);
	double tmp;
	if (t_1 <= -1e+219) {
		tmp = t_2;
	} else if (t_1 <= -1e-236) {
		tmp = (y * (x - z)) * t;
	} else if (t_1 <= 0.0) {
		tmp = y * ((x - z) * t);
	} else if (t_1 <= 1e+154) {
		tmp = t_1 * t;
	} else {
		tmp = t_2;
	}
	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) :: t_2
    real(8) :: tmp
    t_1 = (x * y) - (z * y)
    t_2 = (x - z) * (y * t)
    if (t_1 <= (-1d+219)) then
        tmp = t_2
    else if (t_1 <= (-1d-236)) then
        tmp = (y * (x - z)) * t
    else if (t_1 <= 0.0d0) then
        tmp = y * ((x - z) * t)
    else if (t_1 <= 1d+154) then
        tmp = t_1 * t
    else
        tmp = t_2
    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) - (z * y);
	double t_2 = (x - z) * (y * t);
	double tmp;
	if (t_1 <= -1e+219) {
		tmp = t_2;
	} else if (t_1 <= -1e-236) {
		tmp = (y * (x - z)) * t;
	} else if (t_1 <= 0.0) {
		tmp = y * ((x - z) * t);
	} else if (t_1 <= 1e+154) {
		tmp = t_1 * t;
	} else {
		tmp = t_2;
	}
	return tmp;
}
def code(x, y, z, t):
	return ((x * y) - (z * y)) * t
def code(x, y, z, t):
	t_1 = (x * y) - (z * y)
	t_2 = (x - z) * (y * t)
	tmp = 0
	if t_1 <= -1e+219:
		tmp = t_2
	elif t_1 <= -1e-236:
		tmp = (y * (x - z)) * t
	elif t_1 <= 0.0:
		tmp = y * ((x - z) * t)
	elif t_1 <= 1e+154:
		tmp = t_1 * t
	else:
		tmp = t_2
	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(z * y))
	t_2 = Float64(Float64(x - z) * Float64(y * t))
	tmp = 0.0
	if (t_1 <= -1e+219)
		tmp = t_2;
	elseif (t_1 <= -1e-236)
		tmp = Float64(Float64(y * Float64(x - z)) * t);
	elseif (t_1 <= 0.0)
		tmp = Float64(y * Float64(Float64(x - z) * t));
	elseif (t_1 <= 1e+154)
		tmp = Float64(t_1 * t);
	else
		tmp = t_2;
	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) - (z * y);
	t_2 = (x - z) * (y * t);
	tmp = 0.0;
	if (t_1 <= -1e+219)
		tmp = t_2;
	elseif (t_1 <= -1e-236)
		tmp = (y * (x - z)) * t;
	elseif (t_1 <= 0.0)
		tmp = y * ((x - z) * t);
	elseif (t_1 <= 1e+154)
		tmp = t_1 * t;
	else
		tmp = t_2;
	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[(z * y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x - z), $MachinePrecision] * N[(y * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -1e+219], t$95$2, If[LessEqual[t$95$1, -1e-236], N[(N[(y * N[(x - z), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision], If[LessEqual[t$95$1, 0.0], N[(y * N[(N[(x - z), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e+154], N[(t$95$1 * t), $MachinePrecision], t$95$2]]]]]]
\left(x \cdot y - z \cdot y\right) \cdot t
\begin{array}{l}
t_1 := x \cdot y - z \cdot y\\
t_2 := \left(x - z\right) \cdot \left(y \cdot t\right)\\
\mathbf{if}\;t_1 \leq -1 \cdot 10^{+219}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;t_1 \leq -1 \cdot 10^{-236}:\\
\;\;\;\;\left(y \cdot \left(x - z\right)\right) \cdot t\\

\mathbf{elif}\;t_1 \leq 0:\\
\;\;\;\;y \cdot \left(\left(x - z\right) \cdot t\right)\\

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

\mathbf{else}:\\
\;\;\;\;t_2\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original7.1
Target3.7
Herbie0.7
\[\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 4 regimes
  2. if (-.f64 (*.f64 x y) (*.f64 z y)) < -9.99999999999999965e218 or 1.00000000000000004e154 < (-.f64 (*.f64 x y) (*.f64 z y))

    1. Initial program 24.7

      \[\left(x \cdot y - z \cdot y\right) \cdot t \]
    2. Taylor expanded in y around 0 1.9

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

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

      [Start]1.9

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

      rational.json-simplify-43 [=>]24.7

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

      rational.json-simplify-43 [=>]2.1

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

    if -9.99999999999999965e218 < (-.f64 (*.f64 x y) (*.f64 z y)) < -1e-236

    1. Initial program 0.2

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

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

      [Start]0.2

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

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

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

      rational.json-simplify-48 [=>]0.2

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

    if -1e-236 < (-.f64 (*.f64 x y) (*.f64 z y)) < 0.0

    1. Initial program 15.8

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

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

      [Start]15.8

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

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

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

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

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

      rational.json-simplify-48 [=>]15.8

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

      rational.json-simplify-43 [=>]0.2

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

    if 0.0 < (-.f64 (*.f64 x y) (*.f64 z y)) < 1.00000000000000004e154

    1. Initial program 0.4

      \[\left(x \cdot y - z \cdot y\right) \cdot t \]
  3. Recombined 4 regimes into one program.
  4. Final simplification0.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y - z \cdot y \leq -1 \cdot 10^{+219}:\\ \;\;\;\;\left(x - z\right) \cdot \left(y \cdot t\right)\\ \mathbf{elif}\;x \cdot y - z \cdot y \leq -1 \cdot 10^{-236}:\\ \;\;\;\;\left(y \cdot \left(x - z\right)\right) \cdot t\\ \mathbf{elif}\;x \cdot y - z \cdot y \leq 0:\\ \;\;\;\;y \cdot \left(\left(x - z\right) \cdot t\right)\\ \mathbf{elif}\;x \cdot y - z \cdot y \leq 10^{+154}:\\ \;\;\;\;\left(x \cdot y - z \cdot y\right) \cdot t\\ \mathbf{else}:\\ \;\;\;\;\left(x - z\right) \cdot \left(y \cdot t\right)\\ \end{array} \]

Alternatives

Alternative 1
Error7.9
Cost844
\[\begin{array}{l} t_1 := y \cdot \left(\left(x - z\right) \cdot t\right)\\ \mathbf{if}\;t \leq 9.5 \cdot 10^{+231}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 8.5 \cdot 10^{+257}:\\ \;\;\;\;\left(y \cdot \left(-z\right)\right) \cdot t\\ \mathbf{elif}\;t \leq 1.65 \cdot 10^{+273}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot t\right)\\ \end{array} \]
Alternative 2
Error20.1
Cost716
\[\begin{array}{l} t_1 := x \cdot \left(y \cdot t\right)\\ \mathbf{if}\;x \leq -1.45 \cdot 10^{-95}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 10^{-98}:\\ \;\;\;\;-z \cdot \left(t \cdot y\right)\\ \mathbf{elif}\;x \leq 5 \cdot 10^{+157}:\\ \;\;\;\;\left(y \cdot x\right) \cdot t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error19.9
Cost716
\[\begin{array}{l} t_1 := x \cdot \left(y \cdot t\right)\\ \mathbf{if}\;x \leq -4.8 \cdot 10^{-7}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 3 \cdot 10^{-61}:\\ \;\;\;\;y \cdot \left(\left(-z\right) \cdot t\right)\\ \mathbf{elif}\;x \leq 3.6 \cdot 10^{+161}:\\ \;\;\;\;\left(y \cdot x\right) \cdot t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error2.8
Cost580
\[\begin{array}{l} \mathbf{if}\;y \leq -5.2 \cdot 10^{-24}:\\ \;\;\;\;y \cdot \left(\left(x - z\right) \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;\left(y \cdot \left(x - z\right)\right) \cdot t\\ \end{array} \]
Alternative 5
Error2.6
Cost580
\[\begin{array}{l} \mathbf{if}\;t \leq 5 \cdot 10^{-21}:\\ \;\;\;\;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.3
Cost452
\[\begin{array}{l} \mathbf{if}\;t \leq 2 \cdot 10^{-20}:\\ \;\;\;\;y \cdot \left(t \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot t\right)\\ \end{array} \]
Alternative 7
Error29.4
Cost452
\[\begin{array}{l} \mathbf{if}\;y \leq -8.5 \cdot 10^{-45}:\\ \;\;\;\;y \cdot \left(t \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\left(y \cdot x\right) \cdot t\\ \end{array} \]
Alternative 8
Error31.5
Cost320
\[x \cdot \left(y \cdot t\right) \]

Error

Reproduce?

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