1
$\begingroup$

The only way I can understand the domain restriction on FromPolarCoordinates is as ensuring a round-trip is possible: FromPolarCoordinates@ToPolarCoordinates@{x, y}. This is nice symbolically but cripples the function. Am I overlooking another justification for this choice? Shouldn't there at least be a Domain->All option?

I am not asking how to write my own.

$\endgroup$
  • $\begingroup$ What, exactly, is your question? $\endgroup$ – David G. Stork Aug 23 '16 at 23:55
  • $\begingroup$ @DavidG.Stork "Am I overlooking another justification for this choice? Shouldn't there at least be a Domain->All option?" $\endgroup$ – Alan Aug 24 '16 at 1:03
  • $\begingroup$ @Alan David probably refers to the lack of background/example of unexpected domain restriction you are talking about. While the question is there, it is not clear. $\endgroup$ – Kuba Aug 25 '16 at 21:27
2
$\begingroup$

Clearly it is trivial to implement an equivalent without the domain restriction, e.g.

frompolarcoordinates[r_, θ_] = FromPolarCoordinates[{r, θ}]

I suggest that defining your own function in this way is more convenient than burdening the built-in function with an option controlling its behaviour.

If you did want a function that checked the numerical range of its input, that would be a little more work, so be glad that Wolfram has taken the trouble to write it for you. FromPolarCoordinates can give useful warnings if, for example, you make an error in implementing numerical integration in spherical polar coordinates.

As a trivial example, an error in which the order of the arguments is exchanged is much more likely to show up if the argument domain is checked. (This type of error is probably much more likely in 3D than 2D).

$\endgroup$
  • $\begingroup$ Can you elaborate on that last point? And, shouldn't loosening the domain restriction be an option (or, the behavior reversed from that, with a restriction being an option)? $\endgroup$ – Alan Aug 25 '16 at 21:01
2
$\begingroup$

This is covered in the documentation itself under the Properties & Relations section:

FromPolarCoordinates checks that inputs obey the normal restrictions of polar coordinates:

In[1]:= FromPolarCoordinates[{1, 3 Pi}]

In[1]:= FromPolarCoordinates::bdpt: Evaluation point {1,3 π} is not a
          valid set of polar or hyperspherical coordinates.

Out[1]= FromPolarCoordinates[{1, 3 π}]

This point violates the condition on the angle θ:

In[2]:= CoordinateChartData["Polar", "CoordinateRangeAssumptions", {r, θ}]

Out[2]= r > 0 && -π < θ <= π

Extract the symbolic transform from CoordinateTransformData to apply it to singular points:

In[3]:= transform =
   CoordinateTransformData["Polar" -> "Cartesian", "Mapping"]; transform[{1, 3 Pi}]

Out[4]= {-1, 0}

So FromPolarCoordinates exists expressly to check its arguments for "normal restrictions of polar coordinates" -- if you want the generalized form you are supposed to use something else.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.