?

Average Accuracy: 91.0% → 95.5%
Time: 12.0s
Precision: binary64
Cost: 1096

?

\[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]
\[\begin{array}{l} t_1 := z \cdot \left(z \cdot y\right)\\ \mathbf{if}\;z \leq -1.3 \cdot 10^{+154}:\\ \;\;\;\;-4 \cdot t_1\\ \mathbf{elif}\;z \leq 2 \cdot 10^{+115}:\\ \;\;\;\;x \cdot x + \left(y \cdot 4\right) \cdot \left(t - z \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot x - 4 \cdot t_1\\ \end{array} \]
(FPCore (x y z t) :precision binary64 (- (* x x) (* (* y 4.0) (- (* z z) t))))
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* z (* z y))))
   (if (<= z -1.3e+154)
     (* -4.0 t_1)
     (if (<= z 2e+115)
       (+ (* x x) (* (* y 4.0) (- t (* z z))))
       (- (* x x) (* 4.0 t_1))))))
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 t_1 = z * (z * y);
	double tmp;
	if (z <= -1.3e+154) {
		tmp = -4.0 * t_1;
	} else if (z <= 2e+115) {
		tmp = (x * x) + ((y * 4.0) * (t - (z * z)));
	} else {
		tmp = (x * x) - (4.0 * t_1);
	}
	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) :: t_1
    real(8) :: tmp
    t_1 = z * (z * y)
    if (z <= (-1.3d+154)) then
        tmp = (-4.0d0) * t_1
    else if (z <= 2d+115) then
        tmp = (x * x) + ((y * 4.0d0) * (t - (z * z)))
    else
        tmp = (x * x) - (4.0d0 * t_1)
    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 t_1 = z * (z * y);
	double tmp;
	if (z <= -1.3e+154) {
		tmp = -4.0 * t_1;
	} else if (z <= 2e+115) {
		tmp = (x * x) + ((y * 4.0) * (t - (z * z)));
	} else {
		tmp = (x * x) - (4.0 * t_1);
	}
	return tmp;
}
def code(x, y, z, t):
	return (x * x) - ((y * 4.0) * ((z * z) - t))
def code(x, y, z, t):
	t_1 = z * (z * y)
	tmp = 0
	if z <= -1.3e+154:
		tmp = -4.0 * t_1
	elif z <= 2e+115:
		tmp = (x * x) + ((y * 4.0) * (t - (z * z)))
	else:
		tmp = (x * x) - (4.0 * t_1)
	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)
	t_1 = Float64(z * Float64(z * y))
	tmp = 0.0
	if (z <= -1.3e+154)
		tmp = Float64(-4.0 * t_1);
	elseif (z <= 2e+115)
		tmp = Float64(Float64(x * x) + Float64(Float64(y * 4.0) * Float64(t - Float64(z * z))));
	else
		tmp = Float64(Float64(x * x) - Float64(4.0 * t_1));
	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)
	t_1 = z * (z * y);
	tmp = 0.0;
	if (z <= -1.3e+154)
		tmp = -4.0 * t_1;
	elseif (z <= 2e+115)
		tmp = (x * x) + ((y * 4.0) * (t - (z * z)));
	else
		tmp = (x * x) - (4.0 * t_1);
	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_] := Block[{t$95$1 = N[(z * N[(z * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.3e+154], N[(-4.0 * t$95$1), $MachinePrecision], If[LessEqual[z, 2e+115], 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[(4.0 * t$95$1), $MachinePrecision]), $MachinePrecision]]]]
x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)
\begin{array}{l}
t_1 := z \cdot \left(z \cdot y\right)\\
\mathbf{if}\;z \leq -1.3 \cdot 10^{+154}:\\
\;\;\;\;-4 \cdot t_1\\

\mathbf{elif}\;z \leq 2 \cdot 10^{+115}:\\
\;\;\;\;x \cdot x + \left(y \cdot 4\right) \cdot \left(t - z \cdot z\right)\\

\mathbf{else}:\\
\;\;\;\;x \cdot x - 4 \cdot t_1\\


\end{array}

Error?

Bogosity?

Bogosity

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original91.0%
Target91.0%
Herbie95.5%
\[x \cdot x - 4 \cdot \left(y \cdot \left(z \cdot z - t\right)\right) \]

Derivation?

  1. Split input into 3 regimes
  2. if z < -1.29999999999999994e154

    1. Initial program 74.2%

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

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

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

      [Start]84.7

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

      unpow2 [=>]84.7

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

      *-commutative [=>]84.7

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

      associate-*l* [=>]92.1

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

    if -1.29999999999999994e154 < z < 2e115

    1. Initial program 97.1%

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

    if 2e115 < z

    1. Initial program 78.8%

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

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

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

      [Start]78.8

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

      unpow2 [=>]78.8

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

      *-commutative [=>]78.8

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

      associate-*l* [=>]95.1

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

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

Alternatives

Alternative 1
Accuracy96.6%
Cost7364
\[\begin{array}{l} \mathbf{if}\;z \cdot z \leq 2 \cdot 10^{+302}:\\ \;\;\;\;\mathsf{fma}\left(x, x, \left(z \cdot z - t\right) \cdot \left(y \cdot -4\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot x - 4 \cdot \left(z \cdot \left(z \cdot y\right)\right)\\ \end{array} \]
Alternative 2
Accuracy61.1%
Cost1228
\[\begin{array}{l} t_1 := -4 \cdot \left(z \cdot \left(z \cdot y\right)\right)\\ \mathbf{if}\;x \cdot x \leq 1.4 \cdot 10^{-142}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \cdot x \leq 8 \cdot 10^{-120}:\\ \;\;\;\;t \cdot \left(y \cdot 4\right)\\ \mathbf{elif}\;x \cdot x \leq 1.52 \cdot 10^{+44}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x \cdot x\\ \end{array} \]
Alternative 3
Accuracy78.6%
Cost1105
\[\begin{array}{l} \mathbf{if}\;x \leq -2.15 \cdot 10^{+144}:\\ \;\;\;\;x \cdot x\\ \mathbf{elif}\;x \leq -2.7 \cdot 10^{+80} \lor \neg \left(x \leq -1.25 \cdot 10^{-5}\right) \land x \leq 2 \cdot 10^{+28}:\\ \;\;\;\;-4 \cdot \left(\left(z \cdot z - t\right) \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot x\\ \end{array} \]
Alternative 4
Accuracy83.6%
Cost1096
\[\begin{array}{l} \mathbf{if}\;x \cdot x \leq 7.2 \cdot 10^{+41}:\\ \;\;\;\;-4 \cdot \left(\left(z \cdot z - t\right) \cdot y\right)\\ \mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{+300}:\\ \;\;\;\;x \cdot x - t \cdot \left(y \cdot -4\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot x\\ \end{array} \]
Alternative 5
Accuracy88.5%
Cost969
\[\begin{array}{l} \mathbf{if}\;z \leq -2.4 \cdot 10^{-75} \lor \neg \left(z \leq 3.7 \cdot 10^{-33}\right):\\ \;\;\;\;x \cdot x - 4 \cdot \left(z \cdot \left(z \cdot y\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot x - t \cdot \left(y \cdot -4\right)\\ \end{array} \]
Alternative 6
Accuracy58.9%
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -2.7 \cdot 10^{-7}:\\ \;\;\;\;x \cdot x\\ \mathbf{elif}\;x \leq 6.5 \cdot 10^{-13}:\\ \;\;\;\;t \cdot \left(y \cdot 4\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot x\\ \end{array} \]
Alternative 7
Accuracy41.0%
Cost192
\[x \cdot x \]

Error

Reproduce?

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