Average Error: 7.2 → 0.5
Time: 24.1s
Precision: binary64
Cost: 2512
\[\left(x \cdot y - z \cdot y\right) \cdot t \]
\[\begin{array}{l} t_1 := \left(\left(x - z\right) \cdot y\right) \cdot t\\ t_2 := x \cdot y - z \cdot y\\ t_3 := \left(t \cdot y\right) \cdot \left(x - z\right)\\ \mathbf{if}\;t_2 \leq -2 \cdot 10^{+207}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t_2 \leq -2 \cdot 10^{-180}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_2 \leq 0:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t_2 \leq 5 \cdot 10^{+174}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \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 z) y) t))
        (t_2 (- (* x y) (* z y)))
        (t_3 (* (* t y) (- x z))))
   (if (<= t_2 -2e+207)
     t_3
     (if (<= t_2 -2e-180)
       t_1
       (if (<= t_2 0.0) t_3 (if (<= t_2 5e+174) t_1 t_3))))))
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 - z) * y) * t;
	double t_2 = (x * y) - (z * y);
	double t_3 = (t * y) * (x - z);
	double tmp;
	if (t_2 <= -2e+207) {
		tmp = t_3;
	} else if (t_2 <= -2e-180) {
		tmp = t_1;
	} else if (t_2 <= 0.0) {
		tmp = t_3;
	} else if (t_2 <= 5e+174) {
		tmp = t_1;
	} else {
		tmp = t_3;
	}
	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) :: t_3
    real(8) :: tmp
    t_1 = ((x - z) * y) * t
    t_2 = (x * y) - (z * y)
    t_3 = (t * y) * (x - z)
    if (t_2 <= (-2d+207)) then
        tmp = t_3
    else if (t_2 <= (-2d-180)) then
        tmp = t_1
    else if (t_2 <= 0.0d0) then
        tmp = t_3
    else if (t_2 <= 5d+174) then
        tmp = t_1
    else
        tmp = t_3
    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 - z) * y) * t;
	double t_2 = (x * y) - (z * y);
	double t_3 = (t * y) * (x - z);
	double tmp;
	if (t_2 <= -2e+207) {
		tmp = t_3;
	} else if (t_2 <= -2e-180) {
		tmp = t_1;
	} else if (t_2 <= 0.0) {
		tmp = t_3;
	} else if (t_2 <= 5e+174) {
		tmp = t_1;
	} else {
		tmp = t_3;
	}
	return tmp;
}
def code(x, y, z, t):
	return ((x * y) - (z * y)) * t
def code(x, y, z, t):
	t_1 = ((x - z) * y) * t
	t_2 = (x * y) - (z * y)
	t_3 = (t * y) * (x - z)
	tmp = 0
	if t_2 <= -2e+207:
		tmp = t_3
	elif t_2 <= -2e-180:
		tmp = t_1
	elif t_2 <= 0.0:
		tmp = t_3
	elif t_2 <= 5e+174:
		tmp = t_1
	else:
		tmp = t_3
	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(Float64(x - z) * y) * t)
	t_2 = Float64(Float64(x * y) - Float64(z * y))
	t_3 = Float64(Float64(t * y) * Float64(x - z))
	tmp = 0.0
	if (t_2 <= -2e+207)
		tmp = t_3;
	elseif (t_2 <= -2e-180)
		tmp = t_1;
	elseif (t_2 <= 0.0)
		tmp = t_3;
	elseif (t_2 <= 5e+174)
		tmp = t_1;
	else
		tmp = t_3;
	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 - z) * y) * t;
	t_2 = (x * y) - (z * y);
	t_3 = (t * y) * (x - z);
	tmp = 0.0;
	if (t_2 <= -2e+207)
		tmp = t_3;
	elseif (t_2 <= -2e-180)
		tmp = t_1;
	elseif (t_2 <= 0.0)
		tmp = t_3;
	elseif (t_2 <= 5e+174)
		tmp = t_1;
	else
		tmp = t_3;
	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[(N[(x - z), $MachinePrecision] * y), $MachinePrecision] * t), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x * y), $MachinePrecision] - N[(z * y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(t * y), $MachinePrecision] * N[(x - z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -2e+207], t$95$3, If[LessEqual[t$95$2, -2e-180], t$95$1, If[LessEqual[t$95$2, 0.0], t$95$3, If[LessEqual[t$95$2, 5e+174], t$95$1, t$95$3]]]]]]]
\left(x \cdot y - z \cdot y\right) \cdot t
\begin{array}{l}
t_1 := \left(\left(x - z\right) \cdot y\right) \cdot t\\
t_2 := x \cdot y - z \cdot y\\
t_3 := \left(t \cdot y\right) \cdot \left(x - z\right)\\
\mathbf{if}\;t_2 \leq -2 \cdot 10^{+207}:\\
\;\;\;\;t_3\\

\mathbf{elif}\;t_2 \leq -2 \cdot 10^{-180}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;t_2 \leq 0:\\
\;\;\;\;t_3\\

\mathbf{elif}\;t_2 \leq 5 \cdot 10^{+174}:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;t_3\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original7.2
Target3.0
Herbie0.5
\[\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 2 regimes
  2. if (-.f64 (*.f64 x y) (*.f64 z y)) < -2.0000000000000001e207 or -2e-180 < (-.f64 (*.f64 x y) (*.f64 z y)) < -0.0 or 4.9999999999999997e174 < (-.f64 (*.f64 x y) (*.f64 z y))

    1. Initial program 21.8

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

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

    if -2.0000000000000001e207 < (-.f64 (*.f64 x y) (*.f64 z y)) < -2e-180 or -0.0 < (-.f64 (*.f64 x y) (*.f64 z y)) < 4.9999999999999997e174

    1. Initial program 0.3

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

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

      \[\leadsto \color{blue}{\left(\left(x - z\right) \cdot y\right)} \cdot t \]
      Proof
  3. Recombined 2 regimes into one program.

Alternatives

Alternative 1
Error19.9
Cost780
\[\begin{array}{l} \mathbf{if}\;x \leq -8.2 \cdot 10^{-5}:\\ \;\;\;\;\left(y \cdot x\right) \cdot t\\ \mathbf{elif}\;x \leq -1.1 \cdot 10^{-266}:\\ \;\;\;\;-\left(y \cdot t\right) \cdot z\\ \mathbf{elif}\;x \leq 3.8 \cdot 10^{+69}:\\ \;\;\;\;\left(-y \cdot z\right) \cdot t\\ \mathbf{else}:\\ \;\;\;\;\left(t \cdot y\right) \cdot x\\ \end{array} \]
Alternative 2
Error2.7
Cost712
\[\begin{array}{l} t_1 := \left(t \cdot y\right) \cdot \left(x - z\right)\\ \mathbf{if}\;t \leq -2 \cdot 10^{-25}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 6.2 \cdot 10^{-27}:\\ \;\;\;\;\left(\left(x - z\right) \cdot t\right) \cdot y\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error19.4
Cost648
\[\begin{array}{l} \mathbf{if}\;x \leq -3200:\\ \;\;\;\;\left(y \cdot x\right) \cdot t\\ \mathbf{elif}\;x \leq 3.1 \cdot 10^{+25}:\\ \;\;\;\;-\left(t \cdot z\right) \cdot y\\ \mathbf{else}:\\ \;\;\;\;\left(t \cdot y\right) \cdot x\\ \end{array} \]
Alternative 4
Error30.9
Cost584
\[\begin{array}{l} t_1 := \left(t \cdot y\right) \cdot x\\ \mathbf{if}\;t \leq 1.65 \cdot 10^{-194}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 5 \cdot 10^{-32}:\\ \;\;\;\;y \cdot \left(t \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error6.7
Cost448
\[\left(t \cdot y\right) \cdot \left(x - z\right) \]
Alternative 6
Error31.9
Cost320
\[y \cdot \left(t \cdot x\right) \]

Error

Reproduce

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