Message Boards Message Boards

Solve takes too long with parametric system

Posted 6 months ago

The notebook was given by Jim Napolitano tuf43817@temple.edu and it gets stuck in the "sol" step:

How to fix this problem?

Regards,
Zhao

POSTED BY: Hongyi Zhao
2 Replies
Posted 6 months ago

Now, I apply ParallelEvaluate to the Solve step and it finished quickly, but the result is different from the one shown in the original notebook:

This is the result obtained via ParallelEvaluate:

HW#6 Problem 1: Differential form of Lz
In[41]:= Remove["Global`*"]
$Assumptions = 
  r > 0 && \[Theta] > 0 && \[Theta] < Pi && \[Phi] > 0 && \[Phi] < 
    2 Pi;
In[43]:= xp = r Cos[\[Phi]] Sin[\[Theta]];
yp = r Sin[\[Phi]] Sin[\[Theta]];
zp = r Cos[\[Theta]];
In[46]:= sol = Solve[{x == xp, y == yp, z == zp}, {r, \[Theta], \[Phi]}] // 
   ParallelEvaluate;
In[47]:= drdx = Simplify[D[r /. sol[[3]], x] /. {x -> xp, y -> yp, z -> zp}]
d\[Theta]dx = 
 Simplify[D[\[Theta] /. sol[[3]], x] /. {x -> xp, y -> yp, z -> zp}]
d\[Phi]dx = 
 Simplify[D[\[Phi] /. sol[[3]], x] /. {x -> xp, y -> yp, z -> zp}]
drdy = Simplify[D[r /. sol[[3]], y] /. {x -> xp, y -> yp, z -> zp}]
d\[Theta]dy = 
 Simplify[D[\[Theta] /. sol[[3]], y] /. {x -> xp, y -> yp, z -> zp}]
d\[Phi]dy = 
 Simplify[D[\[Phi] /. sol[[3]], y] /. {x -> xp, y -> yp, z -> zp}]
Out[47]= {-Cos[\[Phi]] Sin[\[Theta]], -Cos[\[Phi]] Sin[\[Theta]], 
 Cos[\[Phi]] Sin[\[Theta]], Cos[\[Phi]] Sin[\[Theta]]}
Out[48]= {ConditionalExpression[(Cos[\[Theta]] Cos[\[Phi]])/r, 
  ConditionalExpression[1, \[Placeholder]] \[Element] Integers], 
 ConditionalExpression[-((Cos[\[Theta]] Cos[\[Phi]])/r), 
  ConditionalExpression[1, \[Placeholder]] \[Element] Integers], 
 ConditionalExpression[-((Cos[\[Theta]] Cos[\[Phi]])/r), 
  ConditionalExpression[1, \[Placeholder]] \[Element] Integers], 
 ConditionalExpression[(Cos[\[Theta]] Cos[\[Phi]])/r, 
  ConditionalExpression[1, \[Placeholder]] \[Element] Integers]}
Out[49]= {ConditionalExpression[-((Csc[\[Theta]] Sin[\[Phi]])/r), 
  ConditionalExpression[2, \[Placeholder]] \[Element] Integers], 
 ConditionalExpression[-((Csc[\[Theta]] Sin[\[Phi]])/r), 
  ConditionalExpression[2, \[Placeholder]] \[Element] Integers], 
 ConditionalExpression[-((Csc[\[Theta]] Sin[\[Phi]])/r), 
  ConditionalExpression[2, \[Placeholder]] \[Element] Integers], 
 ConditionalExpression[-((Csc[\[Theta]] Sin[\[Phi]])/r), 
  ConditionalExpression[2, \[Placeholder]] \[Element] Integers]}
Out[50]= {-Sin[\[Theta]] Sin[\[Phi]], -Sin[\[Theta]] Sin[\[Phi]], 
 Sin[\[Theta]] Sin[\[Phi]], Sin[\[Theta]] Sin[\[Phi]]}
Out[51]= {ConditionalExpression[(Cos[\[Theta]] Sin[\[Phi]])/r, 
  ConditionalExpression[1, \[Placeholder]] \[Element] Integers], 
 ConditionalExpression[-((Cos[\[Theta]] Sin[\[Phi]])/r), 
  ConditionalExpression[1, \[Placeholder]] \[Element] Integers], 
 ConditionalExpression[-((Cos[\[Theta]] Sin[\[Phi]])/r), 
  ConditionalExpression[1, \[Placeholder]] \[Element] Integers], 
 ConditionalExpression[(Cos[\[Theta]] Sin[\[Phi]])/r, 
  ConditionalExpression[1, \[Placeholder]] \[Element] Integers]}
Out[52]= {ConditionalExpression[(Cos[\[Phi]] Csc[\[Theta]])/r, 
  ConditionalExpression[2, \[Placeholder]] \[Element] Integers], 
 ConditionalExpression[(Cos[\[Phi]] Csc[\[Theta]])/r, 
  ConditionalExpression[2, \[Placeholder]] \[Element] Integers], 
 ConditionalExpression[(Cos[\[Phi]] Csc[\[Theta]])/r, 
  ConditionalExpression[2, \[Placeholder]] \[Element] Integers], 
 ConditionalExpression[(Cos[\[Phi]] Csc[\[Theta]])/r, 
  ConditionalExpression[2, \[Placeholder]] \[Element] Integers]}

This is the result given in the original notebook:

HW#6 Problem 1: Differential form of Lz
In[1]:= Remove["Global`*"]
$Assumptions = 
  r > 0 && \[Theta] > 0 && \[Theta] < Pi && \[Phi] > 0 && \[Phi] < 
    2 Pi;
In[3]:= xp = r Cos[\[Phi]] Sin[\[Theta]];
yp = r Sin[\[Phi]] Sin[\[Theta]];
zp = r Cos[\[Theta]];
In[6]:= sol = Solve[{x == xp, y == yp, z == zp}, {r, \[Theta], \[Phi]}];
drdx = Simplify[D[r /. sol[[3]], x] /. {x -> xp, y -> yp, z -> zp}]
d\[Theta]dx = 
 Simplify[D[\[Theta] /. sol[[3]], x] /. {x -> xp, y -> yp, z -> zp}]
d\[Phi]dx = 
 Simplify[D[\[Phi] /. sol[[3]], x] /. {x -> xp, y -> yp, z -> zp}]
drdy = Simplify[D[r /. sol[[3]], y] /. {x -> xp, y -> yp, z -> zp}]
d\[Theta]dy = 
 Simplify[D[\[Theta] /. sol[[3]], y] /. {x -> xp, y -> yp, z -> zp}]
d\[Phi]dy = 
 Simplify[D[\[Phi] /. sol[[3]], y] /. {x -> xp, y -> yp, z -> zp}]
Out[7]= Cos[\[Phi]] Sin[\[Theta]]
Out[8]= ConditionalExpression[-((Cos[\[Theta]] Cos[\[Phi]])/r), 
 C[1] \[Element] Integers]
Out[9]= ConditionalExpression[-((Csc[\[Theta]] Sin[\[Phi]])/r), 
 C[2] \[Element] Integers]
Out[10]= Sin[\[Theta]] Sin[\[Phi]]
Out[11]= ConditionalExpression[-((Cos[\[Theta]] Sin[\[Phi]])/r), 
 C[1] \[Element] Integers]
Out[12]= ConditionalExpression[(Cos[\[Phi]] Csc[\[Theta]])/r, 
 C[2] \[Element] Integers]

Why is such a difference happening and which one is correct?

Regards, Zhao

POSTED BY: Hongyi Zhao

Aborting the Solve step will have that effect.

POSTED BY: Daniel Lichtblau
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract