Carl Love

Carl Love

28065 Reputation

25 Badges

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

MaplePrimes Activity


These are answers submitted by Carl Love

You cannot control the order that multiplicands appear in a `*` term.

If instead you use the inert multiplication operator %*, then the order will remain as you specified. For example,

add(x[indx[]]  %* e[indx[]], indx= indxes);

If you view the output with 2-D output (by setting interface(prettyprint= 2)), then it'll look reasonably normal.

You asked:

  • Am I correct in assuming that when the code I am using in the worksheet with is incorporated into a module in an mpl file and loaded, this will not be an issue?

That's absolutely NOT correct. This is a feature of the kernel, not of the GUI worksheet[*1]. You cannot control the order, period.

[*1] Although there may be cases where the order displayed in the worksheet output differs from the order in which `*` objects are stored in the kernel. This I am not sure about. Nonetheless, you cannot control the order that they're stored in the kernel, which is what matters. You can always inspect this order with the op command. 

Grid:-Map, the second method you show, is the correct way. 

Try issuing this command first:

interface(prettyprint= 2);

However, this should've been set correctly by default, so I wonder how it got set incorrectly.

The lambda calculus is fully implemented in Maple through the arrow -> operator.  For example

(x-> y-> x^2+y^2)(3)(4)

Very good Question. Vote up.

The keyword _rest represents all the extra arguments that don't correspond to a parameter. If there are no extra arguments, then _rest = NULL.

f:= proc(x,y,a:=1) a*x*y end proc:
g:= q-> q(x, y, _rest):
g(f), g(f,3);
      x*y, 3*x*y

Note that it's necessary here to give a a default vaiue, so I chose 1.

You can write the expression by

diff(w(x,t), [x$2, t$alpha])

But I don't know how to solve a PDE containing such a derivative.

The error message indicates that option 'outputs' should be set to a list. So, change outputs= x to outputs= [x] or outputs= [x(t)]

I don't have MapleSim, so I can't test. 

It can be done by direct integration:

simplify(int(t^a*exp(-t^2-I*w*t), t= -infinity..infinity));

-(((((-1)^a*I - I)*cos(a*Pi/2) - sin(a*Pi/2)*((-1)^a + 1))*CylinderD(a, -sqrt(2)*w/2) - CylinderD(a, sqrt(2)*w/2)*(((-1)^a*I - I)*cos(a*Pi/2) + sin(a*Pi/2)*((-1)^a + 1)))*2^(-a/2)*exp(-w^2/8)*sqrt(Pi))/(4*sin(a*Pi/2)*cos(a*Pi/2))

If you want the transform of exp(-t^2)/t^a, just change a to -a

Is this what you want?:

restart:
co:= blue:
plots:-animate(
   plot, 
   [['seq'([[20-i,0],[0,i]], i= 0..k)], color= co, thickness= 3],
   k= 0..20, frames= 21, paraminfo= false
);

If instead you'd like the line segments to have constant length (for example, to simulate a ladder being pushed up a wall), that can be done.

The command

combinat:-randcomb(A,3) 

will draw a sample of size 3 without replacement from A. Kitonum's method draws a sample with replacement. Both methods are valid, but their probability distributions (hypergeometric and binomial, respectively) differ significantly when the population A is small. You'll need to decide which correctly models your situation.

You say that odetest has "failed" just because it doesn't return 0. But the expression that it does return is in fact equal to everywhere except possibly for some singularities where it's undefined. So, is that truly a failure? Do you claim that your solution is valid for all x? Of course not. Your simplify(...(with no optional arguments) has not changed the meaning of the expression as an expression over the complex numbers. Rather, it has highlighted the singularities in such a way that diff (and hence odetest) treats them with more respect.

Here's a vastly simplified version of your example, illustrating exactly the same point just using diff, not odetest. Note that the expression e below is essentially a step function, so its derivative is 0 a.e.

restart:

e:= x*sqrt(1/x^2):

diff(e, x);

(1/x^2)^(1/2)-1/(x^2*(1/x^2)^(1/2))

simplify(%);

0

simplify(e);

csgn(1/x)

diff(%, x);

csgn(1, 1/x)

simplify(%, symbolic);

0

 

In some cases with similar starting expressions e, you'll end up with signum instead of csgn. The final result is the same.

So, my advice is that if you want to ignore the singularities (which is a fine thing to do), do your preliminary simplify(...(with no optional arguments), then odetest, then simplify(..., 'symbolic'). If you then don't have 0, then maybe you could call it a failure.

I think that it's just a coincidence that simplify(..., 'size') hasn't (yet!) produced for you an example of a similar phenomenon.

My opinion of simplify is that it's very robust with regard to preserving the full meaning of expressions. I've seen a few bugs in it over the years, but I don't recall any that changed the meaning of the expression over the complex numbers, unless that was explicitly requested.

Download csgn.mw

The following compact syntax works and achieves your same goal:

sa1:= pdsolve(pde, iv, numeric):-value(output= listprocedure);

Or, if you want to preserve the intermediary module, you could use an embedded assignment:

sa1:= (de:= pdsolve(pde, iv, numeric)):-value(output= listprocedure);

Are those good enough?

Do

evalindets(A,  typefunc(name, And(name, Not(mathfunc))), 0)

Specifically, the above substitutes 0 for all functions in A of the form f(x, y, ...) where f and all the arguments are simply names.

The problem doesn't really ask you to plot the line x=1. If it did, there are many ways to do it, one of which (implicitplot) is shown by DJJerome, and another of which (parametric plot) is shown in my Reply below. It being a vertical line complicates the syntax a tiny bit. Here's a way that just plots the function over the stated interval with the area A highlighted:

f:= x*exp(x^3):
plots:-display(plot(f, x= 0..1, filled), plot(f, x= -1..1));


 

[I was writing this while Acer was writing his similar Answer.]

It's trivial to create a custom binary (i.e., two-argument) operator[*1] to do what you asked for:

`&(`:= ()-> args[-1](args[1], args[2..-2]):

You might as well put the above in your initialization file (or in a custom library if you have one). Its usage is thus:

w2:= (sin(x)^2 + cos(x)^2) &( simplify;

or, if you wish to assign the left-side value also:

w2:=  (w1:= sin(x)^2 + cos(x)^2) &( simplify; 

Multiple arguments can be accomodated by putting them in parentheses on the left:

(x^2*y^3, y) &( degree;

Even when the left side is a single argument, it needs to be parenthesized in most cases.

Chains (compositions) of operations can be accomodated:

(sin(x) + cos(x))^2 &( expand &( simplify;

The name &( is my choice. You could make it almost anything that begins with &. See ?neutral for the complete rules. Many, including &(, won't work in 2-D Input, which I never use. But &a, etc., will work.

[*1] Maple calls these neutral operators. They can be used with or without definitions, but, to my mind, once they have definitions they're no longer neutral. So, I called them "custom binary operators".

First 136 137 138 139 140 141 142 Last Page 138 of 395