tomleslie

13876 Reputation

20 Badges

15 years, 179 days

MaplePrimes Activity


These are replies submitted by tomleslie

I have modified your worksheet so that it runs:

Your first error occurs because assign() evaluates both of its arguments. This will work if the first argument is previously unassigned. Si if you enter the code (toy example)

assign(a,1);
assign(a,1);

Then the first statement will work, but the second will not, because the first thing that happens is that its arguments are evaluated, so it becomes assign(1, 1) - and you cannot use '1' as a variable name in Maple. In order to use the assign() statement as written in your worksheet, it must always be executed from the beginning to ensure that all names are unassigned.

The second problem you have at Convert([seq(Distance....is a combination of errors: it should be 'convert' rather than 'Convert': furthermore, the 'Distance' command which you require is from the Student[Precalculus] pacjkage which you didn't load.

The attached worksheet fixes all of these errors (and maybe a few more which I have forgotten). It now runs and producees the same results as in the RJLopez original

geodFix.mw

On a more general point I don't think this method will ever work for your original aim " to study the geodesics over the cone, the sphere and the cylinder". The algorithm used relies on being able to define a unique value of 'z' from as a function of (x,y). Rather obviously, one cannot do this for a sphere (two z-values for each (x,y)-pair). A cone *ought* to be OK. If I am right, a cylinder won't work either - if it's axxis coincides witht he z-axis, then there will be an infinite number of z-values

 

@vv 

If you compare the 'residuals' function being minimised by LSSolve and that used by DirectSearch:-SolveEquations(), they differ by a factor of 2. (i'm not sure why!). However it does mean that if these two methods found exactly the same 'solution', LSSolve would report the residual error as being exactly half of that reproted by SolveEquations().

And in this particular case

LSSolve residual error 0.960968723053680e-3
SolveEquations residual error  
1.921937446143878480084068181265523577652e-3

ie almost exactly the same if one allows for the afore-mentioned factor of 2 in the definition of the LSSolve() residuals function

Given that the residual errors for the two methods are therefore almost identical, it is somewhat depressing to observe that the solution vectors are completely different!

However I was hoping to avoid having to reproduce the DirectSearch() help page for the SolveEquations() command, since this explains the solution process, and the nature of the terms in the returned list.

The first term (ie the sum of the squares of the residuals) in the returned list, should be a "good" (floating point) approximation to zero - which it isn't. So I know that this is not a very 'good' solution.

However it is the best solution anyone has come with .. so far

I downloaded the RJLopez original worksheet from http://www.maplesoft.com/applications/view.aspx?SID=34940 and it works flawlessly.

Maybe if you uploaded your *changed* version, using the big green up-arrow in the Mapleprimes toolbar, someone here could figure out where you went wrong?

to start with the easy fixes, then work up t the complicated ones. Obviouosly I stop as soon as a 'fix' has been obtained.

On the subject of 'continuation' I wish I could come up with a systematic method. My general approach is to use the continution parmeter to

  1. make all odes 'homogeneous, and if that doesn't work
  2. eliminate  ther highrest order derivative

Given the conditions of your question,

identify(evalf(arcsin(1/2*(2+(2+(2+2^(1/2))^(1/2))^(1/2))^(1/2))));

is almost certainly cheating - but I'm a pragmatist

 

The inability to change font size (at all) in the 'debug' window - and on a high-res monitor, the text is really, really tiny.

I accept that many users will never actually fire up the debugger. I suspect that we have all done code debug in the following sequence

  1. Visual inspection of code - just read it (carefully!)
  2. Add the occasional print() statement somewhere near the suspected bug location
  3. Comment something out
  4. Hmm still can find the problem - better fire up the debugger

Having a debugger where it is almost impossible to read the output just adds to my irritation (when I am already annoyed by having written buggy code in the first place!)

You can try showstat(rsolve), but I'm not sure how informative you will find it!

There are many possible methods which can be tried for solving  recurrence relations.

See the "Solving" section in the Wikipedia article

https://en.wikipedia.org/wiki/Recurrence_relation

I imagine that Maple tries most/all of these methods (and maybe a few more)

 

but consider the following 'toy' examples

   restart;
#
# generate a random matrix for R0, just for
# illustrative purposes
#
   R0:=LinearAlgebra:-RandomMatrix(256,256):
#
# Average of all elements in Matrix R0
#
   add(R0)/numelems(R0);
#
# Generate a Matrix of 'r-values'
#
   dx1:=133:
   dy1:=132:
   rMat:= Matrix(op(1,R0), (i,j)->evalf(sqrt((i-dx1)^2+(j-dy1)^2))):
#
# Average of all elements in Matrix rMat
#
  add(rMat)/numelems(rMat);

 

using the big green up-arrow in the maleprimes toolbar

Matrix powering is by far the faster if one wants an individual, large term.

However if one wants to generate the sequence, from 1 to the same large term, then the recursive procedure with memoization wins (by a large margin)


 

Method 2: Matrix method via rsolve(..., makeproc).

restart:

r2:= rsolve({F(m) = 2*F(m-1) + 4*F(m-2), F(0)=2, F(1)=4}, F, makeproc):

CodeTools:-Usage(seq(r2(j),j=1..2^16)):

memory used=75.48GiB, alloc change=0.96GiB, cpu time=3.12m, real time=2.98m, gc time=20.72s

 

Method 3: Recursive procedure with memoization.

restart:

r3:= proc(n)
   r3(n):= 2*thisproc(n-1)+4*thisproc(n-2);
end proc:
r3(0):=2:
r3(1):=4:

CodeTools:-Usage(seq(r3(j), j=1..2^16)):

memory used=1.29GiB, alloc change=0.93GiB, cpu time=2.53s, real time=2.24s, gc time=1.40s

 

 


 

Download recurSeq.mw

When I said

" Last time I checked the directSearch download,

I actually meant " Last time I checked

And the last time I checked was probably 18months/2yrs ago. However I agree that .help files have now been added - according to the zip file the help files were added on 08/03/2016. Such a pity that the Maple Applications Centre still shows this product as having been published February 01 2011, with no subsequent updates.......

Last time I checked the directSearch download, its help files were in the old '.hdb' format, so these have to be converted to '.help' format for Maple versions 18 and later. See the help entry at

?Migrating Help Content from Versions of Maple Prior to 18

Maple has a Global Optimization Toolbox add-on which you have to pay for. I have never been able to justfy the cost, so I have never used this add-on, and therefore I'm not sure of its capabilities :-(

As Markiyan has pointed out the Direct Search package is free and can be downloaded from the Maple Application Centre. So you can download/install this immediately. The only problem people seem to have with this installation is conversion of the associated 'help' database. Maple changed the format of help files after DirectSearch was released. So DirectSearch help files have to be converted to the new format before they can be read. This is actually fairly simple. Detailed instructions can be found in this thread http://www.mapleprimes.com/questions/206551-DirectSearch-Help-Migration-Into-M2015

 

First 120 121 122 123 124 125 126 Last Page 122 of 207