Average Error: 6.0 → 0.1
Time: 8.9s
Precision: binary64
Cost: 1348
\[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]
\[\begin{array}{l} \mathbf{if}\;z \cdot z \leq 10^{+292}:\\ \;\;\;\;x \cdot x + \left(y \cdot \left(4 \cdot t\right) + y \cdot \left(\left(z \cdot z\right) \cdot -4\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot x + z \cdot \left(\left(z \cdot y\right) \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 (<= (* z z) 1e+292)
   (+ (* x x) (+ (* y (* 4.0 t)) (* y (* (* z z) -4.0))))
   (+ (* x x) (* z (* (* z 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 * z) <= 1e+292) {
		tmp = (x * x) + ((y * (4.0 * t)) + (y * ((z * z) * -4.0)));
	} else {
		tmp = (x * x) + (z * ((z * 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 * z) <= 1d+292) then
        tmp = (x * x) + ((y * (4.0d0 * t)) + (y * ((z * z) * (-4.0d0))))
    else
        tmp = (x * x) + (z * ((z * 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 * z) <= 1e+292) {
		tmp = (x * x) + ((y * (4.0 * t)) + (y * ((z * z) * -4.0)));
	} else {
		tmp = (x * x) + (z * ((z * 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 * z) <= 1e+292:
		tmp = (x * x) + ((y * (4.0 * t)) + (y * ((z * z) * -4.0)))
	else:
		tmp = (x * x) + (z * ((z * 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 (Float64(z * z) <= 1e+292)
		tmp = Float64(Float64(x * x) + Float64(Float64(y * Float64(4.0 * t)) + Float64(y * Float64(Float64(z * z) * -4.0))));
	else
		tmp = Float64(Float64(x * x) + Float64(z * Float64(Float64(z * 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 * z) <= 1e+292)
		tmp = (x * x) + ((y * (4.0 * t)) + (y * ((z * z) * -4.0)));
	else
		tmp = (x * x) + (z * ((z * 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[LessEqual[N[(z * z), $MachinePrecision], 1e+292], N[(N[(x * x), $MachinePrecision] + N[(N[(y * N[(4.0 * t), $MachinePrecision]), $MachinePrecision] + N[(y * N[(N[(z * z), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] + N[(z * N[(N[(z * y), $MachinePrecision] * -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 \cdot z \leq 10^{+292}:\\
\;\;\;\;x \cdot x + \left(y \cdot \left(4 \cdot t\right) + y \cdot \left(\left(z \cdot z\right) \cdot -4\right)\right)\\

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


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.0
Target5.9
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 (*.f64 z z) < 1e292

    1. Initial program 0.1

      \[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]
    2. Applied egg-rr0.1

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

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

    if 1e292 < (*.f64 z z)

    1. Initial program 57.6

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

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

      \[\leadsto x \cdot x - \left(y \cdot 4\right) \cdot \color{blue}{\left(z \cdot z\right)} \]
    4. Taylor expanded in y around 0 57.9

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

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

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

Alternatives

Alternative 1
Error30.9
Cost1108
\[\begin{array}{l} t_1 := 4 \cdot \left(y \cdot t\right)\\ t_2 := y \cdot \left(\left(z \cdot z\right) \cdot -4\right)\\ \mathbf{if}\;z \leq -2.8 \cdot 10^{+150}:\\ \;\;\;\;x \cdot x\\ \mathbf{elif}\;z \leq -4.306244940095068:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 8.822985783073539 \cdot 10^{-299}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.2376377621498346 \cdot 10^{-284}:\\ \;\;\;\;x \cdot x\\ \mathbf{elif}\;z \leq 4.4173171374628515:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 2
Error6.8
Cost1100
\[\begin{array}{l} t_1 := x \cdot x + z \cdot \left(\left(z \cdot y\right) \cdot -4\right)\\ \mathbf{if}\;z \leq -1 \cdot 10^{+85}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -7.205556534252329 \cdot 10^{-46}:\\ \;\;\;\;y \cdot \left(4 \cdot \left(t - z \cdot z\right)\right)\\ \mathbf{elif}\;z \leq 4.4173171374628515:\\ \;\;\;\;x \cdot x + t \cdot \left(y \cdot 4\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error14.8
Cost840
\[\begin{array}{l} \mathbf{if}\;x \leq -1.2380169842127904 \cdot 10^{+54}:\\ \;\;\;\;x \cdot x\\ \mathbf{elif}\;x \leq 13451638.981424097:\\ \;\;\;\;y \cdot \left(4 \cdot \left(t - z \cdot z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot x\\ \end{array} \]
Alternative 4
Error11.0
Cost840
\[\begin{array}{l} t_1 := x \cdot x + t \cdot \left(y \cdot 4\right)\\ \mathbf{if}\;x \leq -2.7045900913506884 \cdot 10^{-123}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.3568564407346414 \cdot 10^{-57}:\\ \;\;\;\;y \cdot \left(4 \cdot \left(t - z \cdot z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error25.7
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -1.704586833957844 \cdot 10^{+48}:\\ \;\;\;\;x \cdot x\\ \mathbf{elif}\;x \leq 13451638.981424097:\\ \;\;\;\;4 \cdot \left(y \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot x\\ \end{array} \]
Alternative 6
Error41.3
Cost192
\[x \cdot x \]

Error

Reproduce

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