?

Average Error: 9.56% → 0.45%
Time: 9.8s
Precision: binary64
Cost: 1092

?

\[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]
\[\begin{array}{l} \mathbf{if}\;z \cdot z \leq 5 \cdot 10^{+234}:\\ \;\;\;\;x \cdot x + \left(y \cdot 4\right) \cdot \left(t - z \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot x + \left(z \cdot \left(z \cdot y\right)\right) \cdot -4\\ \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) 5e+234)
   (+ (* x x) (* (* y 4.0) (- t (* z z))))
   (+ (* 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) <= 5e+234) {
		tmp = (x * x) + ((y * 4.0) * (t - (z * z)));
	} 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) <= 5d+234) then
        tmp = (x * x) + ((y * 4.0d0) * (t - (z * z)))
    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) <= 5e+234) {
		tmp = (x * x) + ((y * 4.0) * (t - (z * z)));
	} 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) <= 5e+234:
		tmp = (x * x) + ((y * 4.0) * (t - (z * z)))
	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) <= 5e+234)
		tmp = Float64(Float64(x * x) + Float64(Float64(y * 4.0) * Float64(t - Float64(z * z))));
	else
		tmp = Float64(Float64(x * x) + Float64(Float64(z * 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) <= 5e+234)
		tmp = (x * x) + ((y * 4.0) * (t - (z * z)));
	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], 5e+234], N[(N[(x * x), $MachinePrecision] + N[(N[(y * 4.0), $MachinePrecision] * N[(t - N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] + N[(N[(z * N[(z * y), $MachinePrecision]), $MachinePrecision] * -4.0), $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 5 \cdot 10^{+234}:\\
\;\;\;\;x \cdot x + \left(y \cdot 4\right) \cdot \left(t - z \cdot z\right)\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original9.56%
Target9.54%
Herbie0.45%
\[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) < 5.0000000000000003e234

    1. Initial program 0.11

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

    if 5.0000000000000003e234 < (*.f64 z z)

    1. Initial program 66.72

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

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

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

      [Start]68.88

      \[ x \cdot x - 4 \cdot \left(y \cdot {z}^{2}\right) \]

      *-commutative [=>]68.88

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

      unpow2 [=>]68.88

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

      associate-*l* [=>]2.53

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

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

Alternatives

Alternative 1
Error10.06%
Cost969
\[\begin{array}{l} \mathbf{if}\;z \leq -4.3 \cdot 10^{-33} \lor \neg \left(z \leq 10^{-44}\right):\\ \;\;\;\;x \cdot x + \left(z \cdot \left(z \cdot y\right)\right) \cdot -4\\ \mathbf{else}:\\ \;\;\;\;x \cdot x + \left(y \cdot 4\right) \cdot t\\ \end{array} \]
Alternative 2
Error38.97%
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -2.95 \cdot 10^{-5}:\\ \;\;\;\;x \cdot x\\ \mathbf{elif}\;x \leq 1.4 \cdot 10^{-64}:\\ \;\;\;\;4 \cdot \left(y \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot x\\ \end{array} \]
Alternative 3
Error27.13%
Cost576
\[x \cdot x + \left(y \cdot 4\right) \cdot t \]
Alternative 4
Error64.45%
Cost192
\[x \cdot x \]

Error

Reproduce?

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