Dr. David Harrington

3252 Reputation

17 Badges

18 years, 31 days
University of Victoria
Professor or university staff
Victoria, British Columbia, Canada

Social Networks and Content at Maplesoft.com

Maple Application Center
I am a professor of chemistry at the University of Victoria, BC, Canada, where my research areas are electrochemistry and surface science. I have been a user of Maple since about 1990.

MaplePrimes Activity

These are replies submitted by dharr

@Markiyan Hirnyk My implication, as stated in my earlier comment and my use of the word "partly", is that this is one term of the "standard solution" given by the OP. This is Maple's standard response for product separation of variables solutions, and only in some cases does it go further to produce the sum. I guess the user is expected to work it up as required.

@Markiyan Hirnyk  I agree it is not the general solution, but is a solution for the bc given. I agree _C4 is superfluous and there is no _C3, but that is what is produced!

@nm  This was version 2017.3. kernelopts(version) reports `Maple 2017.3, X86 64 WINDOWS, Sep 27 2017, Build ID 1265877` and Physics:-Version() reports "C:\Program Files\Maple 2017\lib\update.mla", `2017, September 27, 12:53 hours`.

I was looking for the solution for the specific boundary condition you gave, and one term of the Fourier series works here. If you try pdsolve without the b.c. but with the hint, then you are given the two odes to solve, which I assume can be worked up to one term of the Fourier series; the general solution is a sum of these which I think you won't get without more bc/ic conditions. The "What's new" help under PDEs suggests general series solutions can be obtained for some pdes.


it has the form sqrt(a^2+b^2), so there isn't an obvious answer here, If you think about a and b as the adjacent and opposite sides of a right triangle, then the sqrt is the length of the hypotenuse, which could be written a/cos(theta), where theta = arctan(b/a), but this is hardly a simple form.

@_Maxim_ I agree - it is very confusing. At least I can now understand how to make it work it all cases, for lists. I agree also that is doesn't seem to be documented. I had only ever used the multiple range notation for rtables, so had never attempted it for lists before.

Basically, a[1..3] being equivalent to a[[1,2,3]] rather than a[1,2,3] is already strange.

@_Maxim_  Took me a while to figure this out, since I at first couldn't explain m[1..2,2].


Consider first selecting multiple non-sequential elements from a list


[q, w, e, r, t]


We cannot select elements 1,2 and 4 by 1,2,4 becuase that is reserved for nesting.


Error, invalid subscript selector


But we can do this by


[q, w, r]


Now the case in point

m := [[1, 2], [3, 4]];

[[1, 2], [3, 4]]


 m[[1,2]][2] first finds m[[1,2]], which is elements 1 and 2 in the list (the whole list) and then takes its second element


[[1, 2], [3, 4]]


[3, 4]


Accessing nested ones can be done by






or by the equivalent notation






And the range is 1..2 as the first selector means both of these  


[2, 4]


Similarly for the second selector


[1, 2]








Download indices.mw

@David1 An Array has 4 operands: indexing function, dimension ranges, contents, options, which you can see by

op(sols)  or individually by op(1,sols) etc,

though there is no indexing function in this case.

@David1 If it fails to find the global minimum, it has found the lowest local minimum that it can.

The solutions are in an Array, so ArrayDim(sols) will return 1..31, 1..3. To get the 31 use rhs(ArrayDim(sols)[1])

@David1 Your worksheet runs for me. DirectSearch is not a build-in package, so has to be downloaded from the cloud (for Maple 2017) or  installed from the applications centre, then I think it will run. For a general optimization problem, you could add a very sharp negative spike to the surface that was a global minimum and might be missed (see the DirectSearch:-GlobalOptima examples), but in real life you may know that your surface has some nice properties or is sufficiently smooth or is convex.

fsolve uses many different algorithms, and is likely using a more efficient method that only works for polynomials when that is the case.

@David1 I think using only 6 variables (3 Euler angles and the three components of the translation vector) makes the optimization problem tractable, with no constraints except the ranges of the angles. I corrected the range of theta in worksheet PtsAndLines.mw above, and now there seems to be a unique minimum. DirectSearch:-GlobalSearch looks for all minima, and the examples in the documentation are very convincing that it succeeds in this, though of course it might miss some for extreme problems (which yours isn't, I think). Once you trust it, DirectSearch:-GlobalOptima gives only the minimum, but not any faster. Hope this solution works for you.

@David1 I think for numerical work it doesn't matter about the trig functions - they are still evaluated efficiently and the complexity of the problem depends more on the number of variables. Here is my attempt for a 5 point problem. Optimize:-Minimize minimizes in 0.063 s and DirectSearch:-GlobalOptima takes 117 s. GlobalOptima works hard at finding a global mimimum and could be helped further, but cannot give a guarantee. In this case the same sum of squares is obtained with the same translation vector, so I'm thinking that there is still some redundancy in how I've bounded the Euler angles but I didn't think too hard about that.


[Edit - range of theta changed]


@David1 It seems the problem is indeed too big for Groebner. For Optimization, your rotation matrix has redundancy - I would formulate it in terms of the three Euler angles:


So then there are 6 variables for your minimization, three angles and three translation components.

@David1 Then you should use Maple's Optimization package, e.g., Optimization:-Minimize. DirectSearch also is a possiblility. You always have problems knowing whether or not you have found the global mimimum, but there are lots of algorithms that fairly reliably avoid getting stuck in local minima. 

@David1 Use convert(.223,rational) to convert floating point numbers to rationals. It should work also on an expression or equation. Once you have the final 18 equations with rational coefficients, if you upload a worksheet containing them, it will be clearer what any remaining issues are - use the large green up arrow to upload a worksheet.


[Edit: I agree with the directsearch approach if you don't need all solutions - you do say "I get the solution I expected" as if you only want one, and you know when you have it, so can specify the constraints to directsearch]

I played around with different methods, initmesh, and using b as a continuation parameter. Everything is fine for b=0..0.45, but can't get a solution for b>= 0.4600, so probably the equations have some sort of singularity there. Perhaps someone else has a suggestion. 

First 22 23 24 25 26 27 28 Page 24 of 31