Mac Dude

1571 Reputation

17 Badges

13 years, 114 days

MaplePrimes Activity


These are questions asked by Mac Dude

I have an equation as follows:

By inspection one can see that the last three terms can be simplified (factored) to

How can I coerce Maple to do this? None of the available tools seem to be getting close to this. A partial solution is like this: Writ a procedure as follows:

Fac:=proc(xpr,a,b);
  tmp:=xpr+(a^2+2*a*b+b^2);
  return tmp-(a+b)^2;
end proc;

and then call it:

Fac(lhs(eq),k0,2*Pi*n/L)=rhs(eq);

to get

which is what I want. But procedure Fac() is not general at all; e.g. it fails if the overall sign of the polynomial terms are different. There does not seem to be any way in Maple to determine the sign of a term in the sum of lhs(eq), I can only find ways to determine signs of a simple indeterminate. I'd like to make this procedure more general (which is trivial enough for a human) but I just cannot find any tools in Maple to support this.

Any ideas out there?

Mac Dude.

 

I have the following expression (obtained from an earlier calculation):

I want to collect all the terms under one summation. So I define a rule:

collectf:=proc(f)
A::algebraic*f(a::algebraic)+B::algebraic*f(b::algebraic)\
 +C::algebraic*f(c::algebraic)+D::algebraic*f(d::algebraic)=f(A*a+B*b+C*c+D*d);
end proc:

and then

applyrule(collectf(Sum),%);

I get

Error, (in +) unable to identify A::algebraic

I used similar constructs before so I think the rule is constructed correctly. I should, however, mention that I use the Physics:-Vectors package and in fact the expression I start up with here reads, in 1-d Maple inputform:

Physics[Vectors][`+`](Physics[Vectors][`+`](Physics[Vectors][`+`](-y*(Sum((diff(a[n](r), r))/(exp(I*Pi*n/L))^2, n))/r, (2*I)*(Sum(a[n](r)/(exp(I*Pi*n/L))^2, n))*k0), y*(Sum(a[n](r)/(exp(I*Pi*n/L))^2, n))*k0^2), -y*(Sum((diff(a[n](r), r, r))/(exp(I*Pi*n/L))^2, n)))

Is my problem related to the use of Physics:-Vectors? If so, how can I get around that?

TIA,

Mac Dude

I have a diff equation in cartesian coordinates I need to transform to a certain cylindrical system. The de looks like this:

I define my new system with addcoords like this:

addcoords('AccCylinder',[r,theta,y],[r*cos(theta),y,r*sin(theta)]); # Note: y is the longitudinal axis here!

and also do

VectorCalculus:-AddCoordinates('AccCylinder'[r,theta,y],[r*cos(theta),y,r*sin(theta)],overwrite) assuming r >= 0;

and note that I had to overwrite as my system was already known, so maybe addcoords is reduncant(?)

I then do the transformation ("(7)" is the label of my above de):

changecoords((7),[x,y,z],AccCylinder,[r,theta,y]);

and get

This may be correct, but it has the expressions in the differentials, which diff does not know how to handle. I need to convert things like diff(xpr,r*cos(theta)) = diff(xpr,x)*diff(x,r) where x would be r*cos(theta). I can do this "by hand", but that seems overly tedious and error-prone. Somehow I'd expect the coordinate transforms to be able to do this but I can't figure out how.

Any idea?

Thanks,

Mac Dude,

Hi, I have the feeling I ran into this before, but can't find the answer, so here goes:

I want to create an animated plot of a histogram, changing the range of data to be histogrammed. So I type:

plots:-animate(Statistics:-Histogram,[dR*~WindowN(RP0,Ci,CangleWidth+Ci),ignore=true],Ci=-0.5 .. 0.2);

The error I am getting is

Error, (in MathPad:-WindowN) cannot determine if this expression is true or false: Ci < HFloat(0.39995) and HFloat(0.0) <= -HFloat(0.34995000000000004)+Ci

What happens here is that dR is a Vector of data with RP0 being another Vector equally long. I have a library function called WindowN that returns a Vector of the same length as its argument, with 1. for the elements within the window, undefined for the elements outside. The windowing algorithm is just a straightforward if, in a loop over the elements. This all works and I get a correct Histogram plot if I set the window numerically and call Histogram. CangleWidth is preset to 0.05.

Here the window to use is supposed to be set by the animate command. I expect Ci to be set to numbers in the range given (25 points default) and prepare the plots. But it looks like the WindowN routine gets an unevaluated Ci. I tried evalf(Ci) or eval(Ci) in the arglist, to no avail. Ci is not used or set before this call to animate.

I can see how I can workaround this but I think this should work as is. plots:-animate works for me in other contexts.

Any ideas?

Mac Dude

I have two equations:

and I need to extract the coefficients of x0 and xp0 (to build a matrix; but that is not the issue). So I use coeffs:

coeffs(op(2,X),x0);

coeffs(op(2,XP),x0);

xp0

While I can live with the first result (for X) (not that I like it), the fact that the 2nd one (for XP) has a completely different structure prevents any kind of algorithmic extraction of the coefficients (and the second one of course is 0) for further use. I tried the form of coeffs with a third argument (a name which gets the result assigned) but the same result. This example is a real case, obviously a trivial one and others will be much more involved so I really would like this to work. And yes, I did "collect" before using coeffs (not that it was needed here).

Any ideas out there?

Mac Dude.

First 13 14 15 16 17 18 19 Last Page 15 of 23