
(FPCore (x y z t) :precision binary64 (- (* x x) (* (* y 4.0) (- (* z z) t))))
double code(double x, double y, double z, double t) {
return (x * x) - ((y * 4.0) * ((z * z) - t));
}
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
public static double code(double x, double y, double z, double t) {
return (x * x) - ((y * 4.0) * ((z * z) - t));
}
def code(x, y, z, t): return (x * x) - ((y * 4.0) * ((z * z) - t))
function code(x, y, z, t) return Float64(Float64(x * x) - Float64(Float64(y * 4.0) * Float64(Float64(z * z) - t))) end
function tmp = code(x, y, z, t) tmp = (x * x) - ((y * 4.0) * ((z * z) - t)); 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]
\begin{array}{l}
\\
x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (- (* x x) (* (* y 4.0) (- (* z z) t))))
double code(double x, double y, double z, double t) {
return (x * x) - ((y * 4.0) * ((z * z) - t));
}
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
public static double code(double x, double y, double z, double t) {
return (x * x) - ((y * 4.0) * ((z * z) - t));
}
def code(x, y, z, t): return (x * x) - ((y * 4.0) * ((z * z) - t))
function code(x, y, z, t) return Float64(Float64(x * x) - Float64(Float64(y * 4.0) * Float64(Float64(z * z) - t))) end
function tmp = code(x, y, z, t) tmp = (x * x) - ((y * 4.0) * ((z * z) - t)); 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]
\begin{array}{l}
\\
x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)
\end{array}
(FPCore (x y z t) :precision binary64 (if (<= (* z z) 5e+288) (fma x x (* (- (* z z) t) (* y -4.0))) (- (* x x) (* z (* z (* y 4.0))))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z * z) <= 5e+288) {
tmp = fma(x, x, (((z * z) - t) * (y * -4.0)));
} else {
tmp = (x * x) - (z * (z * (y * 4.0)));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(z * z) <= 5e+288) tmp = fma(x, x, Float64(Float64(Float64(z * z) - t) * Float64(y * -4.0))); else tmp = Float64(Float64(x * x) - Float64(z * Float64(z * Float64(y * 4.0)))); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(z * z), $MachinePrecision], 5e+288], N[(x * x + N[(N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision] * N[(y * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] - N[(z * N[(z * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 5 \cdot 10^{+288}:\\
\;\;\;\;\mathsf{fma}\left(x, x, \left(z \cdot z - t\right) \cdot \left(y \cdot -4\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x - z \cdot \left(z \cdot \left(y \cdot 4\right)\right)\\
\end{array}
\end{array}
if (*.f64 z z) < 5.0000000000000003e288Initial program 97.7%
fma-neg98.8%
*-commutative98.8%
distribute-rgt-neg-in98.8%
distribute-rgt-neg-in98.8%
metadata-eval98.8%
Simplified98.8%
if 5.0000000000000003e288 < (*.f64 z z) Initial program 69.8%
Taylor expanded in z around inf 69.8%
*-commutative69.8%
unpow269.8%
*-commutative69.8%
associate-*r*69.8%
associate-*l*86.5%
*-commutative86.5%
Simplified86.5%
Final simplification95.3%
(FPCore (x y z t) :precision binary64 (if (<= (- (* z z) t) 2e+285) (+ (* 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) {
double tmp;
if (((z * z) - t) <= 2e+285) {
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
real(8) :: tmp
if (((z * z) - t) <= 2d+285) 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) {
double tmp;
if (((z * z) - t) <= 2e+285) {
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): tmp = 0 if ((z * z) - t) <= 2e+285: 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) tmp = 0.0 if (Float64(Float64(z * z) - t) <= 2e+285) tmp = Float64(Float64(x * x) + Float64(Float64(y * 4.0) * Float64(t - Float64(z * z)))); else tmp = Float64(Float64(x * x) - Float64(z * Float64(z * Float64(y * 4.0)))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (((z * z) - t) <= 2e+285) 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_] := If[LessEqual[N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision], 2e+285], 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[(z * N[(z * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z - t \leq 2 \cdot 10^{+285}:\\
\;\;\;\;x \cdot x + \left(y \cdot 4\right) \cdot \left(t - z \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x - z \cdot \left(z \cdot \left(y \cdot 4\right)\right)\\
\end{array}
\end{array}
if (-.f64 (*.f64 z z) t) < 2e285Initial program 98.3%
if 2e285 < (-.f64 (*.f64 z z) t) Initial program 68.9%
Taylor expanded in z around inf 68.9%
*-commutative68.9%
unpow268.9%
*-commutative68.9%
associate-*r*68.9%
associate-*l*85.3%
*-commutative85.3%
Simplified85.3%
Final simplification94.5%
(FPCore (x y z t) :precision binary64 (if (<= (* x x) 0.0) (* t (* y 4.0)) (if (<= (* x x) 1250000000000.0) (* -4.0 (* (* z z) y)) (* x x))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x * x) <= 0.0) {
tmp = t * (y * 4.0);
} else if ((x * x) <= 1250000000000.0) {
tmp = -4.0 * ((z * z) * y);
} else {
tmp = x * x;
}
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
real(8) :: tmp
if ((x * x) <= 0.0d0) then
tmp = t * (y * 4.0d0)
else if ((x * x) <= 1250000000000.0d0) then
tmp = (-4.0d0) * ((z * z) * y)
else
tmp = x * x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x * x) <= 0.0) {
tmp = t * (y * 4.0);
} else if ((x * x) <= 1250000000000.0) {
tmp = -4.0 * ((z * z) * y);
} else {
tmp = x * x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x * x) <= 0.0: tmp = t * (y * 4.0) elif (x * x) <= 1250000000000.0: tmp = -4.0 * ((z * z) * y) else: tmp = x * x return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x * x) <= 0.0) tmp = Float64(t * Float64(y * 4.0)); elseif (Float64(x * x) <= 1250000000000.0) tmp = Float64(-4.0 * Float64(Float64(z * z) * y)); else tmp = Float64(x * x); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x * x) <= 0.0) tmp = t * (y * 4.0); elseif ((x * x) <= 1250000000000.0) tmp = -4.0 * ((z * z) * y); else tmp = x * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x * x), $MachinePrecision], 0.0], N[(t * N[(y * 4.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 1250000000000.0], N[(-4.0 * N[(N[(z * z), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], N[(x * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 0:\\
\;\;\;\;t \cdot \left(y \cdot 4\right)\\
\mathbf{elif}\;x \cdot x \leq 1250000000000:\\
\;\;\;\;-4 \cdot \left(\left(z \cdot z\right) \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x\\
\end{array}
\end{array}
if (*.f64 x x) < 0.0Initial program 93.8%
Taylor expanded in t around inf 58.2%
associate-*r*58.2%
Simplified58.2%
if 0.0 < (*.f64 x x) < 1.25e12Initial program 94.7%
Taylor expanded in z around inf 53.8%
unpow253.8%
Simplified53.8%
if 1.25e12 < (*.f64 x x) Initial program 85.9%
Taylor expanded in x around inf 74.0%
unpow274.0%
Simplified74.0%
Final simplification65.9%
(FPCore (x y z t) :precision binary64 (if (<= (* z z) 1e+17) (- (* x x) (* t (* y -4.0))) (- (* x x) (* z (* z (* y 4.0))))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z * z) <= 1e+17) {
tmp = (x * x) - (t * (y * -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
real(8) :: tmp
if ((z * z) <= 1d+17) then
tmp = (x * x) - (t * (y * (-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) {
double tmp;
if ((z * z) <= 1e+17) {
tmp = (x * x) - (t * (y * -4.0));
} else {
tmp = (x * x) - (z * (z * (y * 4.0)));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z * z) <= 1e+17: tmp = (x * x) - (t * (y * -4.0)) else: tmp = (x * x) - (z * (z * (y * 4.0))) return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(z * z) <= 1e+17) tmp = Float64(Float64(x * x) - Float64(t * Float64(y * -4.0))); else tmp = Float64(Float64(x * x) - Float64(z * Float64(z * Float64(y * 4.0)))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z * z) <= 1e+17) tmp = (x * x) - (t * (y * -4.0)); else tmp = (x * x) - (z * (z * (y * 4.0))); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(z * z), $MachinePrecision], 1e+17], N[(N[(x * x), $MachinePrecision] - N[(t * N[(y * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] - N[(z * N[(z * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 10^{+17}:\\
\;\;\;\;x \cdot x - t \cdot \left(y \cdot -4\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x - z \cdot \left(z \cdot \left(y \cdot 4\right)\right)\\
\end{array}
\end{array}
if (*.f64 z z) < 1e17Initial program 98.4%
Taylor expanded in z around 0 94.2%
associate-*r*94.2%
Simplified94.2%
if 1e17 < (*.f64 z z) Initial program 81.3%
Taylor expanded in z around inf 72.8%
*-commutative72.8%
unpow272.8%
*-commutative72.8%
associate-*r*72.8%
associate-*l*82.2%
*-commutative82.2%
Simplified82.2%
Final simplification88.1%
(FPCore (x y z t)
:precision binary64
(if (<= z -8.6e+24)
(* -4.0 (* z (* z y)))
(if (<= z 3.4e+104)
(- (* x x) (* t (* y -4.0)))
(* (- (* z z) t) (* y -4.0)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -8.6e+24) {
tmp = -4.0 * (z * (z * y));
} else if (z <= 3.4e+104) {
tmp = (x * x) - (t * (y * -4.0));
} else {
tmp = ((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
real(8) :: tmp
if (z <= (-8.6d+24)) then
tmp = (-4.0d0) * (z * (z * y))
else if (z <= 3.4d+104) then
tmp = (x * x) - (t * (y * (-4.0d0)))
else
tmp = ((z * z) - t) * (y * (-4.0d0))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -8.6e+24) {
tmp = -4.0 * (z * (z * y));
} else if (z <= 3.4e+104) {
tmp = (x * x) - (t * (y * -4.0));
} else {
tmp = ((z * z) - t) * (y * -4.0);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -8.6e+24: tmp = -4.0 * (z * (z * y)) elif z <= 3.4e+104: tmp = (x * x) - (t * (y * -4.0)) else: tmp = ((z * z) - t) * (y * -4.0) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -8.6e+24) tmp = Float64(-4.0 * Float64(z * Float64(z * y))); elseif (z <= 3.4e+104) tmp = Float64(Float64(x * x) - Float64(t * Float64(y * -4.0))); else tmp = Float64(Float64(Float64(z * z) - t) * Float64(y * -4.0)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -8.6e+24) tmp = -4.0 * (z * (z * y)); elseif (z <= 3.4e+104) tmp = (x * x) - (t * (y * -4.0)); else tmp = ((z * z) - t) * (y * -4.0); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -8.6e+24], N[(-4.0 * N[(z * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 3.4e+104], N[(N[(x * x), $MachinePrecision] - N[(t * N[(y * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision] * N[(y * -4.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8.6 \cdot 10^{+24}:\\
\;\;\;\;-4 \cdot \left(z \cdot \left(z \cdot y\right)\right)\\
\mathbf{elif}\;z \leq 3.4 \cdot 10^{+104}:\\
\;\;\;\;x \cdot x - t \cdot \left(y \cdot -4\right)\\
\mathbf{else}:\\
\;\;\;\;\left(z \cdot z - t\right) \cdot \left(y \cdot -4\right)\\
\end{array}
\end{array}
if z < -8.59999999999999975e24Initial program 75.1%
Taylor expanded in z around inf 72.3%
unpow272.3%
*-commutative72.3%
associate-*l*78.2%
Simplified78.2%
if -8.59999999999999975e24 < z < 3.3999999999999997e104Initial program 98.6%
Taylor expanded in z around 0 91.0%
associate-*r*91.0%
Simplified91.0%
if 3.3999999999999997e104 < z Initial program 81.0%
Taylor expanded in x around 0 83.3%
*-commutative83.3%
*-commutative83.3%
unpow283.3%
*-commutative83.3%
associate-*l*83.3%
Simplified83.3%
Final simplification86.5%
(FPCore (x y z t) :precision binary64 (if (<= (* x x) 4.5e+53) (* (- (* z z) t) (* y -4.0)) (* x x)))
double code(double x, double y, double z, double t) {
double tmp;
if ((x * x) <= 4.5e+53) {
tmp = ((z * z) - t) * (y * -4.0);
} else {
tmp = x * x;
}
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
real(8) :: tmp
if ((x * x) <= 4.5d+53) then
tmp = ((z * z) - t) * (y * (-4.0d0))
else
tmp = x * x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x * x) <= 4.5e+53) {
tmp = ((z * z) - t) * (y * -4.0);
} else {
tmp = x * x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x * x) <= 4.5e+53: tmp = ((z * z) - t) * (y * -4.0) else: tmp = x * x return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x * x) <= 4.5e+53) tmp = Float64(Float64(Float64(z * z) - t) * Float64(y * -4.0)); else tmp = Float64(x * x); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x * x) <= 4.5e+53) tmp = ((z * z) - t) * (y * -4.0); else tmp = x * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x * x), $MachinePrecision], 4.5e+53], N[(N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision] * N[(y * -4.0), $MachinePrecision]), $MachinePrecision], N[(x * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 4.5 \cdot 10^{+53}:\\
\;\;\;\;\left(z \cdot z - t\right) \cdot \left(y \cdot -4\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x\\
\end{array}
\end{array}
if (*.f64 x x) < 4.5000000000000002e53Initial program 94.0%
Taylor expanded in x around 0 85.7%
*-commutative85.7%
*-commutative85.7%
unpow285.7%
*-commutative85.7%
associate-*l*85.7%
Simplified85.7%
if 4.5000000000000002e53 < (*.f64 x x) Initial program 85.3%
Taylor expanded in x around inf 77.5%
unpow277.5%
Simplified77.5%
Final simplification81.6%
(FPCore (x y z t) :precision binary64 (if (<= (* x x) 4.8e+19) (* -4.0 (* z (* z y))) (* x x)))
double code(double x, double y, double z, double t) {
double tmp;
if ((x * x) <= 4.8e+19) {
tmp = -4.0 * (z * (z * y));
} else {
tmp = x * x;
}
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
real(8) :: tmp
if ((x * x) <= 4.8d+19) then
tmp = (-4.0d0) * (z * (z * y))
else
tmp = x * x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x * x) <= 4.8e+19) {
tmp = -4.0 * (z * (z * y));
} else {
tmp = x * x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x * x) <= 4.8e+19: tmp = -4.0 * (z * (z * y)) else: tmp = x * x return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x * x) <= 4.8e+19) tmp = Float64(-4.0 * Float64(z * Float64(z * y))); else tmp = Float64(x * x); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x * x) <= 4.8e+19) tmp = -4.0 * (z * (z * y)); else tmp = x * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x * x), $MachinePrecision], 4.8e+19], N[(-4.0 * N[(z * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 4.8 \cdot 10^{+19}:\\
\;\;\;\;-4 \cdot \left(z \cdot \left(z \cdot y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x\\
\end{array}
\end{array}
if (*.f64 x x) < 4.8e19Initial program 94.2%
Taylor expanded in z around inf 50.3%
unpow250.3%
*-commutative50.3%
associate-*l*56.0%
Simplified56.0%
if 4.8e19 < (*.f64 x x) Initial program 85.9%
Taylor expanded in x around inf 74.0%
unpow274.0%
Simplified74.0%
Final simplification65.8%
(FPCore (x y z t) :precision binary64 (if (<= (* x x) 1.42e+20) (* t (* y 4.0)) (* x x)))
double code(double x, double y, double z, double t) {
double tmp;
if ((x * x) <= 1.42e+20) {
tmp = t * (y * 4.0);
} else {
tmp = x * x;
}
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
real(8) :: tmp
if ((x * x) <= 1.42d+20) then
tmp = t * (y * 4.0d0)
else
tmp = x * x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x * x) <= 1.42e+20) {
tmp = t * (y * 4.0);
} else {
tmp = x * x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x * x) <= 1.42e+20: tmp = t * (y * 4.0) else: tmp = x * x return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x * x) <= 1.42e+20) tmp = Float64(t * Float64(y * 4.0)); else tmp = Float64(x * x); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x * x) <= 1.42e+20) tmp = t * (y * 4.0); else tmp = x * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x * x), $MachinePrecision], 1.42e+20], N[(t * N[(y * 4.0), $MachinePrecision]), $MachinePrecision], N[(x * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 1.42 \cdot 10^{+20}:\\
\;\;\;\;t \cdot \left(y \cdot 4\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x\\
\end{array}
\end{array}
if (*.f64 x x) < 1.42e20Initial program 94.3%
Taylor expanded in t around inf 48.6%
associate-*r*48.6%
Simplified48.6%
if 1.42e20 < (*.f64 x x) Initial program 85.8%
Taylor expanded in x around inf 74.5%
unpow274.5%
Simplified74.5%
Final simplification62.7%
(FPCore (x y z t) :precision binary64 (* x x))
double code(double x, double y, double z, double t) {
return x * x;
}
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
end function
public static double code(double x, double y, double z, double t) {
return x * x;
}
def code(x, y, z, t): return x * x
function code(x, y, z, t) return Float64(x * x) end
function tmp = code(x, y, z, t) tmp = x * x; end
code[x_, y_, z_, t_] := N[(x * x), $MachinePrecision]
\begin{array}{l}
\\
x \cdot x
\end{array}
Initial program 89.6%
Taylor expanded in x around inf 46.4%
unpow246.4%
Simplified46.4%
Final simplification46.4%
(FPCore (x y z t) :precision binary64 (- (* x x) (* 4.0 (* y (- (* z z) t)))))
double code(double x, double y, double z, double t) {
return (x * x) - (4.0 * (y * ((z * z) - t)));
}
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) - (4.0d0 * (y * ((z * z) - t)))
end function
public static double code(double x, double y, double z, double t) {
return (x * x) - (4.0 * (y * ((z * z) - t)));
}
def code(x, y, z, t): return (x * x) - (4.0 * (y * ((z * z) - t)))
function code(x, y, z, t) return Float64(Float64(x * x) - Float64(4.0 * Float64(y * Float64(Float64(z * z) - t)))) end
function tmp = code(x, y, z, t) tmp = (x * x) - (4.0 * (y * ((z * z) - t))); end
code[x_, y_, z_, t_] := N[(N[(x * x), $MachinePrecision] - N[(4.0 * N[(y * N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot x - 4 \cdot \left(y \cdot \left(z \cdot z - t\right)\right)
\end{array}
herbie shell --seed 2023185
(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))))