?

Average Error: 5.9 → 5.6
Time: 8.3s
Precision: binary64
Cost: 7812

?

\[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]
\[\begin{array}{l} \mathbf{if}\;x \cdot x \leq 5 \cdot 10^{+203}:\\ \;\;\;\;x \cdot x - \left(y \cdot \left(t \cdot -4\right) + 64 \cdot \left({\left(\frac{z}{4}\right)}^{2} \cdot y\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot x - t \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 (<= (* x x) 5e+203)
   (- (* x x) (+ (* y (* t -4.0)) (* 64.0 (* (pow (/ z 4.0) 2.0) y))))
   (- (* x x) (* 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 ((x * x) <= 5e+203) {
		tmp = (x * x) - ((y * (t * -4.0)) + (64.0 * (pow((z / 4.0), 2.0) * y)));
	} else {
		tmp = (x * x) - (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 ((x * x) <= 5d+203) then
        tmp = (x * x) - ((y * (t * (-4.0d0))) + (64.0d0 * (((z / 4.0d0) ** 2.0d0) * y)))
    else
        tmp = (x * x) - (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 ((x * x) <= 5e+203) {
		tmp = (x * x) - ((y * (t * -4.0)) + (64.0 * (Math.pow((z / 4.0), 2.0) * y)));
	} else {
		tmp = (x * x) - (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 (x * x) <= 5e+203:
		tmp = (x * x) - ((y * (t * -4.0)) + (64.0 * (math.pow((z / 4.0), 2.0) * y)))
	else:
		tmp = (x * x) - (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 (Float64(x * x) <= 5e+203)
		tmp = Float64(Float64(x * x) - Float64(Float64(y * Float64(t * -4.0)) + Float64(64.0 * Float64((Float64(z / 4.0) ^ 2.0) * y))));
	else
		tmp = Float64(Float64(x * x) - Float64(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 ((x * x) <= 5e+203)
		tmp = (x * x) - ((y * (t * -4.0)) + (64.0 * (((z / 4.0) ^ 2.0) * y)));
	else
		tmp = (x * x) - (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[LessEqual[N[(x * x), $MachinePrecision], 5e+203], N[(N[(x * x), $MachinePrecision] - N[(N[(y * N[(t * -4.0), $MachinePrecision]), $MachinePrecision] + N[(64.0 * N[(N[Power[N[(z / 4.0), $MachinePrecision], 2.0], $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] - N[(t * 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}\;x \cdot x \leq 5 \cdot 10^{+203}:\\
\;\;\;\;x \cdot x - \left(y \cdot \left(t \cdot -4\right) + 64 \cdot \left({\left(\frac{z}{4}\right)}^{2} \cdot y\right)\right)\\

\mathbf{else}:\\
\;\;\;\;x \cdot x - t \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.9
Target5.8
Herbie5.6
\[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 x x) < 4.99999999999999994e203

    1. Initial program 5.8

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

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

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

      [Start]5.8

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

      rational.json-simplify-1 [<=]5.8

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

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

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

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

      \[ x \cdot x - \left(y \cdot \left(t \cdot -4\right) + 4 \cdot \color{blue}{\left({z}^{2} \cdot y\right)}\right) \]
    4. Applied egg-rr5.9

      \[\leadsto x \cdot x - \left(y \cdot \left(t \cdot -4\right) + \color{blue}{\left({z}^{2} \cdot \left(y \cdot 3\right) + {z}^{2} \cdot y\right)}\right) \]
    5. Applied egg-rr5.8

      \[\leadsto x \cdot x - \left(y \cdot \left(t \cdot -4\right) + \color{blue}{32 \cdot \left(\left(y + y\right) \cdot {\left(\frac{z}{4}\right)}^{2}\right)}\right) \]
    6. Simplified5.8

      \[\leadsto x \cdot x - \left(y \cdot \left(t \cdot -4\right) + \color{blue}{64 \cdot \left({\left(\frac{z}{4}\right)}^{2} \cdot y\right)}\right) \]
      Proof

      [Start]5.8

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

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

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

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

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

      rational.json-simplify-53 [=>]5.8

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

      metadata-eval [=>]5.8

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

    if 4.99999999999999994e203 < (*.f64 x x)

    1. Initial program 6.2

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

      \[\leadsto x \cdot x - \color{blue}{-4 \cdot \left(y \cdot t\right)} \]
    3. Simplified4.5

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

      [Start]4.4

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

      rational.json-simplify-43 [<=]4.5

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

      rational.json-simplify-2 [<=]4.5

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

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

Alternatives

Alternative 1
Error5.9
Cost832
\[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]
Alternative 2
Error17.7
Cost576
\[x \cdot x - t \cdot \left(y \cdot -4\right) \]
Alternative 3
Error37.2
Cost320
\[t \cdot \left(4 \cdot y\right) \]

Error

Reproduce?

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