Average Error: 5.7 → 0.1
Time: 8.4s
Precision: binary64
Cost: 1097
\[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]
\[\begin{array}{l} \mathbf{if}\;z \leq -5 \cdot 10^{+150} \lor \neg \left(z \leq 2 \cdot 10^{+152}\right):\\ \;\;\;\;x \cdot x + \left(z \cdot \left(z \cdot y\right)\right) \cdot -4\\ \mathbf{else}:\\ \;\;\;\;x \cdot x + \left(z \cdot z - t\right) \cdot \left(y \cdot -4\right)\\ \end{array} \]
(FPCore (x y z t) :precision binary64 (- (* x x) (* (* y 4.0) (- (* z z) t))))
(FPCore (x y z t)
 :precision binary64
 (if (or (<= z -5e+150) (not (<= z 2e+152)))
   (+ (* x x) (* (* z (* z y)) -4.0))
   (+ (* x x) (* (- (* z z) t) (* y -4.0)))))
double code(double x, double y, double z, double t) {
	return (x * x) - ((y * 4.0) * ((z * z) - t));
}
double code(double x, double y, double z, double t) {
	double tmp;
	if ((z <= -5e+150) || !(z <= 2e+152)) {
		tmp = (x * x) + ((z * (z * y)) * -4.0);
	} else {
		tmp = (x * x) + (((z * z) - t) * (y * -4.0));
	}
	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 * x) - ((y * 4.0d0) * ((z * 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 <= (-5d+150)) .or. (.not. (z <= 2d+152))) then
        tmp = (x * x) + ((z * (z * y)) * (-4.0d0))
    else
        tmp = (x * x) + (((z * z) - t) * (y * (-4.0d0)))
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	return (x * x) - ((y * 4.0) * ((z * z) - t));
}
public static double code(double x, double y, double z, double t) {
	double tmp;
	if ((z <= -5e+150) || !(z <= 2e+152)) {
		tmp = (x * x) + ((z * (z * y)) * -4.0);
	} else {
		tmp = (x * x) + (((z * z) - t) * (y * -4.0));
	}
	return tmp;
}
def code(x, y, z, t):
	return (x * x) - ((y * 4.0) * ((z * z) - t))
def code(x, y, z, t):
	tmp = 0
	if (z <= -5e+150) or not (z <= 2e+152):
		tmp = (x * x) + ((z * (z * y)) * -4.0)
	else:
		tmp = (x * x) + (((z * z) - t) * (y * -4.0))
	return tmp
function code(x, y, z, t)
	return Float64(Float64(x * x) - Float64(Float64(y * 4.0) * Float64(Float64(z * z) - t)))
end
function code(x, y, z, t)
	tmp = 0.0
	if ((z <= -5e+150) || !(z <= 2e+152))
		tmp = Float64(Float64(x * x) + Float64(Float64(z * Float64(z * y)) * -4.0));
	else
		tmp = Float64(Float64(x * x) + Float64(Float64(Float64(z * z) - t) * Float64(y * -4.0)));
	end
	return tmp
end
function tmp = code(x, y, z, t)
	tmp = (x * x) - ((y * 4.0) * ((z * z) - t));
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if ((z <= -5e+150) || ~((z <= 2e+152)))
		tmp = (x * x) + ((z * (z * y)) * -4.0);
	else
		tmp = (x * x) + (((z * z) - t) * (y * -4.0));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := N[(N[(x * x), $MachinePrecision] - N[(N[(y * 4.0), $MachinePrecision] * N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -5e+150], N[Not[LessEqual[z, 2e+152]], $MachinePrecision]], N[(N[(x * x), $MachinePrecision] + N[(N[(z * N[(z * y), $MachinePrecision]), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] + N[(N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision] * N[(y * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)
\begin{array}{l}
\mathbf{if}\;z \leq -5 \cdot 10^{+150} \lor \neg \left(z \leq 2 \cdot 10^{+152}\right):\\
\;\;\;\;x \cdot x + \left(z \cdot \left(z \cdot y\right)\right) \cdot -4\\

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


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original5.7
Target5.7
Herbie0.1
\[x \cdot x - 4 \cdot \left(y \cdot \left(z \cdot z - t\right)\right) \]

Derivation

  1. Split input into 2 regimes
  2. if z < -5.00000000000000009e150 or 2.0000000000000001e152 < z

    1. Initial program 61.7

      \[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]
    2. Taylor expanded in z around inf 61.7

      \[\leadsto x \cdot x - \color{blue}{4 \cdot \left(y \cdot {z}^{2}\right)} \]
    3. Simplified0.3

      \[\leadsto x \cdot x - \color{blue}{4 \cdot \left(\left(y \cdot z\right) \cdot z\right)} \]
      Proof
      (-.f64 (*.f64 x x) (*.f64 4 (*.f64 (*.f64 y z) z))): 0 points increase in error, 0 points decrease in error
      (-.f64 (*.f64 x x) (*.f64 4 (Rewrite<= associate-*r*_binary64 (*.f64 y (*.f64 z z))))): 3 points increase in error, 0 points decrease in error
      (-.f64 (*.f64 x x) (*.f64 4 (*.f64 y (Rewrite<= unpow2_binary64 (pow.f64 z 2))))): 0 points increase in error, 3 points decrease in error

    if -5.00000000000000009e150 < z < 2.0000000000000001e152

    1. Initial program 0.1

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

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

Alternatives

Alternative 1
Error28.8
Cost1504
\[\begin{array}{l} t_1 := z \cdot \left(z \cdot \left(y \cdot -4\right)\right)\\ t_2 := t \cdot \left(4 \cdot y\right)\\ \mathbf{if}\;z \leq -3.7 \cdot 10^{+86}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -2.7 \cdot 10^{-22}:\\ \;\;\;\;x \cdot x\\ \mathbf{elif}\;z \leq -7.5 \cdot 10^{-49}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -6.2 \cdot 10^{-111}:\\ \;\;\;\;x \cdot x\\ \mathbf{elif}\;z \leq -3 \cdot 10^{-167}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -8.2 \cdot 10^{-209}:\\ \;\;\;\;x \cdot x\\ \mathbf{elif}\;z \leq 7.5 \cdot 10^{-108}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 1.05 \cdot 10^{-39}:\\ \;\;\;\;x \cdot x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error9.5
Cost1236
\[\begin{array}{l} t_1 := x \cdot x + t \cdot \left(4 \cdot y\right)\\ t_2 := z \cdot \left(z \cdot \left(y \cdot -4\right)\right)\\ t_3 := \left(z \cdot z - t\right) \cdot \left(y \cdot -4\right)\\ \mathbf{if}\;z \leq -3.9 \cdot 10^{+86}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -3.35 \cdot 10^{-22}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -4.5 \cdot 10^{-38}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq 1.05 \cdot 10^{-39}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 4.8 \cdot 10^{+153}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 3
Error6.4
Cost969
\[\begin{array}{l} \mathbf{if}\;z \leq -3.4 \cdot 10^{-38} \lor \neg \left(z \leq 1.35 \cdot 10^{-28}\right):\\ \;\;\;\;x \cdot x + \left(z \cdot \left(z \cdot y\right)\right) \cdot -4\\ \mathbf{else}:\\ \;\;\;\;x \cdot x + t \cdot \left(4 \cdot y\right)\\ \end{array} \]
Alternative 4
Error14.8
Cost840
\[\begin{array}{l} \mathbf{if}\;x \leq -2.1 \cdot 10^{-19}:\\ \;\;\;\;x \cdot x\\ \mathbf{elif}\;x \leq 3.2 \cdot 10^{+22}:\\ \;\;\;\;\left(z \cdot z - t\right) \cdot \left(y \cdot -4\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot x\\ \end{array} \]
Alternative 5
Error24.9
Cost585
\[\begin{array}{l} \mathbf{if}\;x \leq -1.15 \cdot 10^{-19} \lor \neg \left(x \leq 255000\right):\\ \;\;\;\;x \cdot x\\ \mathbf{else}:\\ \;\;\;\;t \cdot \left(4 \cdot y\right)\\ \end{array} \]
Alternative 6
Error41.0
Cost192
\[x \cdot x \]

Error

Reproduce

herbie shell --seed 2022343 
(FPCore (x y z t)
  :name "Graphics.Rasterific.Shading:$sradialGradientWithFocusShader from Rasterific-0.6.1, B"
  :precision binary64

  :herbie-target
  (- (* x x) (* 4.0 (* y (- (* z z) t))))

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