Carl Love

Carl Love

28055 Reputation

25 Badges

12 years, 356 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are replies submitted by Carl Love

@ecterrab You wrote:

  • I am a non-native-English speaker...

But I suspect that you've lived primarily in the English-speaking world longer than nm has been alive, so it's not quite the same thing.

  • ...but I don't see what would be wrong with this use of "work as well" in this sentence of this help page.

There's nothing at all wrong with it if the intended audience is people fluent in spoken English. But the intended audience should be considered to include those whose primary exposure to English is written technical literature and technical online forums rather than speech. There are 2 or possibly 3 reasons why as well may not be the best choice for this broader audience:

  1. The phrase as well is idiomatic, which means that its meaning cannot be deduced from the meanings of its individual words. Indeed, in archaic usage it was a single word: aswell.
  2. It's primarily used in spoken English; in written English, it's usually replaced by also (if it means also).
  3. As used in the help page, it appears in the middle of its clause. That's a bit awkward; when it means also, it usually appears at the end of its clause (except possibly in Canada).
  4. (Doesn't apply to this example.) Its spoken usage is slightly different in Canada, where it may be used at the beginning of a sentence.

And by no means am I implying that you should've known any of this when you were writing that help page! I believe that editing such material for a technical, international audience can only be done by a professional technical editor.

Just for the record, the phrase in question is "works as well", not "work as well". However, all the points that I made above would apply to either phrase.

@Arif Ullah khan You wrote:

  • I face another issue here that when we choose a particular value for B, then for different values of infinity we get different solutions. It seems that infinity play a role of parameter here.

Yes, but I see that as the best thing about this algorithm. Since the equations are being numerically solved as IVPs rather than BVPs, it is trivial to simply keep extending the right boundary until the value of the second derivative  stabilizes (to within, say, epsilon = 0.5e-4 = 4 digits). This stable value is what the author calls C or C(B) (or with an overbar in the case of the 2nd equation). Finding a good value for the fake infinity is often the most challenging part of solving these boundary-layer BVPs.

So you need to get used to not using a fixed value for the fake infinity. The suitable value will depend on the parameters.This would be much more difficult to do with either a mesh-based BVP solver or a shooting method. 

 

@rlopez The worksheet's Startup Code contains

restart:
with(plots):
with(plottools):

To view the Startup Code, go to the Edit menu, and it's near the bottom of that menu.

The streams command does work to produce a plot from the 2-variable scalar function V. (I'm not claiming that this plot has any significance to the physical problem being considered. It's just a correct plot of a specific mathematical function.) The problem arose when trying to plot the gradient of V.

@9009134 Okay, you mean that you a vector-field plot of the gradient. That's doable.

To understand my last comment, you need to look at the code of procedure streams by expanding the Code Edit Region in the worksheet that you posted. Here it is:

streams:=proc(n,fcn,pts,name) 
       local f,k,DISK,p; 
       f:=transform((r,th) -> [r*cos(th),r*sin(th)]): 
       DISK:=disk([0,0],1,color=red); 
       for k from -n by 2 to n do 
             p[k]:=implicitplot(fcn=2*k/n,x=-n/2..n/2,y=-Pi..Pi,numpoints=pts): 
       od: 
       display(seq(f(p[2*i]), i=-n/2..n/2), DISK, view=[-n/2..n/2,-n/2..n/2], scaling=constrained, axes=boxed, title=name); 
end:

As you can see, it uses implicitplot​​​​​, which is not a command that can plot a vector field.

Here's how to plot the gradient. Take out (or comment out) the lines

with(Physics[Vectors]):
Setup(mathematicalnotation= true):

Use these lines:

dV:= VectorCalculus:-Gradient(V, [x,y]):
plots:-fieldplot(dV, x= -2..2, y= -2..2, fieldstrength= log[10]);

There are many options to control the appearance, size, and relative size of the arrows. See help page ?plots,fieldplot for details.

I don't know what you mean by "plot the gradient". Your is a function of two variables. Thus its gradient is a vector of two functions, each of two variables. What does it mean to plot such an object? In addition, the 2nd parameter of procedure streams is fcn. If fcn is passed a gradient--a vector--then what does fcn = 2*k/n mean?

@radaar Let me know if you need any help with those changes.

Still, I'd like to know what was your intention with the "three-level" stuff? There are higher-order analogs to Newton-Raphson that involve higher-order derivatives (thus they are difficult or impossible to apply to multivariate functions). These are called Householder methods, which you can look up in Wikipedia. Was that your intention? If they converge, they do so even faster (measured by iteration count) than Newton-Raphson, but they can become either numerically unstable or slow if those higher-order derivatives are excessively complicated.

The help page says "works as well", but I think that you misinterpretted that as "works well". In idiomatic English, those phrases mean very different things. Works as well means works also in this context. As well is an idiomatic expression with several meanings not related to the usual meaning of well.

To add to the confusion, if the phrase were works as well as <any noun phrase>, then the well would be meant in its usual sense. But if it were works as well as <any verb phrase grammatically parallel to "works">, then it would mean works and also <verb phrase>.

It would be helpful for the non-native-English audience if a professional editor removed such idioms from the help pages.

@itsme A lot of what you're asking for is already implemented in Code Edit Regions. Look for it on the Insert menu.

My wish for Code Edit Regions is quite simple: When they're executed, and there's a syntax error, I'd like the cursor to be placed somewhere near the error.

@ActiveUser To color them with specified colors, do

plot(map(ListTools:-Enumerate, LL), color= [red, blue, green]);

 

@mmcdara It's clear (at least to me) that the OP is referring to 3 lists of real numbers, not 3 lists of (x,y) pairs. If you're starting with lists of (x,y) pairs, then neither method guarantees that the "x-axis represents time 1, 2, 3, ...."

@vv Okay, here's an overload for all rational fractions (positive and negative):

restart:
`Psi/original`:= eval(Psi):
unprotect(Psi):
Psi:= overload([
    proc(r::fraction, $)
    option overload;
    local n, f, p, q, k;
        if r < 0 then return thisproc(-r) - 1/r - Pi*cot(Pi*r) fi;     
        (p,q):= (numer,denom)((f:= r - (n:= trunc(r))));
        simplify(
            q*add(`/`~([seq](p..(n-1)*q+p, q))) +
            2*add(cos(2*Pi*k*f)*ln(sin(Pi*k/q)), k= 1..iquo(q-1,2)) - 
            Pi/2*cot(Pi*f) - ln(2) - ln(q) - :-gamma
        )
    end proc,

    `Psi/original`
]):
protect(Psi, `Psi/original`)
:

 

What is the point of doing 3 identical iterations within each main-loop iteration?

After the 3rd main-loop iteration in your example, you have detectable convergence. This should be your criterion for ending the loop and returning a value.

You should compute the symbolic gradient and hessian just once. This will save a lot of cpu time.

Your code will need to be modified a little for multivariate functions. In particular, you'll want to solve a linear system with LinearAlgebra:-LinearSolve rather than divide by the hessian.

You happened to converge on the local minimum. With a different starting value, you may as well have converged on the local maximum. Optimization:-Minimize also converges on the local minimum, not the absolute minimum in the interval -2..2.

@radaar It looks to me like this algorithm cannot be easily modified for multivariate functions. The algorithm's author, Calvin, states directly in the paper's title that it's "a one-dimensional optimization algorithm".

This algorithm is intended primarily for functions that are nowhere differentiable (because they have a noise component). It is much slower than minimization algorithms intended for the usual differentiable functions.

@Gabriel samaila You can extract the numeric data from a Maple plot as a matrix or an array (or perhaps a collection of matrices or arrays if multiple pieces in the plot). Then use ExportMatrix. See its help page for information on exporting to Matlab format.

If you show the Maple command that makes the plot, I can give more details.

Or you cam use your own Maple code to generate a matrix or array and then use ExportMatrix.

There is no reasonable method that uses print. You could use fprintf to print numbers to a file, and perhaps that would be a tiny bit more efficient if done expertly, but ExportMatrix is much more convenient.

@vv Thanks. I only intended it for r > 0, as can be seen from the procedure header.

First 165 166 167 168 169 170 171 Last Page 167 of 709