
(FPCore (x y z) :precision binary64 (+ (* x (sin y)) (* z (cos y))))
double code(double x, double y, double z) {
return (x * sin(y)) + (z * cos(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 * sin(y)) + (z * cos(y))
end function
public static double code(double x, double y, double z) {
return (x * Math.sin(y)) + (z * Math.cos(y));
}
def code(x, y, z): return (x * math.sin(y)) + (z * math.cos(y))
function code(x, y, z) return Float64(Float64(x * sin(y)) + Float64(z * cos(y))) end
function tmp = code(x, y, z) tmp = (x * sin(y)) + (z * cos(y)); end
code[x_, y_, z_] := N[(N[(x * N[Sin[y], $MachinePrecision]), $MachinePrecision] + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \sin y + z \cdot \cos y
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ (* x (sin y)) (* z (cos y))))
double code(double x, double y, double z) {
return (x * sin(y)) + (z * cos(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 * sin(y)) + (z * cos(y))
end function
public static double code(double x, double y, double z) {
return (x * Math.sin(y)) + (z * Math.cos(y));
}
def code(x, y, z): return (x * math.sin(y)) + (z * math.cos(y))
function code(x, y, z) return Float64(Float64(x * sin(y)) + Float64(z * cos(y))) end
function tmp = code(x, y, z) tmp = (x * sin(y)) + (z * cos(y)); end
code[x_, y_, z_] := N[(N[(x * N[Sin[y], $MachinePrecision]), $MachinePrecision] + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \sin y + z \cdot \cos y
\end{array}
(FPCore (x y z) :precision binary64 (fma x (sin y) (* z (cos y))))
double code(double x, double y, double z) {
return fma(x, sin(y), (z * cos(y)));
}
function code(x, y, z) return fma(x, sin(y), Float64(z * cos(y))) end
code[x_, y_, z_] := N[(x * N[Sin[y], $MachinePrecision] + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x, \sin y, z \cdot \cos y\right)
\end{array}
Initial program 99.8%
fma-define99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x y z) :precision binary64 (+ (* z (cos y)) (* x (sin y))))
double code(double x, double y, double z) {
return (z * cos(y)) + (x * 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 = (z * cos(y)) + (x * sin(y))
end function
public static double code(double x, double y, double z) {
return (z * Math.cos(y)) + (x * Math.sin(y));
}
def code(x, y, z): return (z * math.cos(y)) + (x * math.sin(y))
function code(x, y, z) return Float64(Float64(z * cos(y)) + Float64(x * sin(y))) end
function tmp = code(x, y, z) tmp = (z * cos(y)) + (x * sin(y)); end
code[x_, y_, z_] := N[(N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision] + N[(x * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
z \cdot \cos y + x \cdot \sin y
\end{array}
Initial program 99.8%
Final simplification99.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (sin y))) (t_1 (* z (cos y))))
(if (<= x -4.4e+111)
t_0
(if (<= x -2.05e+79)
t_1
(if (<= x -1.9e+56)
t_0
(if (<= x -1.32e-21)
(+ z (* x y))
(if (<= x 0.3)
t_1
(if (or (<= x 65000000000000.0) (not (<= x 2.6e+96)))
t_0
(* x (/ t_1 x))))))))))
double code(double x, double y, double z) {
double t_0 = x * sin(y);
double t_1 = z * cos(y);
double tmp;
if (x <= -4.4e+111) {
tmp = t_0;
} else if (x <= -2.05e+79) {
tmp = t_1;
} else if (x <= -1.9e+56) {
tmp = t_0;
} else if (x <= -1.32e-21) {
tmp = z + (x * y);
} else if (x <= 0.3) {
tmp = t_1;
} else if ((x <= 65000000000000.0) || !(x <= 2.6e+96)) {
tmp = t_0;
} else {
tmp = x * (t_1 / 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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x * sin(y)
t_1 = z * cos(y)
if (x <= (-4.4d+111)) then
tmp = t_0
else if (x <= (-2.05d+79)) then
tmp = t_1
else if (x <= (-1.9d+56)) then
tmp = t_0
else if (x <= (-1.32d-21)) then
tmp = z + (x * y)
else if (x <= 0.3d0) then
tmp = t_1
else if ((x <= 65000000000000.0d0) .or. (.not. (x <= 2.6d+96))) then
tmp = t_0
else
tmp = x * (t_1 / x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * Math.sin(y);
double t_1 = z * Math.cos(y);
double tmp;
if (x <= -4.4e+111) {
tmp = t_0;
} else if (x <= -2.05e+79) {
tmp = t_1;
} else if (x <= -1.9e+56) {
tmp = t_0;
} else if (x <= -1.32e-21) {
tmp = z + (x * y);
} else if (x <= 0.3) {
tmp = t_1;
} else if ((x <= 65000000000000.0) || !(x <= 2.6e+96)) {
tmp = t_0;
} else {
tmp = x * (t_1 / x);
}
return tmp;
}
def code(x, y, z): t_0 = x * math.sin(y) t_1 = z * math.cos(y) tmp = 0 if x <= -4.4e+111: tmp = t_0 elif x <= -2.05e+79: tmp = t_1 elif x <= -1.9e+56: tmp = t_0 elif x <= -1.32e-21: tmp = z + (x * y) elif x <= 0.3: tmp = t_1 elif (x <= 65000000000000.0) or not (x <= 2.6e+96): tmp = t_0 else: tmp = x * (t_1 / x) return tmp
function code(x, y, z) t_0 = Float64(x * sin(y)) t_1 = Float64(z * cos(y)) tmp = 0.0 if (x <= -4.4e+111) tmp = t_0; elseif (x <= -2.05e+79) tmp = t_1; elseif (x <= -1.9e+56) tmp = t_0; elseif (x <= -1.32e-21) tmp = Float64(z + Float64(x * y)); elseif (x <= 0.3) tmp = t_1; elseif ((x <= 65000000000000.0) || !(x <= 2.6e+96)) tmp = t_0; else tmp = Float64(x * Float64(t_1 / x)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * sin(y); t_1 = z * cos(y); tmp = 0.0; if (x <= -4.4e+111) tmp = t_0; elseif (x <= -2.05e+79) tmp = t_1; elseif (x <= -1.9e+56) tmp = t_0; elseif (x <= -1.32e-21) tmp = z + (x * y); elseif (x <= 0.3) tmp = t_1; elseif ((x <= 65000000000000.0) || ~((x <= 2.6e+96))) tmp = t_0; else tmp = x * (t_1 / x); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[Sin[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -4.4e+111], t$95$0, If[LessEqual[x, -2.05e+79], t$95$1, If[LessEqual[x, -1.9e+56], t$95$0, If[LessEqual[x, -1.32e-21], N[(z + N[(x * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.3], t$95$1, If[Or[LessEqual[x, 65000000000000.0], N[Not[LessEqual[x, 2.6e+96]], $MachinePrecision]], t$95$0, N[(x * N[(t$95$1 / x), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \sin y\\
t_1 := z \cdot \cos y\\
\mathbf{if}\;x \leq -4.4 \cdot 10^{+111}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -2.05 \cdot 10^{+79}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -1.9 \cdot 10^{+56}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -1.32 \cdot 10^{-21}:\\
\;\;\;\;z + x \cdot y\\
\mathbf{elif}\;x \leq 0.3:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 65000000000000 \lor \neg \left(x \leq 2.6 \cdot 10^{+96}\right):\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{t\_1}{x}\\
\end{array}
\end{array}
if x < -4.39999999999999997e111 or -2.05e79 < x < -1.89999999999999998e56 or 0.299999999999999989 < x < 6.5e13 or 2.6e96 < x Initial program 99.8%
Taylor expanded in x around inf 83.4%
if -4.39999999999999997e111 < x < -2.05e79 or -1.32e-21 < x < 0.299999999999999989Initial program 99.8%
Taylor expanded in x around 0 89.4%
if -1.89999999999999998e56 < x < -1.32e-21Initial program 100.0%
Taylor expanded in y around 0 76.0%
*-commutative76.0%
Simplified76.0%
if 6.5e13 < x < 2.6e96Initial program 99.8%
add-cbrt-cube52.4%
pow352.3%
Applied egg-rr52.3%
Taylor expanded in y around 0 29.2%
*-commutative29.2%
Simplified29.2%
Taylor expanded in x around inf 44.8%
Taylor expanded in z around inf 63.0%
Final simplification84.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (sin y))) (t_1 (* z (cos y))))
(if (<= x -6.6e+112)
t_0
(if (<= x -1.1e+79)
t_1
(if (<= x -1.3e+55)
t_0
(if (<= x -2.3e-23)
(+ z (* x y))
(if (or (<= x 0.03)
(and (not (<= x 60000000000000.0)) (<= x 4.5e+94)))
t_1
t_0)))))))
double code(double x, double y, double z) {
double t_0 = x * sin(y);
double t_1 = z * cos(y);
double tmp;
if (x <= -6.6e+112) {
tmp = t_0;
} else if (x <= -1.1e+79) {
tmp = t_1;
} else if (x <= -1.3e+55) {
tmp = t_0;
} else if (x <= -2.3e-23) {
tmp = z + (x * y);
} else if ((x <= 0.03) || (!(x <= 60000000000000.0) && (x <= 4.5e+94))) {
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 * sin(y)
t_1 = z * cos(y)
if (x <= (-6.6d+112)) then
tmp = t_0
else if (x <= (-1.1d+79)) then
tmp = t_1
else if (x <= (-1.3d+55)) then
tmp = t_0
else if (x <= (-2.3d-23)) then
tmp = z + (x * y)
else if ((x <= 0.03d0) .or. (.not. (x <= 60000000000000.0d0)) .and. (x <= 4.5d+94)) 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.sin(y);
double t_1 = z * Math.cos(y);
double tmp;
if (x <= -6.6e+112) {
tmp = t_0;
} else if (x <= -1.1e+79) {
tmp = t_1;
} else if (x <= -1.3e+55) {
tmp = t_0;
} else if (x <= -2.3e-23) {
tmp = z + (x * y);
} else if ((x <= 0.03) || (!(x <= 60000000000000.0) && (x <= 4.5e+94))) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * math.sin(y) t_1 = z * math.cos(y) tmp = 0 if x <= -6.6e+112: tmp = t_0 elif x <= -1.1e+79: tmp = t_1 elif x <= -1.3e+55: tmp = t_0 elif x <= -2.3e-23: tmp = z + (x * y) elif (x <= 0.03) or (not (x <= 60000000000000.0) and (x <= 4.5e+94)): tmp = t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * sin(y)) t_1 = Float64(z * cos(y)) tmp = 0.0 if (x <= -6.6e+112) tmp = t_0; elseif (x <= -1.1e+79) tmp = t_1; elseif (x <= -1.3e+55) tmp = t_0; elseif (x <= -2.3e-23) tmp = Float64(z + Float64(x * y)); elseif ((x <= 0.03) || (!(x <= 60000000000000.0) && (x <= 4.5e+94))) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * sin(y); t_1 = z * cos(y); tmp = 0.0; if (x <= -6.6e+112) tmp = t_0; elseif (x <= -1.1e+79) tmp = t_1; elseif (x <= -1.3e+55) tmp = t_0; elseif (x <= -2.3e-23) tmp = z + (x * y); elseif ((x <= 0.03) || (~((x <= 60000000000000.0)) && (x <= 4.5e+94))) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[Sin[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -6.6e+112], t$95$0, If[LessEqual[x, -1.1e+79], t$95$1, If[LessEqual[x, -1.3e+55], t$95$0, If[LessEqual[x, -2.3e-23], N[(z + N[(x * y), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[x, 0.03], And[N[Not[LessEqual[x, 60000000000000.0]], $MachinePrecision], LessEqual[x, 4.5e+94]]], t$95$1, t$95$0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \sin y\\
t_1 := z \cdot \cos y\\
\mathbf{if}\;x \leq -6.6 \cdot 10^{+112}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -1.1 \cdot 10^{+79}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -1.3 \cdot 10^{+55}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -2.3 \cdot 10^{-23}:\\
\;\;\;\;z + x \cdot y\\
\mathbf{elif}\;x \leq 0.03 \lor \neg \left(x \leq 60000000000000\right) \land x \leq 4.5 \cdot 10^{+94}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -6.5999999999999998e112 or -1.0999999999999999e79 < x < -1.3e55 or 0.029999999999999999 < x < 6e13 or 4.49999999999999972e94 < x Initial program 99.8%
Taylor expanded in x around inf 83.4%
if -6.5999999999999998e112 < x < -1.0999999999999999e79 or -2.3000000000000001e-23 < x < 0.029999999999999999 or 6e13 < x < 4.49999999999999972e94Initial program 99.8%
Taylor expanded in x around 0 86.3%
if -1.3e55 < x < -2.3000000000000001e-23Initial program 100.0%
Taylor expanded in y around 0 76.0%
*-commutative76.0%
Simplified76.0%
Final simplification84.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (cos y))) (t_1 (* z (+ 1.0 (* x (/ (sin y) z))))))
(if (<= z -9e+107)
t_0
(if (<= z -3.4e-186)
t_1
(if (<= z 2.1e-248) (* x (sin y)) (if (<= z 6.4e-15) t_1 t_0))))))
double code(double x, double y, double z) {
double t_0 = z * cos(y);
double t_1 = z * (1.0 + (x * (sin(y) / z)));
double tmp;
if (z <= -9e+107) {
tmp = t_0;
} else if (z <= -3.4e-186) {
tmp = t_1;
} else if (z <= 2.1e-248) {
tmp = x * sin(y);
} else if (z <= 6.4e-15) {
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 = z * cos(y)
t_1 = z * (1.0d0 + (x * (sin(y) / z)))
if (z <= (-9d+107)) then
tmp = t_0
else if (z <= (-3.4d-186)) then
tmp = t_1
else if (z <= 2.1d-248) then
tmp = x * sin(y)
else if (z <= 6.4d-15) 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 = z * Math.cos(y);
double t_1 = z * (1.0 + (x * (Math.sin(y) / z)));
double tmp;
if (z <= -9e+107) {
tmp = t_0;
} else if (z <= -3.4e-186) {
tmp = t_1;
} else if (z <= 2.1e-248) {
tmp = x * Math.sin(y);
} else if (z <= 6.4e-15) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = z * math.cos(y) t_1 = z * (1.0 + (x * (math.sin(y) / z))) tmp = 0 if z <= -9e+107: tmp = t_0 elif z <= -3.4e-186: tmp = t_1 elif z <= 2.1e-248: tmp = x * math.sin(y) elif z <= 6.4e-15: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(z * cos(y)) t_1 = Float64(z * Float64(1.0 + Float64(x * Float64(sin(y) / z)))) tmp = 0.0 if (z <= -9e+107) tmp = t_0; elseif (z <= -3.4e-186) tmp = t_1; elseif (z <= 2.1e-248) tmp = Float64(x * sin(y)); elseif (z <= 6.4e-15) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * cos(y); t_1 = z * (1.0 + (x * (sin(y) / z))); tmp = 0.0; if (z <= -9e+107) tmp = t_0; elseif (z <= -3.4e-186) tmp = t_1; elseif (z <= 2.1e-248) tmp = x * sin(y); elseif (z <= 6.4e-15) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(z * N[(1.0 + N[(x * N[(N[Sin[y], $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -9e+107], t$95$0, If[LessEqual[z, -3.4e-186], t$95$1, If[LessEqual[z, 2.1e-248], N[(x * N[Sin[y], $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 6.4e-15], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \cos y\\
t_1 := z \cdot \left(1 + x \cdot \frac{\sin y}{z}\right)\\
\mathbf{if}\;z \leq -9 \cdot 10^{+107}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -3.4 \cdot 10^{-186}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 2.1 \cdot 10^{-248}:\\
\;\;\;\;x \cdot \sin y\\
\mathbf{elif}\;z \leq 6.4 \cdot 10^{-15}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -9e107 or 6.3999999999999999e-15 < z Initial program 99.8%
Taylor expanded in x around 0 88.3%
if -9e107 < z < -3.3999999999999999e-186 or 2.1e-248 < z < 6.3999999999999999e-15Initial program 99.8%
add-sqr-sqrt47.6%
associate-*r*47.7%
fma-define47.7%
Applied egg-rr47.7%
Taylor expanded in y around 0 44.7%
Taylor expanded in z around inf 80.6%
associate-/l*80.5%
Simplified80.5%
if -3.3999999999999999e-186 < z < 2.1e-248Initial program 99.8%
Taylor expanded in x around inf 81.5%
Final simplification84.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (sin y))) (t_1 (* z (cos y))))
(if (<= x -4.2e+111)
t_0
(if (<= x -2.5e+47)
(* x (/ t_1 x))
(if (<= x -3.05e-21)
(* x (+ y (* (cos y) (/ z x))))
(if (<= x 7.8e+93) t_1 t_0))))))
double code(double x, double y, double z) {
double t_0 = x * sin(y);
double t_1 = z * cos(y);
double tmp;
if (x <= -4.2e+111) {
tmp = t_0;
} else if (x <= -2.5e+47) {
tmp = x * (t_1 / x);
} else if (x <= -3.05e-21) {
tmp = x * (y + (cos(y) * (z / x)));
} else if (x <= 7.8e+93) {
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 * sin(y)
t_1 = z * cos(y)
if (x <= (-4.2d+111)) then
tmp = t_0
else if (x <= (-2.5d+47)) then
tmp = x * (t_1 / x)
else if (x <= (-3.05d-21)) then
tmp = x * (y + (cos(y) * (z / x)))
else if (x <= 7.8d+93) 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.sin(y);
double t_1 = z * Math.cos(y);
double tmp;
if (x <= -4.2e+111) {
tmp = t_0;
} else if (x <= -2.5e+47) {
tmp = x * (t_1 / x);
} else if (x <= -3.05e-21) {
tmp = x * (y + (Math.cos(y) * (z / x)));
} else if (x <= 7.8e+93) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * math.sin(y) t_1 = z * math.cos(y) tmp = 0 if x <= -4.2e+111: tmp = t_0 elif x <= -2.5e+47: tmp = x * (t_1 / x) elif x <= -3.05e-21: tmp = x * (y + (math.cos(y) * (z / x))) elif x <= 7.8e+93: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * sin(y)) t_1 = Float64(z * cos(y)) tmp = 0.0 if (x <= -4.2e+111) tmp = t_0; elseif (x <= -2.5e+47) tmp = Float64(x * Float64(t_1 / x)); elseif (x <= -3.05e-21) tmp = Float64(x * Float64(y + Float64(cos(y) * Float64(z / x)))); elseif (x <= 7.8e+93) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * sin(y); t_1 = z * cos(y); tmp = 0.0; if (x <= -4.2e+111) tmp = t_0; elseif (x <= -2.5e+47) tmp = x * (t_1 / x); elseif (x <= -3.05e-21) tmp = x * (y + (cos(y) * (z / x))); elseif (x <= 7.8e+93) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[Sin[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -4.2e+111], t$95$0, If[LessEqual[x, -2.5e+47], N[(x * N[(t$95$1 / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -3.05e-21], N[(x * N[(y + N[(N[Cos[y], $MachinePrecision] * N[(z / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 7.8e+93], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \sin y\\
t_1 := z \cdot \cos y\\
\mathbf{if}\;x \leq -4.2 \cdot 10^{+111}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -2.5 \cdot 10^{+47}:\\
\;\;\;\;x \cdot \frac{t\_1}{x}\\
\mathbf{elif}\;x \leq -3.05 \cdot 10^{-21}:\\
\;\;\;\;x \cdot \left(y + \cos y \cdot \frac{z}{x}\right)\\
\mathbf{elif}\;x \leq 7.8 \cdot 10^{+93}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -4.1999999999999999e111 or 7.8000000000000005e93 < x Initial program 99.8%
Taylor expanded in x around inf 83.9%
if -4.1999999999999999e111 < x < -2.50000000000000011e47Initial program 99.8%
add-cbrt-cube46.5%
pow346.5%
Applied egg-rr46.5%
Taylor expanded in y around 0 24.3%
*-commutative24.3%
Simplified24.3%
Taylor expanded in x around inf 37.4%
Taylor expanded in z around inf 72.0%
if -2.50000000000000011e47 < x < -3.05000000000000007e-21Initial program 100.0%
add-cbrt-cube63.8%
pow363.8%
Applied egg-rr63.8%
Taylor expanded in y around 0 48.8%
*-commutative48.8%
Simplified48.8%
Taylor expanded in x around inf 85.0%
*-commutative85.0%
associate-/l*85.0%
Applied egg-rr85.0%
if -3.05000000000000007e-21 < x < 7.8000000000000005e93Initial program 99.8%
Taylor expanded in x around 0 83.0%
Final simplification82.8%
(FPCore (x y z) :precision binary64 (if (or (<= y -400.0) (not (<= y 0.1))) (* x (sin y)) (+ z (* y (+ x (* y (+ (* z -0.5) (* (* x y) -0.16666666666666666))))))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -400.0) || !(y <= 0.1)) {
tmp = x * sin(y);
} else {
tmp = z + (y * (x + (y * ((z * -0.5) + ((x * y) * -0.16666666666666666)))));
}
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 <= (-400.0d0)) .or. (.not. (y <= 0.1d0))) then
tmp = x * sin(y)
else
tmp = z + (y * (x + (y * ((z * (-0.5d0)) + ((x * y) * (-0.16666666666666666d0))))))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -400.0) || !(y <= 0.1)) {
tmp = x * Math.sin(y);
} else {
tmp = z + (y * (x + (y * ((z * -0.5) + ((x * y) * -0.16666666666666666)))));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -400.0) or not (y <= 0.1): tmp = x * math.sin(y) else: tmp = z + (y * (x + (y * ((z * -0.5) + ((x * y) * -0.16666666666666666))))) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -400.0) || !(y <= 0.1)) tmp = Float64(x * sin(y)); else tmp = Float64(z + Float64(y * Float64(x + Float64(y * Float64(Float64(z * -0.5) + Float64(Float64(x * y) * -0.16666666666666666)))))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -400.0) || ~((y <= 0.1))) tmp = x * sin(y); else tmp = z + (y * (x + (y * ((z * -0.5) + ((x * y) * -0.16666666666666666))))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -400.0], N[Not[LessEqual[y, 0.1]], $MachinePrecision]], N[(x * N[Sin[y], $MachinePrecision]), $MachinePrecision], N[(z + N[(y * N[(x + N[(y * N[(N[(z * -0.5), $MachinePrecision] + N[(N[(x * y), $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -400 \lor \neg \left(y \leq 0.1\right):\\
\;\;\;\;x \cdot \sin y\\
\mathbf{else}:\\
\;\;\;\;z + y \cdot \left(x + y \cdot \left(z \cdot -0.5 + \left(x \cdot y\right) \cdot -0.16666666666666666\right)\right)\\
\end{array}
\end{array}
if y < -400 or 0.10000000000000001 < y Initial program 99.6%
Taylor expanded in x around inf 45.8%
if -400 < y < 0.10000000000000001Initial program 100.0%
Taylor expanded in y around 0 98.8%
Final simplification71.3%
(FPCore (x y z) :precision binary64 (if (or (<= x -2.3e+113) (not (<= x 24.5))) (* x y) z))
double code(double x, double y, double z) {
double tmp;
if ((x <= -2.3e+113) || !(x <= 24.5)) {
tmp = x * y;
} else {
tmp = 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 ((x <= (-2.3d+113)) .or. (.not. (x <= 24.5d0))) then
tmp = x * y
else
tmp = z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -2.3e+113) || !(x <= 24.5)) {
tmp = x * y;
} else {
tmp = z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -2.3e+113) or not (x <= 24.5): tmp = x * y else: tmp = z return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -2.3e+113) || !(x <= 24.5)) tmp = Float64(x * y); else tmp = z; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -2.3e+113) || ~((x <= 24.5))) tmp = x * y; else tmp = z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -2.3e+113], N[Not[LessEqual[x, 24.5]], $MachinePrecision]], N[(x * y), $MachinePrecision], z]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.3 \cdot 10^{+113} \lor \neg \left(x \leq 24.5\right):\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;z\\
\end{array}
\end{array}
if x < -2.29999999999999997e113 or 24.5 < x Initial program 99.8%
Taylor expanded in y around 0 47.3%
*-commutative47.3%
Simplified47.3%
Taylor expanded in y around inf 43.5%
Taylor expanded in y around inf 35.9%
*-commutative35.9%
Simplified35.9%
if -2.29999999999999997e113 < x < 24.5Initial program 99.8%
Taylor expanded in y around 0 52.1%
*-commutative52.1%
Simplified52.1%
Taylor expanded in z around inf 48.5%
Final simplification43.6%
(FPCore (x y z) :precision binary64 (+ z (* x y)))
double code(double x, double y, double z) {
return z + (x * y);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = z + (x * y)
end function
public static double code(double x, double y, double z) {
return z + (x * y);
}
def code(x, y, z): return z + (x * y)
function code(x, y, z) return Float64(z + Float64(x * y)) end
function tmp = code(x, y, z) tmp = z + (x * y); end
code[x_, y_, z_] := N[(z + N[(x * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
z + x \cdot y
\end{array}
Initial program 99.8%
Taylor expanded in y around 0 50.2%
*-commutative50.2%
Simplified50.2%
Final simplification50.2%
(FPCore (x y z) :precision binary64 z)
double code(double x, double y, double z) {
return z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = z
end function
public static double code(double x, double y, double z) {
return z;
}
def code(x, y, z): return z
function code(x, y, z) return z end
function tmp = code(x, y, z) tmp = z; end
code[x_, y_, z_] := z
\begin{array}{l}
\\
z
\end{array}
Initial program 99.8%
Taylor expanded in y around 0 50.2%
*-commutative50.2%
Simplified50.2%
Taylor expanded in z around inf 34.7%
Final simplification34.7%
herbie shell --seed 2024112
(FPCore (x y z)
:name "Diagrams.ThreeD.Transform:aboutX from diagrams-lib-1.3.0.3, B"
:precision binary64
(+ (* x (sin y)) (* z (cos y))))