Carl Love

Carl Love

28055 Reputation

25 Badges

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

MaplePrimes Activity


These are replies submitted by Carl Love

@emendes No problem. Let's name the procedure P.

P:= proc(f::list, vars::And(list, satisfies(vars-> nops(vars) = nops(f))))
     #...statements...
end proc:

There's no need for the parameter of the satisfies procedure to have the same name as the corresponding parameter of P, so that can be shortened to

P:= proc(f::list, vars::And(list, satisfies(v-> nops(v) = nops(f))))
     #...statements...
end proc:

Here's a third way, completely different:

P:= proc(f::list, vars::depends([anything $ nops(f)]))
     #...statements...
end proc:

In this way, it's the square brackets that force vars to be a list, the $ nops(f) that forces it to be a certain length, the anything is a primitive type that matches any single thing, and the depends is a keyword that signals that the type check for vars depends on f. For reasons that I don't understand, the depends isn't needed when the dependency is inside a satisfies.

Please let me know if you have any more questions.

@nidojan Okay, now we're getting somewhere. However, the errors are not quite the same. If you want me to take your question seriously, please point out how the two error messages are different. In the process, you may begin to understand the fundamental problem. Hint: It is a purely mathematical error; it has nothing to do with computer coding.

@nidojan Please post the corrected file. I don't feel like retyping your equation.

@nidojan Another problem is that in PDE, you take derivatives with respect to y; whereas the independent variables are x and t. Do you really need me to point that out?

@Carl Love Continuing from above, items 1 and 2 are handled by the list({name, name= anything}). Note that a disjunction of types is expressed with {...}. A conjunction of types is handled by And.

To check if the elements of a list are distinct, we construct the corresponding set and check if it has the same number of elements as the list. If v is a list, then nops(v) is its number of elements, and {v[]} is the corresponding set. Some members of v may be equations. From these, we to extract the left sides. The other members, we want to leave alone. A procedure that does this is (x-> `if`(x::name, x, lhs(x))). This mapped over the set is (x-> `if`(x::name, x, lhs(x)))~({v[]}), and the number of elements of that is nops((x-> `if`(x::name, x, lhs(x)))~({v[]})).

In the expression (n-> n=nops(f) and n=nops((x-> `if`(x::name, x, lhs(x)))~({v[]})))(nops(v)), the nops(v) is the argument that corresponds to the parameter n.

Please let me know if you have more questions.

@acer Just to make it absolutely clear for the other readers, by "Java garbage collector" you mean something distinct from the much-more-familiar kernel garbage collector, right? And one doesn't seem to have much control over this Java garbage collector, by, say, deleting visible objects like plots from worksheets.

Firefox (where I currently have 35 tabs open) is usually the number one memory hog on my computer, and Maple's Java GUI is usually number two.

@emendes Naturally, you have selected the most complicated part of the whole thing. I'll need to explain this a little bit at a time.

First, let's distinguish arguments and parameters. In the following four code snippets, x is a parameter, and y is the argument that corresponds to x:

  1. f:= proc(x) x^2 end proc;  f(y);
  2. f:= x-> x^2;  f(y);
  3. proc(x) x^2 end proc(y);
  4. (x-> x^2)(y);

All four examples define a procedure, and then evaluate that procedure at argument y. To understand the code that you asked about, you must understand that the end result of 4 is y^2.

In a parameter declaration, the part after the :: is a type. For the parameter v, I want to check several things:

  1. That it is a list.
  2. That each member of that list is either a name or an equation whose left side is a name.
  3. That the length of the list is the same as the length of f.
  4. That the names that constitute the members of the list or the left sides of the equations are distinct.

Items 1 and 2 can be handled by Maple's vast collection of predefined types. For 3 and 4, an ad hoc type is specified by the keyword satisfies, whose argument is a boolean-valued procedure.

That's all that I have time to write right now. More later.

 

 

@tomleslie Changing some operators to prefix form is an unfortunate effect of converting 2D input to 1D, which happens when you copy-and-paste. So X$n always gets converted to `$`(X, n) without it being directly the fault of the OP.

The use of square brackets in the second argument of diff allows for the degenerate case of a zeroth-order derivative to be specified. For example:

d:= Diff(exp(x^2), [x$n]);
v:= value(d);

     v := x^(-n)*2^n*MeijerG([[0, 1/2], []], [[0], [1/2+(1/2)*n, (1/2)*n]], -x^2)

simplify(value(eval(d-v, n= 0)));

     0

The above's last line would be syntactically invalid without the square brackets in the first line.

@dsh1

Well you better check yourself before you go accusing people of being wrong, because if you copy-and-paste this input

geom3d:-point~([A,B,C], [[8,3,-9], [-6,-6,-2], [6,9,-3]]):
geom3d:-line(L1, [A,B]):
geom3d:-line(L2, [C, [2,4,-1]]):
geom3d:-distance(L1,L2);

you'll get 2*sqrt(5), not (388/545)*sqrt(545).

@Niek There is no problem with your pi because of the reason described by Preben Alsholm above. If you were to try using pi without menus and the mouse, then it would be a problem.

The syntax for assuming that an object has a property uses `::` rather than `=`. For example, Assume(rho::constant). I doubt that this type of assumption would have any effect on dsolve.

@emendes The only two things that I can recommend are the Maple Programming Guide and asking Questions here. The Guide is available in the onboard help system. Just enter ?ProgrammingGuide.

If there's any specific point of syntax that you'd like to ask about, I'd be glad to answer.

@omer Using recursion, it can be done as a one-liner in modern Maple (and even in older Maple):

SumToOneDigit:= (n::posint)-> `if`(ilog10(n) < 1, n, thisproc(add(convert(n, base, 10)))):

I just post this as an example to show how recursion is done in modern Maple. Acer's and Joe's very-well-known mod trick makes this procedure obsolete.

@firmaulana Tom Leslie's code works for me. Please post a worksheet so that I can see what you're doing wrong. It is impossible to use if as you show, without quotation marks, and not get an error message.

@emendes In the vast majority of cases, a procedure should use named parameters rather than relying on args. Yes, you should use proc(f::list, vars::list, samp:= T). This makes samp optional with a default value of T.

See my Answer below for a solution to the problem of iterating a multivariate function multiple times with simplification at each step.

First 390 391 392 393 394 395 396 Last Page 392 of 709