Carl Love

Carl Love

28150 Reputation

25 Badges

13 years, 352 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are replies submitted by Carl Love

@Jeremyad 

I would say all that Acer said had I got to it first. I'm only replying now because I thought that I'd give an additional explanation of the need for unapply. Maple has two primitive constructors for procedures (aka functions[*1]):

(parameters)->  body (containing a single expression)

and

proc(parameters)
   header (possibly empty)  
   body (possibly containing multiple statements and expressions)
end proc

The first form is also called an arrow expression[*2]. Once formed, there's no practical difference between the two; indeed, the first form can always be readily and automatically converted to the second. In either case, any references to the parameters within the header or body must be direct and explicit. If there are indirect references, one must use another method to construct the procedure. The most common and most important of these is unapply, whose basic syntax is

unapply(
   single-expression body, possibly unevaluated, possibly containing indirect
      references to the parameters
,
   parameters
)

A second method uses subs to substitute expressions directly into existing procedures. This method is not limited to single expressions. It'd probably be best if I didn't delve further into this one now, but I'd be happy to when your need arises.

There are a few other methods of constructing procedures which are only suitable for expert users, most notably ToInert / FromInert. The vast majority of indirect reference procedures can be constructed by unapply. Of the remainder, the vast majority can be constructed by subs.

[*1] Function is the usual term for this in computer-science literature, and this corresponds somewhat to mathematical functions; however, in Maple usage, function has another, unrelated meaning (see help page ?type,function) as a one-dimensional, labelled, ordered container object.

[*2] These arrow expressions are also called lambda expressions in the terminology of functional programming.

@Rouben Rostamian  You used an arbitrary initial guess. Is there ever a situation where u(t0, x) (my generalization of u(0, x)) is not  the best choice of initial iteration?

@mmcdara I intentionally answered only the direct question asked by the OP, not the entire problem posed in the quote they gave. Now, I came back to this thread to followup.

@Adam Ledger Did you restart?

@asma khan It could be done like this:

M:= < 1, 2, 9;
      2, 3, 5;
      3, 4, 0 >
:
int~(M, t= -1..1);

It's not necessary to enter a matrix on multiple lines as I've done above. I just do that for clarity of presentation.

We can do the equivalent thing with fdiff. Here's your fdiff command:

fdiff(n*Zeta(n, 3), [n], n = 3);

We wrap any forced-integer argument with round:

fdiff(n*Zeta(round(n), 3), [n], n = 3);
      -0.3740436824

This works regardless of whether `diff/Zeta` has been modified as I suggested above because fdiff doesn't use diff anyway.

There is only 1 derivative with respect to x in your "PDE" system, and it's a first derivative. Thus 1 and only 1 condition with x fixed is allowed.

IMO, your system isn't a PDE system in the usual sense of "PDE" because each equation only has derivatives wrt a single variable. However, pdsolve(..., numeric) may solve it anyway, once you give reasonable boundary conditions. I'm curious to see. If not, then you'll need to use Preben's Heaviside workaround from the Q&A that you just linked to.

@Mariusz Iwaniuk It doesn't make sense to me to differentiate Zeta(n,z) wrt n because n is the order of the derivative. Do you mean a discrete derivative Delta(f, n) = f(n+1) - f(n)? If that's what you mean, it could be easily coded into Maple.

@Christian Wolinski The problem is that, unlike a procedure, the code of a module's "body" is not stored with the module. Indeed, it's not stored anywhere at all (other than possibly in a source-code document); it gets marked for garbage collection immediately after it's executed. All that's stored of a module is its header (as I show in my Answer below) and the values of its locals and exports at the time that the storage occurred. It's useful to keep that in mind when writing a module. Consequently, the vast majority of modules that I write either have no body at all, or the body is the single statement ModuleLoad() (whose only purpose to be in the body is to "kickstart" the module the very first time that it's run, which is useful for debugging).

@Adam Ledger 

See Donald E Knuth's The Art of Computer Programming. Specifically, half of Volume 2 is devoted to random number generators. If you were going to prison for a life sentence, and you could take just one book, this should be the one that you take.

@JAMET Did  you try making x, y, and i local like I told you to??

Your code above still works for me using the given H2 and H5.

@tomleslie The OP's code will not work if either x or y are assigned non-name values before the presented code is run. I suspect that this was the cause of the error message.

I haven't executed it, but I see nothing wrong. What makes you say that it's not working?

There is something strange, however: Why do you compute 200 iterations and only look at the 5th?

A month ago I showed you how to set up a tridiagonal stochastic matrix in one simple command. Why don't you use that here?

@mehdi jafari There's also a command VariationalCalculus:-EulerLagrange.

@Rouben Rostamian  

Whenever I install a new version of Maple, the first command that I give is ?updates. 

Thank you for the detailed explanation of the Sobolev space. Yes, the smoothing is remarkable. So, go ahead and change the sign of the second derivative; my code will work just as well.

First 268 269 270 271 272 273 274 Last Page 270 of 711