Carl Love

Carl Love

28055 Reputation

25 Badges

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

MaplePrimes Activity


These are answers submitted by Carl Love

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".

Use

eval(S1, t= 0.3)

or

S1P:= unapply(S1, t):
S1P(0.3)

The unapply turns it into a procedure and only needs to be done once. After that, the more-convenient S1P(...syntax can be used for the rest of the session instead of eval(S1, t= ...). Also, the unapply localizes the t so that things won't get messed up if it's inadvertently assigned a value at some point.

To check for a specific function, use type specfunc(...)---in this case specfunc(`odetest/PIECEWISE`). The type function is extremely common, and it's certainly not robust to check for it. For example, sin(x) is a function.

I'm not familiar with DTM, but the ms in both sums in the for loop seem suspicious to me, including the upper limits. I think that all 6 should be changed to k.

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