kubaPod / MoreCalculus

Developement repository for MoreCalculus Mathematica package
9 stars 4 forks source link

Using built-in transformations does not work #6

Open divenex opened 3 years ago

divenex commented 3 years ago

The simple examples provided on StackOverflow using built-in transformations do not work (in Mathematica 12.2).

DChange[D[f[x, y], x, x] + D[f[x, y], y, y] == 0, 
     "Cartesian" -> "Polar", {x, y}, {r, th}, f[x, y]]

Generate a series of error messages starting with

Solve::nsmet: This system cannot be solved with the methods available to Solve.

DChange::ambTrans: Transformation rule is ambiguous. The first of found solutions is used:

    r==Sqrt[x^2+y^2]
    th==ArcTan[x,y]

Please add appropriate assumptions if this solution does not meet your expectations.
...
cklausme commented 3 years ago

I ran into the same problem this morning, so I spent some time trying to figure out what's wrong. Here's some info that @kubaPod might find useful in fixing this:

The problem seems to stem from a change in v12.2 in how Solve handles Assumptions.

Specifically, the automatic assumptions x \[Element] Reals && y \[Element] Reals that arise from CoordinateChartData[{"Cartesian", 2}, "CoordinateRangeAssumptions", {x, y}] in the CoordinateTransformData version of DChange causes the oldVarsRules = Solve[transformations, oldVars]; in the main version of DChange to fail in 12.2.

You'll probably have a better idea how to fix this, but I tried replacing

MapThread[CoordinateChartData[{#, dim}, "CoordinateRangeAssumptions", #2] &, {List @@ coordinates, {oldVars, newVars}}]

with

CoordinateChartData[{(List @@ coordinates)[[2]], dim}, "CoordinateRangeAssumptions", newVars]

and it seemed to work without breaking any of the other examples.