1
|
1284 Views
|
18 Replies
|
21 Total Likes
View groups...
Share
GROUPS:

# Finding roots of multivariable function

Posted 2 months ago
 I have a real-valued function of four variables, namely $L[\phi, m0, m1, m2]$. I am interested in taking the partial derivative $\partial_{\phi}L$ thereof and setting the partial derivative to zero, that is $\partial_{\phi}L = 0$. Then solving for $\phi \in [0,2\pi]$ in terms of $m0, m1, m2 \in \mathbb{N}_{0}$. I have reached the point in the attached code where I have generated the partial derivative $\partial_{\phi}L$, but I am having difficulty setting the partial derivative to zero and getting an analytic expression for $\phi$ in terms of the other variables $m0,~m1$ and $m2$. Please advise if there is a clear way of doing this analytically and numerically. Just a note that the function $L[\phi, m0, m1, m2]$ is defined in terms of probabilities $P1, P2$ and $P3$, hence it has a real-valued output for any $\phi \in \mathbb{R}$. Link to related Mathematica SE post.
18 Replies
Sort By:
Posted 2 months ago
 The function L[ϕ,m0,m1,m2] is defined in terms of P02,P11 and P20, not of P1,P2 and P3.Assuming that P02 = P1; P11 = P2; P20 = P3 you can do it this way: Clear[\[Phi], m0, m1, m2, L, DL]; L[\[Phi]_, m0_, m1_, m2_] = P1[\[Phi]]^m0*P2[\[Phi]]^m1*P3[\[Phi]]^m2; DL[\[Phi]_, m0_, m1_, m2_] = Simplify[D[L[\[Phi], m0, m1, m2], \[Phi]], Element[\[Phi], Reals]]; Reduce[DL[\[Phi], m0, m1, m2] == 0 && Element[{m0, m1, m2}, PositiveIntegers] && Element[\[Phi], Reals], \[Phi]] 
Posted 2 months ago
 Firstly, did you mean $L(\phi, m_0, m_1, m_2) = P_{1}(\phi)^{m_{0}} \cdot P_2(\phi)^{m_{1}} \cdot P_3(\phi)^{m_{2}}$ 'cause P02, P11, P20 are not defined? If so,we see thatFullSimplify@L[\[Phi], m0, m1, m2] is $2^{-\text{m0}-\text{m2}} \cos ^4\left(\frac{\phi }{2}\right)^{\text{m1}} \sin ^2(\phi )^{\text{m0}+\text{m2}}$With this expression you could simply do any operations.If we go further:DL[\[Phi]_, m0_, m1_, m2_] :=FullSimplify@D[FullSimplify@L[\[Phi], m0, m1, m2], \[Phi]] $2^{-\text{m0}-\text{m2}+1} \csc (\phi ) \cos ^4\left(\frac{\phi }{2}\right)^{\text{m1}} \sin ^2(\phi )^{\text{m0}+\text{m2}} (\cos (\phi ) (\text{m0}+\text{m1}+\text{m2})-\text{m1})$ If we run (as in post Gianluca Gorni):Reduce[DL[\[Phi], m0, m1, m2] == 0 && Element[{m0, m1, m2}, PositiveIntegers] && 0 <= \[Phi] <= 2 \[Pi], \[Phi]]we get some (not very) complicated result, from which we could learn that DL[\[Phi], m0, m1, m2] == 0iff: $\phi=0,\pi,2 \pi$ or $\phi=\arccos\left(\frac{\text{m1}}{\text{m0}+\text{m1}+\text{m2}}\right)$ or $\phi=2 \pi -\arccos\left(\frac{\text{m1}}{\text{m0}+\text{m1}+\text{m2}}\right)$ But if we try to substitute directlyDL[\[Phi], m0, m1, m2] /. \[Phi] -> {0, \[Pi], 2 \[Pi]}we get{ComplexInfinity, ComplexInfinity, ComplexInfinity}We need more accurate testing:Limit[DL[\[Phi], m0, m1, m2], \[Phi] -> #, Assumptions -> Element[{m0, m1, m2}, PositiveIntegers]] & /@ {0, \[Pi], 2 \[Pi]}{0, 0, 0}so all five solutions are valid.
Posted 2 months ago
 This is interesting example with some pitfalls.When i run your code directly, I get complex result with Log function.I suspect it is not so
Posted 2 months ago
 The solutions are real, despite their appearance: sol = Reduce[ DL[\[Phi], m0, m1, m2] == 0 && Element[{m0, m1, m2}, PositiveIntegers] && Element[\[Phi], Reals], \[Phi]]; FullSimplify[ComplexExpand[sol], m0 > 0 && m1 > 0 && m1 > 0] 
Posted 2 months ago
 Hmm, may be, but they have very simple trig form finally
Posted 2 months ago
 Many thanks for your response. Firstly, yes P02 = P1; P11 = P2; P20 = P3. Why is it that you seem to get a different function when you FullSimplify at the start, they don't seem to be equivalent. Please have a look at my adapted code using your what you suggest in your post:
Posted 2 months ago
 Yes, you are wright, looks like I mess something (We can get firstly:FullSimplify /@ {P1[\[Phi]] , P2[\[Phi]], P3[\[Phi]]} $\left\{\cos ^4\left(\frac{\phi }{2}\right),\frac{\sin ^2(\phi )}{2},\sin ^4\left(\frac{\phi }{2}\right)\right\}$Cause $\sin^2\left(\alpha/2\right)=\frac{1-\cos\left(\alpha\right)}{2}$we can check result directly and your last post looks like fully correct!
Posted 2 months ago
 Many thanks for your response. I attach the modified code where I attempt to explicitly show the 4th and 5th solutions (the solutions other than $\phi = {0, \pi ,2\pi}$). Do you agree with this code and the computation of the fourth and fifth roots:Lastly, at the end of your response you stated Limit[DL[[Phi], m0, m1, m2], [Phi] -> #, Assumptions -> Element[{m0, m1, m2}, PositiveIntegers]] & /@ {0, [Pi], 2 [Pi]} {0, 0, 0} so all five solutions are valid.But it seems that you only tested the solutions $\phi = 0, \pi ,2\pi$ yielding derivatives of {0, 0, 0}, yet you state 'so all five solutions are valid'. Could you advise on this please.
Posted 2 months ago
 Yes, today later i'll double check all calculations!
Posted 2 months ago
 (1) This should link to the mathematica.stackexchange crosspost.(2) The notebook should use consistent notation for {P1,P2,P3}.(3) You might try the suggestion from a comment (mine) in MSE. Specifically, convert exponentials to trigs, and optimize the log of the expression of interest. P1[\[Phi]_] := 2^-4*ExpToTrig[ ((E^(I*(\[Phi]/2)) + E^(-I*(\[Phi]/2))) (E^(I*(-(\[Phi]/2))) + E^(I*(\[Phi]/2))))]^2; P2[\[Phi]_] := 2^-3 *ExpToTrig[ (E^(I*(\[Phi])) - E^(-I*(\[Phi]))) (E^(I*(-\[Phi])) - E^(I*(\[Phi])))]; P3[\[Phi]_] := 2^-4 *ExpToTrig[ ((E^(I*(\[Phi]/2)) - E^(-I*(\[Phi]/2))) (E^(I*(-(\[Phi]/2))) - E^(I*(\[Phi]/2))))]^2; L[\[Phi]_, m0_, m1_, m2_] := ((P1[\[Phi]])^m0)*((P2[\[Phi]])^m1)*((P3[\[Phi]])^m2) In[24]:= llog = PowerExpand[Log[L[\[Phi], m0, m1, m2]]] (* Out[24]= -m1 Log[2] + 4 m0 Log[Cos[\[Phi]/2]] + 4 m2 Log[Sin[\[Phi]/2]] + 2 m1 Log[Sin[\[Phi]]] *) In[26]:= Solve[D[llog, \[Phi]] == 0, \[Phi]] (* Out[26]= {{\[Phi] -> ConditionalExpression[ 2 (-ArcTan[Sqrt[m1 + 2 m2]/Sqrt[ 2 m0 + m1]] + \[Pi] ConditionalExpression[ 1, \[Placeholder]]), ConditionalExpression[1, \[Placeholder]] \[Element] Integers]}, {\[Phi] -> ConditionalExpression[ 2 (ArcTan[Sqrt[m1 + 2 m2]/Sqrt[ 2 m0 + m1]] + \[Pi] ConditionalExpression[1, \[Placeholder]]), ConditionalExpression[1, \[Placeholder]] \[Element] Integers]}} *) 
Posted 2 months ago
 Idea with $Log$ is very good, but don't you miss roots $\{0, \pi, 2\pi\}$ ?They are always there, as we could see from examples of Plot with different m0,m1,m2: Manipulate[ Plot[DL[\[Phi], m0, m1, m2], {\[Phi], 0, 2 \[Pi]}, PlotRange -> Full], {{m0, 0.1}, 0.01, 10, 0.01}, {{m1, 0.1}, 0.0, 10, 0.01}, {{m2, 0.1}, 0.01, 10, 0.01}] 
Posted 2 months ago
 Absolutely right, my method should also check for when the log is -Infinity (a boundary case, with this transformation). And, as you note, this happens at multiples of Pi. I should have caught that. Thanks for pointing out the missing solutions.
Posted 2 months ago
 One more query, is there a systematic way in Mathematica of identifying these indeterminate points from the log function itself. I don't think Mathematica has built-in functions to find these indeterminate critical points?
Posted 2 months ago
 Thanks.
Posted 2 months ago
 Good question. I think one way is to find discontinuity points. Skipping some of the setup, here is hoq that could be done. ee = -m1 Log[2] + 4 m0 Log[Cos[\[Phi]/2]] + 4 m2 Log[Sin[\[Phi]/2]] + 2 m1 Log[Sin[\[Phi]]]; Solve[FunctionDiscontinuities[{ee, 0 <= \[Phi] <= 2*Pi}, \[Phi]] && 0 <= \[Phi] <= 2*Pi, \[Phi]] (* During evaluation of In[18]:= FunctionDiscontinuities::unkds: Warning: The set of discontinuities may be incomplete due to missing domain and discontinuity information for some of the functions involved. Out[19]= {{\[Phi] -> 0}, {\[Phi] -> 0}, {\[Phi] -> \[Pi]}, {\[Phi] -> \[Pi]}, {\[Phi] -> 2 \[Pi]}, {\[Phi] -> 2 \[Pi]}} *) 
Posted 2 months ago
 Hi Daniel I am very interested in finding out why the different approaches in Mathematica yield different outcomes. If you have a chance could you please check out this post.
Posted 2 months ago
 Hi, just a note for completeness of this post. I think there is a small problem in using PowerExpand to take the Log in this way. Consider that the Sine and Cosine functions take negative values hence you cannot use the Log property of taking the respective exponents of 4 and 2 and moving them to factors in front of the Log terms. If you take the Log of L[\phi, m1, m2, m3], I don't think the log-function which you obtained is correct for this reason. Consider the attached code, where I use FullSimplify (as Ivanov noted):
Posted 2 months ago
 We take a derivative after that. Will the logs be off by something other than a constant in the variable phi?