Preben Alsholm

13471 Reputation

22 Badges

20 years, 249 days

MaplePrimes Activity


These are answers submitted by Preben Alsholm

As far as I can see, there is no solution.

Try the following.

dsolve({ode2,v(0)=.01});
ode3:=subs(%,ode1);

Now the general solution of ode3 is found by

res:=dsolve(ode3);

and is

u(r) = sinh(sqrt(t)*r)*_C2/r+cosh(sqrt(t)*r)*_C1/r-1/(100*t)

The requirement that u(0)=.5 (i.e. finite for all t) forces _C1 = 0.

By letting r -> 0 we find 0.5=sqrt(t)*_C2-1/(100*t), so that

u(r) = 0.01*sinh(sqrt(t)*r)*(50*t+1)/(r*t^(3/2))-1/(100*t)

which clearly depends on t also when r=0.2, where your second boundary condition is given as independent of t.

The immediate problem is qwe > 0, 1. Did you mean qwe > 0.1 or ?

Next problem is that 'if ... then .." uses evalb which cannot determine if e.g. sqrt(2)>0. You could use evalf(qwe)>0.1 (or use 'is').

The linalg package is deprecated. LinearAlgebra has got what you need.

No need to repeat with(Optimization).

Here is a way. Not particularly elegant, but it works.

A:=LinearAlgebra:-RandomMatrix(3,4);

#This is a way to get the 2nd column
A[1..,2];

#The matrix after applying f to each column
Matrix(f~([seq(A[1..,i],i=1..4)]));

#A very simple example
g:=v->5*v;
Matrix(g~([seq(A[1..,i],i=1..4)]));

You could use of LinearAlgebra:-Column(A,i) instead of A[1..,i].

There must be more to it. I think you need to tell us how B and inter are defined.

The following simpel version works as expected.

for q to 12 do inter[q]:=q end do:
B:=6:
for q  from 1 by 1 to 12 do;
   if inter[q] <= B then xz[q] := inter[q] end if;
end do;

for q to 12 do xz[q] end do;

The initial conditions for the derivatives must be given as follows:

D(x)(0) = 15, D(y)(0)= 1, D(z)(0) = 0

When that change has been made you get a solution and a plot of all 3 together can be obtained e.g. this way

plots:-odeplot(sol1,[[t,x(t)],[t,y(t)],[t,z(t)]],0..10);

With k just a name p(k) evaluates to 0 in Maple. Thus so does  sum(p(k), k = 1 .. 1), since sum obeys normal evaluation rules.

Delaying evaluation by using unevaluation quotes solves the problem.

sum('p(k)', k = 1 .. 1);

add on the other hand has special evalution rules (like seq does) so here no quotes are necessary:

add(p(k), k=1..1);

In your first loop you define theta[k+1], but since that involves theta[k+1] itself (for i = 0) you need theta[k+1] to be known already. But it isn't. To begin with only theta[0] is known. So when k = 0 you are attempting to define theta[1] from theta[1], which leads to the infinite recursion error.

eq:=diff(u(r,t),t)=diff(u(r,t),r,r)+diff(u(r,t),r)/r+u(r,t)+f(r,t);

##
#Picking as an example f(r,t)=r^2*t
##

res:=pdsolve(eval(eq,f(r,t)=r^2*t),{u(r,0)=0,u(0,t)=t^2,u(2,t)=0},numeric);
res:-plot(t=1,title="The solution at time t = 1");
res:-animate(r=0..2,t=0..3,title="t=%f");
res:-animate(t=0..3,r=0..2,title="r=%f");

If f is defined as a function ( and if I understand your intention correctly) you could use D as in this example,

f:=sin:
plot(D(f)(2*Pi/z),z=1/(2*Pi)...60/(2*Pi)); # plots the derivative

plot(f(2*Pi/z),z=1/(2*Pi)...60/(2*Pi)); # plots the function itself

The plot looks like the plots produced by the command line version of Maple, cmaple.

I have seen this phenomenon occur in Maple 14 on a few rare occasions for no apparent reason. I can't reproduce it though, since I have no clue why it happens when it does. I tried your code and the result was just fine in both Maple 14 and 15.

Your code stripped of output:

with(plots);
homo_data:= [[0.07143, -5.27798], [0.03571, -5.09811],[0.02381, -5.04314], [0.01786,-4.95879]];
lumo_data:= [[0.07143, -2.0953], [0.03571, -2.52144],[0.02381, -2.62239], [0.01786,-2.79138]];
homo_eqn:= -12.94151*sqrt(1-0.85175*cos(Pi/(N+1)));
eval(homo_eqn, N=infinity);
lumo_eqn:=homo_eqn+15.90268*sqrt(1-0.98083*cos(Pi/(N+1)));
gap_data:=[[0.07143, 2.9816], [0.03571, 2.3132],[0.02381, 2.1291], [0.01786, 2.0525]];
display([pointplot(homo_data),pointplot(lumo_data),plot([[1/N,homo_eqn(N),N=14..10000],[1/N,lumo_eqn(N),N=14..10000]], labels = ["1/N","E in eV"])]);

Try those lines in a new worksheet and see what happens.

After option package;  insert the line

uses plots;

Then all procedures in the plots package can be used with their short names, e.g.  display instead of plots:-display.

(A comment: The redefinition of `plots/animate` is not necessary in Maple 15, but is in earlier versions).

(rhs@op)~([a]);

For concrete values of m and n it is no problem, so if that suffices you don't have to do much:

ode:=diff(f(x),x,x)+f(x)^n=0;
f:=x->sum(u[i](x)*p^i,i=0..m);
ode;
eval(ode,{m=3,n=2});
collect(%,p);

Does this happen after a restart?

And a comment: If you want to plot sin on the interval -10..10 the syntax is

plot(sin(x), x=-10..10);

You can animate animate itself.

A not very exciting example:

animate(animate,[plot,[b*x^a,x=0..1,caption=typeset("a = ",a,", b = ",b)],a=0..5,frames=10,paraminfo=false],b=1..2,paraminfo=false,frames=5);

First 134 135 136 137 138 139 140 Last Page 136 of 158