
(FPCore (x y z) :precision binary64 (+ (* x (cos y)) (* z (sin y))))
double code(double x, double y, double z) {
return (x * cos(y)) + (z * sin(y));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * cos(y)) + (z * sin(y))
end function
public static double code(double x, double y, double z) {
return (x * Math.cos(y)) + (z * Math.sin(y));
}
def code(x, y, z): return (x * math.cos(y)) + (z * math.sin(y))
function code(x, y, z) return Float64(Float64(x * cos(y)) + Float64(z * sin(y))) end
function tmp = code(x, y, z) tmp = (x * cos(y)) + (z * sin(y)); end
code[x_, y_, z_] := N[(N[(x * N[Cos[y], $MachinePrecision]), $MachinePrecision] + N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \cos y + z \cdot \sin y
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ (* x (cos y)) (* z (sin y))))
double code(double x, double y, double z) {
return (x * cos(y)) + (z * sin(y));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * cos(y)) + (z * sin(y))
end function
public static double code(double x, double y, double z) {
return (x * Math.cos(y)) + (z * Math.sin(y));
}
def code(x, y, z): return (x * math.cos(y)) + (z * math.sin(y))
function code(x, y, z) return Float64(Float64(x * cos(y)) + Float64(z * sin(y))) end
function tmp = code(x, y, z) tmp = (x * cos(y)) + (z * sin(y)); end
code[x_, y_, z_] := N[(N[(x * N[Cos[y], $MachinePrecision]), $MachinePrecision] + N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \cos y + z \cdot \sin y
\end{array}
(FPCore (x y z) :precision binary64 (+ (* x (cos y)) (* z (sin y))))
double code(double x, double y, double z) {
return (x * cos(y)) + (z * sin(y));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * cos(y)) + (z * sin(y))
end function
public static double code(double x, double y, double z) {
return (x * Math.cos(y)) + (z * Math.sin(y));
}
def code(x, y, z): return (x * math.cos(y)) + (z * math.sin(y))
function code(x, y, z) return Float64(Float64(x * cos(y)) + Float64(z * sin(y))) end
function tmp = code(x, y, z) tmp = (x * cos(y)) + (z * sin(y)); end
code[x_, y_, z_] := N[(N[(x * N[Cos[y], $MachinePrecision]), $MachinePrecision] + N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \cos y + z \cdot \sin y
\end{array}
Initial program 99.7%
(FPCore (x y z)
:precision binary64
(if (or (<= x -6.8e+183)
(not (or (<= x -5e+135) (and (not (<= x -1.75e+21)) (<= x 1e-11)))))
(* x (cos y))
(+ x (* z (sin y)))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -6.8e+183) || !((x <= -5e+135) || (!(x <= -1.75e+21) && (x <= 1e-11)))) {
tmp = x * cos(y);
} else {
tmp = x + (z * sin(y));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((x <= (-6.8d+183)) .or. (.not. (x <= (-5d+135)) .or. (.not. (x <= (-1.75d+21))) .and. (x <= 1d-11))) then
tmp = x * cos(y)
else
tmp = x + (z * sin(y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -6.8e+183) || !((x <= -5e+135) || (!(x <= -1.75e+21) && (x <= 1e-11)))) {
tmp = x * Math.cos(y);
} else {
tmp = x + (z * Math.sin(y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -6.8e+183) or not ((x <= -5e+135) or (not (x <= -1.75e+21) and (x <= 1e-11))): tmp = x * math.cos(y) else: tmp = x + (z * math.sin(y)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -6.8e+183) || !((x <= -5e+135) || (!(x <= -1.75e+21) && (x <= 1e-11)))) tmp = Float64(x * cos(y)); else tmp = Float64(x + Float64(z * sin(y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -6.8e+183) || ~(((x <= -5e+135) || (~((x <= -1.75e+21)) && (x <= 1e-11))))) tmp = x * cos(y); else tmp = x + (z * sin(y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -6.8e+183], N[Not[Or[LessEqual[x, -5e+135], And[N[Not[LessEqual[x, -1.75e+21]], $MachinePrecision], LessEqual[x, 1e-11]]]], $MachinePrecision]], N[(x * N[Cos[y], $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.8 \cdot 10^{+183} \lor \neg \left(x \leq -5 \cdot 10^{+135} \lor \neg \left(x \leq -1.75 \cdot 10^{+21}\right) \land x \leq 10^{-11}\right):\\
\;\;\;\;x \cdot \cos y\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \sin y\\
\end{array}
\end{array}
if x < -6.8e183 or -5.00000000000000029e135 < x < -1.75e21 or 9.99999999999999939e-12 < x Initial program 99.7%
Taylor expanded in x around inf 91.4%
if -6.8e183 < x < -5.00000000000000029e135 or -1.75e21 < x < 9.99999999999999939e-12Initial program 99.7%
Taylor expanded in y around 0 93.7%
Final simplification92.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (cos y))))
(if (<= x -9.5e+183)
t_0
(if (<= x -2.65e+129)
(* x (- (* (sin y) (/ z x)) -1.0))
(if (or (<= x -2.6e+22) (not (<= x 7.4e-13)))
t_0
(+ x (* z (sin y))))))))
double code(double x, double y, double z) {
double t_0 = x * cos(y);
double tmp;
if (x <= -9.5e+183) {
tmp = t_0;
} else if (x <= -2.65e+129) {
tmp = x * ((sin(y) * (z / x)) - -1.0);
} else if ((x <= -2.6e+22) || !(x <= 7.4e-13)) {
tmp = t_0;
} else {
tmp = x + (z * sin(y));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = x * cos(y)
if (x <= (-9.5d+183)) then
tmp = t_0
else if (x <= (-2.65d+129)) then
tmp = x * ((sin(y) * (z / x)) - (-1.0d0))
else if ((x <= (-2.6d+22)) .or. (.not. (x <= 7.4d-13))) then
tmp = t_0
else
tmp = x + (z * sin(y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * Math.cos(y);
double tmp;
if (x <= -9.5e+183) {
tmp = t_0;
} else if (x <= -2.65e+129) {
tmp = x * ((Math.sin(y) * (z / x)) - -1.0);
} else if ((x <= -2.6e+22) || !(x <= 7.4e-13)) {
tmp = t_0;
} else {
tmp = x + (z * Math.sin(y));
}
return tmp;
}
def code(x, y, z): t_0 = x * math.cos(y) tmp = 0 if x <= -9.5e+183: tmp = t_0 elif x <= -2.65e+129: tmp = x * ((math.sin(y) * (z / x)) - -1.0) elif (x <= -2.6e+22) or not (x <= 7.4e-13): tmp = t_0 else: tmp = x + (z * math.sin(y)) return tmp
function code(x, y, z) t_0 = Float64(x * cos(y)) tmp = 0.0 if (x <= -9.5e+183) tmp = t_0; elseif (x <= -2.65e+129) tmp = Float64(x * Float64(Float64(sin(y) * Float64(z / x)) - -1.0)); elseif ((x <= -2.6e+22) || !(x <= 7.4e-13)) tmp = t_0; else tmp = Float64(x + Float64(z * sin(y))); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * cos(y); tmp = 0.0; if (x <= -9.5e+183) tmp = t_0; elseif (x <= -2.65e+129) tmp = x * ((sin(y) * (z / x)) - -1.0); elseif ((x <= -2.6e+22) || ~((x <= 7.4e-13))) tmp = t_0; else tmp = x + (z * sin(y)); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[Cos[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -9.5e+183], t$95$0, If[LessEqual[x, -2.65e+129], N[(x * N[(N[(N[Sin[y], $MachinePrecision] * N[(z / x), $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[x, -2.6e+22], N[Not[LessEqual[x, 7.4e-13]], $MachinePrecision]], t$95$0, N[(x + N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \cos y\\
\mathbf{if}\;x \leq -9.5 \cdot 10^{+183}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -2.65 \cdot 10^{+129}:\\
\;\;\;\;x \cdot \left(\sin y \cdot \frac{z}{x} - -1\right)\\
\mathbf{elif}\;x \leq -2.6 \cdot 10^{+22} \lor \neg \left(x \leq 7.4 \cdot 10^{-13}\right):\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \sin y\\
\end{array}
\end{array}
if x < -9.5000000000000003e183 or -2.6499999999999999e129 < x < -2.6e22 or 7.39999999999999977e-13 < x Initial program 99.7%
Taylor expanded in x around inf 91.4%
if -9.5000000000000003e183 < x < -2.6499999999999999e129Initial program 99.6%
Taylor expanded in y around 0 82.4%
Taylor expanded in x around -inf 82.4%
mul-1-neg82.4%
*-commutative82.4%
distribute-rgt-neg-in82.4%
sub-neg82.4%
metadata-eval82.4%
+-commutative82.4%
mul-1-neg82.4%
unsub-neg82.4%
*-commutative82.4%
associate-/l*82.7%
Simplified82.7%
if -2.6e22 < x < 7.39999999999999977e-13Initial program 99.7%
Taylor expanded in y around 0 94.8%
Final simplification92.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (cos y))) (t_1 (* z (sin y))))
(if (<= x -180000000000.0)
t_0
(if (<= x -5.7e-92)
t_1
(if (<= x -2e-141) (fma y z x) (if (<= x 1.6e-109) t_1 t_0))))))
double code(double x, double y, double z) {
double t_0 = x * cos(y);
double t_1 = z * sin(y);
double tmp;
if (x <= -180000000000.0) {
tmp = t_0;
} else if (x <= -5.7e-92) {
tmp = t_1;
} else if (x <= -2e-141) {
tmp = fma(y, z, x);
} else if (x <= 1.6e-109) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(x * cos(y)) t_1 = Float64(z * sin(y)) tmp = 0.0 if (x <= -180000000000.0) tmp = t_0; elseif (x <= -5.7e-92) tmp = t_1; elseif (x <= -2e-141) tmp = fma(y, z, x); elseif (x <= 1.6e-109) tmp = t_1; else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[Cos[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -180000000000.0], t$95$0, If[LessEqual[x, -5.7e-92], t$95$1, If[LessEqual[x, -2e-141], N[(y * z + x), $MachinePrecision], If[LessEqual[x, 1.6e-109], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \cos y\\
t_1 := z \cdot \sin y\\
\mathbf{if}\;x \leq -180000000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -5.7 \cdot 10^{-92}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -2 \cdot 10^{-141}:\\
\;\;\;\;\mathsf{fma}\left(y, z, x\right)\\
\mathbf{elif}\;x \leq 1.6 \cdot 10^{-109}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.8e11 or 1.6000000000000001e-109 < x Initial program 99.7%
Taylor expanded in x around inf 84.4%
if -1.8e11 < x < -5.70000000000000009e-92 or -2.0000000000000001e-141 < x < 1.6000000000000001e-109Initial program 99.7%
Taylor expanded in x around 0 74.2%
if -5.70000000000000009e-92 < x < -2.0000000000000001e-141Initial program 99.9%
Taylor expanded in y around 0 84.5%
+-commutative84.5%
fma-define84.5%
Simplified84.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (cos y))) (t_1 (* z (sin y))))
(if (<= x -10000000000000.0)
t_0
(if (<= x -5.7e-92)
t_1
(if (<= x -1e-141)
(+ x (* y (+ z (* y (* x -0.5)))))
(if (<= x 1.3e-110) t_1 t_0))))))
double code(double x, double y, double z) {
double t_0 = x * cos(y);
double t_1 = z * sin(y);
double tmp;
if (x <= -10000000000000.0) {
tmp = t_0;
} else if (x <= -5.7e-92) {
tmp = t_1;
} else if (x <= -1e-141) {
tmp = x + (y * (z + (y * (x * -0.5))));
} else if (x <= 1.3e-110) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x * cos(y)
t_1 = z * sin(y)
if (x <= (-10000000000000.0d0)) then
tmp = t_0
else if (x <= (-5.7d-92)) then
tmp = t_1
else if (x <= (-1d-141)) then
tmp = x + (y * (z + (y * (x * (-0.5d0)))))
else if (x <= 1.3d-110) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * Math.cos(y);
double t_1 = z * Math.sin(y);
double tmp;
if (x <= -10000000000000.0) {
tmp = t_0;
} else if (x <= -5.7e-92) {
tmp = t_1;
} else if (x <= -1e-141) {
tmp = x + (y * (z + (y * (x * -0.5))));
} else if (x <= 1.3e-110) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * math.cos(y) t_1 = z * math.sin(y) tmp = 0 if x <= -10000000000000.0: tmp = t_0 elif x <= -5.7e-92: tmp = t_1 elif x <= -1e-141: tmp = x + (y * (z + (y * (x * -0.5)))) elif x <= 1.3e-110: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * cos(y)) t_1 = Float64(z * sin(y)) tmp = 0.0 if (x <= -10000000000000.0) tmp = t_0; elseif (x <= -5.7e-92) tmp = t_1; elseif (x <= -1e-141) tmp = Float64(x + Float64(y * Float64(z + Float64(y * Float64(x * -0.5))))); elseif (x <= 1.3e-110) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * cos(y); t_1 = z * sin(y); tmp = 0.0; if (x <= -10000000000000.0) tmp = t_0; elseif (x <= -5.7e-92) tmp = t_1; elseif (x <= -1e-141) tmp = x + (y * (z + (y * (x * -0.5)))); elseif (x <= 1.3e-110) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[Cos[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -10000000000000.0], t$95$0, If[LessEqual[x, -5.7e-92], t$95$1, If[LessEqual[x, -1e-141], N[(x + N[(y * N[(z + N[(y * N[(x * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.3e-110], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \cos y\\
t_1 := z \cdot \sin y\\
\mathbf{if}\;x \leq -10000000000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -5.7 \cdot 10^{-92}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -1 \cdot 10^{-141}:\\
\;\;\;\;x + y \cdot \left(z + y \cdot \left(x \cdot -0.5\right)\right)\\
\mathbf{elif}\;x \leq 1.3 \cdot 10^{-110}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1e13 or 1.29999999999999995e-110 < x Initial program 99.7%
Taylor expanded in x around inf 84.4%
if -1e13 < x < -5.70000000000000009e-92 or -1e-141 < x < 1.29999999999999995e-110Initial program 99.7%
Taylor expanded in x around 0 74.2%
if -5.70000000000000009e-92 < x < -1e-141Initial program 99.9%
*-commutative99.9%
add-cube-cbrt98.7%
associate-*r*98.7%
fma-define98.7%
pow298.7%
Applied egg-rr98.7%
Taylor expanded in y around 0 84.5%
associate-*r*84.5%
*-commutative84.5%
Simplified84.5%
Final simplification80.5%
(FPCore (x y z) :precision binary64 (if (or (<= y -0.00075) (not (<= y 33000.0))) (* x (cos y)) (+ x (* y (+ z (* y (+ (* x -0.5) (* -0.16666666666666666 (* y z)))))))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -0.00075) || !(y <= 33000.0)) {
tmp = x * cos(y);
} else {
tmp = x + (y * (z + (y * ((x * -0.5) + (-0.16666666666666666 * (y * z))))));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((y <= (-0.00075d0)) .or. (.not. (y <= 33000.0d0))) then
tmp = x * cos(y)
else
tmp = x + (y * (z + (y * ((x * (-0.5d0)) + ((-0.16666666666666666d0) * (y * z))))))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -0.00075) || !(y <= 33000.0)) {
tmp = x * Math.cos(y);
} else {
tmp = x + (y * (z + (y * ((x * -0.5) + (-0.16666666666666666 * (y * z))))));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -0.00075) or not (y <= 33000.0): tmp = x * math.cos(y) else: tmp = x + (y * (z + (y * ((x * -0.5) + (-0.16666666666666666 * (y * z)))))) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -0.00075) || !(y <= 33000.0)) tmp = Float64(x * cos(y)); else tmp = Float64(x + Float64(y * Float64(z + Float64(y * Float64(Float64(x * -0.5) + Float64(-0.16666666666666666 * Float64(y * z))))))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -0.00075) || ~((y <= 33000.0))) tmp = x * cos(y); else tmp = x + (y * (z + (y * ((x * -0.5) + (-0.16666666666666666 * (y * z)))))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -0.00075], N[Not[LessEqual[y, 33000.0]], $MachinePrecision]], N[(x * N[Cos[y], $MachinePrecision]), $MachinePrecision], N[(x + N[(y * N[(z + N[(y * N[(N[(x * -0.5), $MachinePrecision] + N[(-0.16666666666666666 * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -0.00075 \lor \neg \left(y \leq 33000\right):\\
\;\;\;\;x \cdot \cos y\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \left(z + y \cdot \left(x \cdot -0.5 + -0.16666666666666666 \cdot \left(y \cdot z\right)\right)\right)\\
\end{array}
\end{array}
if y < -7.5000000000000002e-4 or 33000 < y Initial program 99.5%
Taylor expanded in x around inf 54.0%
if -7.5000000000000002e-4 < y < 33000Initial program 100.0%
Taylor expanded in y around 0 99.3%
Final simplification76.1%
(FPCore (x y z) :precision binary64 (if (or (<= z -2.5e+212) (not (<= z 6e+112))) (* y z) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2.5e+212) || !(z <= 6e+112)) {
tmp = y * z;
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-2.5d+212)) .or. (.not. (z <= 6d+112))) then
tmp = y * z
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -2.5e+212) || !(z <= 6e+112)) {
tmp = y * z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2.5e+212) or not (z <= 6e+112): tmp = y * z else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -2.5e+212) || !(z <= 6e+112)) tmp = Float64(y * z); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -2.5e+212) || ~((z <= 6e+112))) tmp = y * z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -2.5e+212], N[Not[LessEqual[z, 6e+112]], $MachinePrecision]], N[(y * z), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.5 \cdot 10^{+212} \lor \neg \left(z \leq 6 \cdot 10^{+112}\right):\\
\;\;\;\;y \cdot z\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -2.49999999999999996e212 or 5.99999999999999958e112 < z Initial program 99.7%
Taylor expanded in y around 0 50.3%
+-commutative50.3%
Simplified50.3%
Taylor expanded in y around inf 41.4%
if -2.49999999999999996e212 < z < 5.99999999999999958e112Initial program 99.7%
Taylor expanded in y around 0 52.2%
+-commutative52.2%
Simplified52.2%
Taylor expanded in z around inf 47.0%
Taylor expanded in z around 0 44.3%
Final simplification43.7%
(FPCore (x y z) :precision binary64 (+ x (* y z)))
double code(double x, double y, double z) {
return x + (y * z);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x + (y * z)
end function
public static double code(double x, double y, double z) {
return x + (y * z);
}
def code(x, y, z): return x + (y * z)
function code(x, y, z) return Float64(x + Float64(y * z)) end
function tmp = code(x, y, z) tmp = x + (y * z); end
code[x_, y_, z_] := N[(x + N[(y * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + y \cdot z
\end{array}
Initial program 99.7%
Taylor expanded in y around 0 51.8%
+-commutative51.8%
Simplified51.8%
Final simplification51.8%
(FPCore (x y z) :precision binary64 x)
double code(double x, double y, double z) {
return x;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x
end function
public static double code(double x, double y, double z) {
return x;
}
def code(x, y, z): return x
function code(x, y, z) return x end
function tmp = code(x, y, z) tmp = x; end
code[x_, y_, z_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 99.7%
Taylor expanded in y around 0 51.8%
+-commutative51.8%
Simplified51.8%
Taylor expanded in z around inf 47.7%
Taylor expanded in z around 0 37.4%
herbie shell --seed 2024103
(FPCore (x y z)
:name "Diagrams.ThreeD.Transform:aboutY from diagrams-lib-1.3.0.3"
:precision binary64
(+ (* x (cos y)) (* z (sin y))))