dharr

Dr. David Harrington

8270 Reputation

22 Badges

20 years, 360 days
University of Victoria
Professor or university staff
Victoria, British Columbia, Canada

Social Networks and Content at Maplesoft.com

Maple Application Center
I am a retired professor of chemistry at the University of Victoria, BC, Canada. My research areas are electrochemistry and surface science. I have been a user of Maple since about 1990.

MaplePrimes Activity


These are answers submitted by dharr

If you work out Theta[k] and Phi[k] for k=2 nd 3, then you can use a single loop from 4 to M for Theta[k], Phi[k], F[k]. (I shouldn't really cut and paste to duplicate lines here.)

Solution_1-dharr.mw

 

as @mmcdara pointed out, you van specify ranges in which to search for solutions. You can also use the avoid option to not get the same solution, e.g. after ans1:=fsolve({f, g}); you can use fsolve({f, g},{x,y},avoid=ans1); to get the second solution.

plots:-complexplot(exp(I*theta),theta=0..2*Pi);

put the plot in a variable, e.g., p1:=plot(x^2,x=0..3):

and then lprint(p1);

Even though the first two seem to be interpreted as 2-D integrals, the correct syntax for 2D integrals needs the variables and ranges in a list (or nested 1D integrals), like

simplify(Int(integrand, [phi = 0 .. 2*Pi, r = 0 .. 2]));

and then you get the correct answers. 

You have two first order equations, so if you know omega[0] and sigma, you need only two initial conditions. Put them as a sequence not as a list to solve the syntax error. So give omega[0] and sigma values then

ICS:=C(0)=0,A(0)=1:
sol:=dsolve({C_t,A_t,ICS},{C(t),A(t)},type=numeric):
pRange:=0..20:
plots:-odeplot( sol, [t, A(t)],t=pRange, numpoints=10000 );  #note A(t) not A

If you want to find the values of omega[0] and sigma by specifying two additional conditions, then I think that only works with boundary value problems, and you have only initial conditions. Note also the syntax for derivative conditions

is D(C)(0)=0 for derivative zero at time zero 

 

I think dchange existed in Maple V, so try

integral := Int(2*(sin(theta)/cos(theta))^(2*p-1), theta = 0 .. (1/2)*Pi);
PDEtools[dchange]({theta=arctan(t)},integral);
value(%);

gives Pi*csc(Pi*p) (in Maple 2017)

 

add the option range=-1..1 as the second argument to HeatMap works for me in Maple 2017.

The 'ps' driver (not 'eps) is supposed to be uncolored by default, but didn't seem to be. Using color=none is black and white,  but for me it produces a black background with white text and lines. Using color=gray gave a gray plot line, but no axes or text.

So adding color="Black" in the display command to override default plot colors should be an alternative, but if colors were given in the plot command, then you probably have to edit the plot structure.
 

The general solution can be (partly) obtained as below. Here sqrt(_c[1]) is n, but to get this you need to know that the function is periodic in theta (trying u(r,theta)=u(r,theta+2*n*Pi) doesn't work). To keep the solution finite at the centre of the disk you have to set _C2=0, and again you have to manipulate with Maple further to decide this.

pde:=diff(u(r,theta),r$2)+1/r*diff(u(r,theta),r)+1/r^2*diff(u(r,theta),theta$2)=0;
sol:=simplify(pdsolve(pde,u(r,theta),HINT=`*`,build));

diff(diff(u(r, theta), r), r)+(diff(u(r, theta), r))/r+(diff(diff(u(r, theta), theta), theta))/r^2 = 0

u(r, theta) = (_C3*sin(_c[1]^(1/2)*theta)+_C4*cos(_c[1]^(1/2)*theta))*(_C1*r^(_c[1]^(1/2))+_C2*r^(-_c[1]^(1/2)))

 


 

Download PDE2.mw

Using HINT=`*` forces the product form, and then you can implement another BC. Edit: added the 2nd BC "by hand"

restart;
pde:=diff(u(r,theta),r$2)+1/r*diff(u(r,theta),r)+1/r^2*diff(u(r,theta),theta$2)=0;
bc:=u(a,theta)=cos(theta);
sol:=pdsolve([pde,bc],u(r,theta),HINT=`*`);

diff(diff(u(r, theta), r), r)+(diff(u(r, theta), r))/r+(diff(diff(u(r, theta), theta), theta))/r^2 = 0

u(a, theta) = cos(theta)

u(r, theta) = cos(theta)*(_C2*_C4*a^2-_C2*_C4*r^2+a*r^2)/(a^2*r)

Will be finite at r=0 if _C2 and _C4=0

sol2:=u(r,theta)=eval(rhs(sol),{_C2=0,_C4=0});

u(r, theta) = cos(theta)*r/a

pdetest([sol2,bc],pde);

0

 


 

Download PDE.mw

As the others have implied, a lot depends on what you consider simple. For the last one I like

Student[Precalculus]:-CompleteSquare(k^2+2*k+9); which gives (k+1)^2+8

and for the rational functions I like continued fractions:

convert((k-2)*(k^2+5)*(k^3-k^2+7*k+8)/(6*k*(k^2-3*k+8)),confrac,k);

 

 

The second sqrt argument k^4-10*k^3+37*k^2-60*k+180 can be simplified to (k-2)^2*(k-3)^2+144. The first one is harder.

restart;

y:=k^4-10*k^3+37*k^2-60*k+180;

k^4-10*k^3+37*k^2-60*k+180

y1,y2,y3,y4:=solve(y,k);

5/2-(1/2)*(1-48*I)^(1/2), 5/2+(1/2)*(1-48*I)^(1/2), 5/2-(1/2)*(1+48*I)^(1/2), 5/2+(1/2)*(1+48*I)^(1/2)

simplify((k-y1)*(k-y2));
simplify((k-y3)*(k-y4));

6+12*I+k^2-5*k

6-12*I+k^2-5*k

factor(k^2-5*k+6);

(k-2)*(k-3)

simplify(((k-2)*(k-3)+12*I)*((k-2)*(k-3)-12*I));
simplify((k-2)^2*(k-3)^2+144);

k^4-10*k^3+37*k^2-60*k+180

k^4-10*k^3+37*k^2-60*k+180

z:=k^6-12*k^5+64*k^4-198*k^3+448*k^2-636*k+369;

k^6-12*k^5+64*k^4-198*k^3+448*k^2-636*k+369

solve(z,k,explicit=true);

RootOf(_Z^6-12*_Z^5+64*_Z^4-198*_Z^3+448*_Z^2-636*_Z+369, index = 1), RootOf(_Z^6-12*_Z^5+64*_Z^4-198*_Z^3+448*_Z^2-636*_Z+369, index = 2), RootOf(_Z^6-12*_Z^5+64*_Z^4-198*_Z^3+448*_Z^2-636*_Z+369, index = 3), RootOf(_Z^6-12*_Z^5+64*_Z^4-198*_Z^3+448*_Z^2-636*_Z+369, index = 4), RootOf(_Z^6-12*_Z^5+64*_Z^4-198*_Z^3+448*_Z^2-636*_Z+369, index = 5), RootOf(_Z^6-12*_Z^5+64*_Z^4-198*_Z^3+448*_Z^2-636*_Z+369, index = 6)

 


 

Download sqrts.mw

Your answer to @Preben Alsholm  suggests you are using a table, not an array. Then the following works:

restart;

for i from 1 to 5 do
  for j while j^2+i < 20 do
  A[i, j] := i+2*j ;
end do: end do:

type(A,table);
type(A,Array);

true

false

print(A);

A

L:=[indices(A)];

[[1, 3], [2, 3], [3, 3], [4, 3], [1, 1], [3, 1], [4, 1], [5, 2], [3, 2], [1, 4], [5, 1], [2, 2], [4, 2], [1, 2], [2, 1], [5, 3], [2, 4], [3, 4]]

f:=(x,pair)->evalb(x=pair[1]);

proc (x, pair) options operator, arrow; evalb(x = pair[1]) end proc

ListTools:-Occurrences(3,L,f); #number of A[3,j]

4

 

Download Occurrences.mw

Under help for list (in Maple 2017.3), we find:
"Lists and sets can be nested, in which case selection can be done in one of two ways:  S[i][j]...[n] or S[i,j,...,n]."

This seems to allow the interpretation of m[[1,2],2] as m[[1,2]][2] though it is very confusing.

First 67 68 69 70 71 72 73 Last Page 69 of 82