I use the following code to find the expansion for small $x$:
Assuming[x \[Element] Reals,
FullSimplify@
Series[-Sqrt[-x] I^(n + 1/2) HankelH1[n, -x], {x, 0, 1}]]
I find the solutions:
Analogously:
Assuming[x \[Element] Reals,
FullSimplify@
Series[-Sqrt[-x] I^(n + 1/2) HankelH2[n, -x], {x, 0, 1}]]
What does True
mean in the last lines?
Answer
From the documentation of Piecewise
:
The $\text{cond}_i$ are evaluated in turn, until one of them is found to yield
True
.
The last condition is always True
, so that Piecewise
can return a value even when all the preceding conditions evaluated to False
.
In a math textbook, this last case would be written as "otherwise".
When you write math notation for humans, you would make sure that the conditions are all disjoint, and there is an "otherwise" at the end. A CAS like Mathematica needs to handle junk input reasonable gracefully. What if some conditions overlap, or what if there's no "otherwise"? Symbolically verifying that the conditions are disjoint is not feasible (not only is it a hard problem that is not solvable in general, it would be very slow in many cases when it is solvable). This is why Mathematica resorts to evaluating conditions in turn, and taking the first one that is True
. Additionally, it automatically adds a last True
condition for "otherwise" if you haven't done so yourself.
Comments
Post a Comment