Carl Love

Carl Love

28035 Reputation

25 Badges

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

MaplePrimes Activity


These are answers submitted by Carl Love

You need a percent sign with the T, like this:

a.a^%T;

A plus sign with no percent sign also works:

a.a^+;

You asked:

Does [Length of output exceeds limit of 1000000] mean that the function couldn't be solved and I have to modify the mathematical model?

No, it doesn't mean that. It means that the solution has been found, but is just too long to display.

If the results are just too long to be displayed, how can I see the results?

You should seriously reconsider your desire to see the results. They could be hundreds of pages long. I have seen one over 4000 pages long. Once you start the display, there is no way to stop it other than by killing the Maple process. The stop button does nothing in this case.

And, practically, what would you do with such a solution?

You should use definite integrals, not indefinite integrals that you then evaluate between limits of integration.

Examples:

int(int(r^2*cos(theta), theta= Pi/4..Pi/3), r= 15..18);

or

int(r^2*cos(theta), [theta= Pi/4..Pi/3, r= 15..18]);

The revelant commands are DEtools[DEplot] or dsolve followed by plots:-odeplot. If you have parameters, I think the dsolve odeplot route would be easiest. If you want more help, you'll need to post your system of ODEs, their initial conditions, and your desired values of the parameters.

This is a common operation---not at all a "strange question."

The ApproximateInt command, if given exact symbolic input, attempts to compute the exact value of the integral approximation. What you want is a floating-point approximation. To get such, you simply need to include a decimal point in the function or in the interval of integration:

f:= x^2/(sin(x)+x+1.;
Student:-Calculus1:-ApproximateInt(f, x= 1. .. 2., method= simpson, partition= 20);

This'll produce the decimal answer very quickly. Only one the decimal points above is needed.

To make plots go to a separate window, use the command

plotsetup(window);

These plots will look normal even if run from the command-line interface (that which you're calling maple-terminal).

One potential problem with this is that every plot goes to a new window, and I know of no programmatic way to close the windows. So, if you make 1000 plots, you'll have a 1000 open windows.

SimpleStack is an object-oriented module-based implementation; stack is a much older table-based implementation. SimpleStack has all the functionality of stack and some additional functionality. SimpleStack uses a more-familiar programming paradigm. I use SimpleStack exclusively.

Recursive procedures are very easy in Maple:

catalan:= proc(n::nonnegint)
option remember;
local k;
     add(thisproc(k)*thisproc(n-1-k), k= 0..n-1)
end proc:

#Put initial value in remember table.
catalan(0):= 1:

catalan(9);

     4862

By preloading the initial value into the remember table, we avoid the need to check for initial values in the procedure itself. This is more efficient.

A proper Maple function doesn't "print" a value; it returns a value. It's left up to the user whether or not to print the value.

 

`&ll`:= (a,b)-> 1/(1/a+1/b):
3 &ll 7;

In Maple, a^(1/3) is not real for a < 0. The real cube root is accessed by surd(a,3). So, change the plot command to

plot3d(surd(1-x^3-y^3, 3), x= -10..10, y= -10..10);

One way is to use the sequencing operator $:

1/2^k $ k= 4..8;

Although this operator is less efficient than the more common seq, it has the benefit of being capable of abstraction, which seq lacks:

MySeq:= 1/2^k $ k= a..b;


eval(MySeq, [a= 4, b= 8]);

Unlike seq, the k in the above expression should be either unassigned or placed in unevaluation quotes:

1/2^'k' $ 'k'= a..b;

When the number of equations is different from the number of variables being solved for, it's usually a bad idea to use solve. Use eliminate instead. The syntax is the same; just change solve to eliminate.

eliminate(
     [a = -(-y+1)/(x-y+2),
      b = -(-x^2+2*x*y-y^2-3*x+3*y-2)/(x-2*y+3),
      c = -(x*y-y^2-2*x+4*y-4)/(x*y-y^2-x+2*y-1),
      d = -(-x*y+y^2+x-2*y+1)/(x-2*y+3)
      ],
[x,y]
);

The second set is expressions that equal 0. So you can think of it as providing solutions for b and c.

You removed your code from your Question. That isn't a good sign.

Anyway, here is a very fast way to generate a large number of your random walks using directions sampled from your probability distribution.

 

restart:


Dirs:= Statistics:-Distribution(PDF= (phi-> cos(phi/2)/4)):
n:= 2^9: #walk length
N:= 2^4: #number of walks
DirBuffer:= Matrix((N,n), datatype= float[8]):
Walks:= Array((1..N,1..n,1..2), datatype= float[8]):


FillBuffer:= proc(B::rtable)
     Statistics:-Sample(Dirs, B, method= [envelope, range= -Pi..Pi]);
     [][]
end proc:


DoWalks_hf:= proc(W::Array, B::Matrix, n::posint, N::posint)
local k,K,phi;
     for K to N do
          W[K,1,1]:= 0:  W[K,1,2]:= 0:
          for k from 2 to n do
               phi:= B[K,k];
               W[K,k,1]:= W[K,k-1,1] + cos(phi);
               W[K,k,2]:= W[K,k-1,2] + sin(phi)
          end do
     end do
end proc:

DoWalks:= proc(W::Array, B::Matrix)
local n, N;
     FillBuffer(B);
     (N,n):= op(1,B);
     evalhf(DoWalks_hf(W, B, n, N));
     [][]
end proc:
     

CodeTools:-Usage(DoWalks(Walks, DirBuffer));

memory used=1.98MiB, alloc change=8.02MiB, cpu time=109.00ms, real time=111.00ms

 

(r,c):= trunc(sqrt(N))$2:
plots:-display(
     Matrix((r,c), (i,j)-> plot(<Walks[(i-1)*c+j,..]>)),
     thickness= 0, gridlines= false
);

 

Download RandDirWalk.mw

Array plots won't display in MaplePrimes, but you'll see in the worksheet that every walk is plotted on its own set of axes.

Regarding your followup question where you want to form the conjugate i*j*i^(-1) for every pair of elements i, j in A: It can be done like this:

B:= {seq(seq(PermConjugate(i,j), i= A), j= A)};

This computation takes about a minute because there are 705600 pairs. The end result is simply the set again (no surprise).

 

You can essentially enter them as in the book, and then make some substitutions: y to y(x), dy to diff(y(x), x) and dx to 1. Also, I've never seen arctg or tg. I just changed these immediately to arctan and tan, respectively.


13.1

eq:= sqrt(1-y^2)*dx+y*sqrt(1-x^2)*dy = 0;

(1-y^2)^(1/2)*dx+y*(1-x^2)^(1/2)*dy = 0

(1)

dSubs:= [dy= diff(y(x),x), dx= 1, y= y(x)];

[dy = diff(y(x), x), dx = 1, y = y(x)]

(2)

eq1:= eval(eq, dSubs);

(1-y(x)^2)^(1/2)+y(x)*(1-x^2)^(1/2)*(diff(y(x), x)) = 0

(3)

dsolve(eq1);

arcsin(x)+(y(x)-1)*(y(x)+1)/(1-y(x)^2)^(1/2)+_C1 = 0

(4)

13.2

eq:= x*y*dx+(x+1)*dy = 0;

x*y*dx+(x+1)*dy = 0

(5)

eq1:= eval(eq, dSubs);

x*y(x)+(x+1)*(diff(y(x), x)) = 0

(6)

dsolve(eq1);

y(x) = _C1*(exp(-x)*x+exp(-x))

(7)

13.3

eq:= x*(y^2+1)*dx+cos(x)^2*dy=0;

x*(y^2+1)*dx+cos(x)^2*dy = 0

(8)

eq1:= eval(eq, dSubs);

x*(y(x)^2+1)+cos(x)^2*(diff(y(x), x)) = 0

(9)

dsolve(eq1);

y(x) = -tan(x*tan(x)+ln(cos(x))+_C1)

(10)

13.4

eq:= x*y*arctan(x)*dx+(y^2+1)*dy=0;

x*y*arctan(x)*dx+(y^2+1)*dy = 0

(11)

eq1:= eval(eq, dSubs);

x*y(x)*arctan(x)+(y(x)^2+1)*(diff(y(x), x)) = 0

(12)

dsolve(eq1);

y(x) = 1/(1/LambertW(_C1*exp(-arctan(x)*x^2+x-arctan(x))))^(1/2)

(13)

dsolve(eq1, implicit);

(1/2)*arctan(x)*x^2-(1/2)*x+(1/2)*arctan(x)+(1/2)*y(x)^2+ln(y(x))+_C1 = 0

(14)

13.5

eq:= exp(x-y)*dy-dx = 0;

exp(x-y)*dy-dx = 0

(15)

eq1:= eval(eq, dSubs);

exp(x-y(x))*(diff(y(x), x))-1 = 0

(16)

dsolve(eq1);

y(x) = -ln(1-_C1*exp(x))+x

(17)

13.6

eq:= dy/dx = tan(y/x)+y/x;

dy/dx = tan(y/x)+y/x

(18)

eq1:= eval(eq, dSubs);

diff(y(x), x) = tan(y(x)/x)+y(x)/x

(19)

dsolve(eq1);

y(x) = arcsin(x*_C1)*x

(20)

 


Download 6_ODEs.mw

First 239 240 241 242 243 244 245 Last Page 241 of 395