Carl Love

Carl Love

28025 Reputation

25 Badges

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

MaplePrimes Activity


These are answers submitted by Carl Love

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.

Getting Maple to do those computations is trivial, and there are many ways to do it. I show one way below. But there'll be great variation in the efficiency of those ways depending on how the input is supplied, and how your raw computation sequence is converted to a Maple procedure.

Getting Maple to write out a CSV file is also trivial, and it's done with the command

ExportMatrix(file namematrix name, 'target'= 'csv') 

(see help page ?ImportMatrix).

But I'm confused as to why you "have this file", which contains both one instance of the input data and the computation sequence.

  1. Would it be necessary for Maple to read and interpret the computation sequence from this file?
  2. Or could you just manually place the computation sequence in a Maple worksheet?
  3. Is it necessary that the input data come from such a file?
  4. Or could it come from a CSV file?

Suppose that your answers to 2 & 4 are "yes". Then you could do this:

restart:
MyFunc:= evalf@unapply(
   eval[recurse](
      <T | U>, #Output a 2-element row vector.
      #One of many ways to specify computation sequence:
      [T= E^2+G-sin(F), U= F+E-B, E= A*B, F= cos(A)+exp(B), G= 265/C]
   ), 
   [A,B,C] #Input parameters
):
Process:= proc(In::Matrix)
local n:= upperbound(In)[1], Out:= Matrix(n,2), k;
   for k to n do Out[k,..]:= MyFunc(seq(In[k])) od; #Process input row by row.
   Out
end proc
:
Data:= ImportMatrix( some file name , 'source'= 'csv');
ExportMatrix( some other file name , <Data | Process(Data)>, 'target'= 'csv');

If the answers to 1 or 3 are "yes", it's still possible, but I'll need details.

Is there anything wrong with 

has(expr, sqrt(x*y))

After 

infinies:= Infinitesimals(PDE)

do something like

infinies:= eval(infinies, [_F4= 0, _F3= 0, _F2= 1, _F1= (R-> a*R)])

Then, as you said, the Invariants will be much simpler; indeed, they'll fit on one line and contain no unevaluated integrals.

Note 1: Anywhere in Maple, an explicit numeric constant (such as or 1 above) can be used as if it were a constant function.

Note 2: The underscore characters are essential parts of the names _F1, etc., just as if it were an alphabetic letter.

Warning: The _Fs will not necessarily be numbered the same every time that you run this. I advise that you visually check it each time.

There are three problems that I see immediately, before even running your code:

  1. In your for loop, the four expressions on the left sides of the assignment operators each have an extra space after the function name. In others words, you need to change S (k+1) to S(k+1), etc.
  2. On the right sides of the assignment operators, you need to change all square brackets [ ] to parentheses ( ). Square brackets are never used for algebraic groupings in Maple (nor in most other computer languages).
  3. needs to have a value.
First 136 137 138 139 140 141 142 Last Page 138 of 395