From: Jason on 21 Jul 2010 09:25 "Matt J " <mattjacREMOVE(a)THISieee.spam> wrote in message <i24dt5$3op$1(a)fred.mathworks.com>... > "Jason" <jf203(a)ic.ac.uk> wrote in message <i22ek6$90o$1(a)fred.mathworks.com>... > > > Yes, exactly. It will be a complicated expression in terms of the unknown x2. However you can solve it using symlinks and the matlab 'solve' command. > > > > For example (NOTE THAT x1 and x2 are replaced by l1 and l2 in my code!): > > > > J1 = (a*l1^2 + 2*b*l1*l2 + 2*d*l1 + c*l2^2 + 2*e*l2 + f)^2 > > > > The first derivative in terms of l1: > > dJl1 = 4*(d + a*l1 + b*l2)*(a*l1^2 + 2*b*l1*l2 + 2*d*l1 + c*l2^2 + 2*e*l2 + f) > > > > The roots of this: > > > > root1 = -(d + b*l2)/a > > root2 = -(d + b*l2 - (b^2*l2^2 + 2*b*d*l2 + d^2 - a*c*l2^2 - 2*a*e*l2 - a*f)^(1/2))/a > > root3 = -(d + b*l2 + (b^2*l2^2 + 2*b*d*l2 + d^2 - a*c*l2^2 - 2*a*e*l2 - a*f)^(1/2))/a > > > > Solutions for l2 based on the first root: > > > > l2_1 = (b*d - a*e + a*((f*b^2 - 2*b*d*e + c*d^2 + a*e^2 - a*c*f)/a)^(1/2))/(a*c - b^2) > > l2_2 = -(a*e - b*d)/(a*c - b^2) > > l2_3 = -(a*e - b*d + a*((f*b^2 - 2*b*d*e + c*d^2 + a*e^2 - a*c*f)/a)^(1/2))/(a*c - b^2) > > > > Solutions for l1 by substituting back into root1: > > > > l1_1 = -(d + (b*(b*d - a*e + a*((f*b^2 - 2*b*d*e + c*d^2 + a*e^2 - a*c*f)/a)^(1/2)))/(a*c - b^2))/a > > l1_2 = -(d - (b*(a*e - b*d))/(a*c - b^2))/a > > l1_3 = -(d - (b*(a*e - b*d + a*((f*b^2 - 2*b*d*e + c*d^2 + a*e^2 - a*c*f)/a)^(1/2)))/(a*c - b^2))/a > > > > etc... > > > > Is there anything wrong with that? > =========== > > It is strange to me that for each fixed root1,2,3 the symbolic solver would obtain only a single corresponding l1_1,2,3. > > Prior to substituting root1,2,3 into dJl2, you have a cubic polynomial in l2 with potentially multiple real roots for each fixed l1. Are you saying the substitution of root1,2,3 reduced the number of potential roots to one? > I have only outlined the case of substituting root1 into dJl2 and setting to zero. In fact if you do the same for root2 and root3 you obtain 9 roots in total (from which 2 can be excluded) meaning you are left with 7 in total, i.e. 7 estimates for l1 and consequently 7 estimates for l2. Since I wrongly placed the sum inside rather than outside I am missing some terms which I need to update now. But the solution should still be straightforward, and most importantly analytical and closed form. I know we have discussed about parametrizing l1 and l2 using cos and sin. However this is not an option I'm afraid. Do you see any problems with the way I am about to proceed ?
From: Matt J on 21 Jul 2010 09:37 "Jason" <jf203(a)ic.ac.uk> wrote in message <i26sfh$spl$1(a)fred.mathworks.com>... > > I know we have discussed about parametrizing l1 and l2 using cos and sin. However this is not an option I'm afraid. > > Do you see any problems with the way I am about to proceed ? Not if the symbolic toolbox is able to solve the optimality equations, as you say. The only problem I see is the unclear reasoning why parametrizing l1 and l2 with sines and cosines is "not an option".
From: Jason on 21 Jul 2010 09:54 "Matt J " <mattjacREMOVE(a)THISieee.spam> wrote in message <i26t60$f5i$1(a)fred.mathworks.com>... > "Jason" <jf203(a)ic.ac.uk> wrote in message <i26sfh$spl$1(a)fred.mathworks.com>... > > > > > I know we have discussed about parametrizing l1 and l2 using cos and sin. However this is not an option I'm afraid. > > > > Do you see any problems with the way I am about to proceed ? > > Not if the symbolic toolbox is able to solve the optimality equations, as you say. This I am not 100% sure of, but am testing it now. I did come across some problems for which I had to do some workarounds. Parametrizing l1 and l2 is not an option because I would have to do an exhaustive search over all angles. Furthermore this will only be an estimate, and yes, it can be improved by using a finer grid once a solution has been found. I am not adverse to this, and might actually give it a try if everything else fails. However I am worried about speed, and also not having an exact solution, when theoretically you can obtain a perfect solution, i.e. analytically obtain the global minimum. That's why! Many thanks for your insightful feedback, I will let you know how it went!
From: Matt J on 21 Jul 2010 10:08 "Jason" <jf203(a)ic.ac.uk> wrote in message <i26u5t$jk6$1(a)fred.mathworks.com>... > > Parametrizing l1 and l2 is not an option because I would have to do an exhaustive search over all angles. Furthermore this will only be an estimate, and yes, it can be improved by using a finer grid once a solution has been found. ============= No, that's not the way I was intending you go about it. You would search on a grid of angles that is both coarse enough to make the search very fast search, but fine enough that the search gets you very close to the solution. Depending on the size of your ellipses, the grid size might be 1 or 2 degrees or even more. Once you have the result of this search, you would use it to initialize lsqnonlin and converge to a more exact result. The problems you were initially having with lsqnonlin would be greatly diminished here because now you have a very good initial guess of the global minimum. That will make the residual work done by lsqnonlin both fast and robust against stuck at local minima. > I am not adverse to this, and might actually give it a try if everything else fails. However I am worried about speed, and also not having an exact solution, when theoretically you can obtain a perfect solution, i.e. analytically obtain the global minimum. ================ I'm still rather astounded that this can be solved exactly, but yes, an analytical solution is better.
First
|
Prev
|
Pages: 1 2 Prev: 'popupmneu' uicontrol behavior in Linux Next: GUIDE and prgrammaticaly create GUI |