Preben Alsholm

MaplePrimes Activity


These are replies submitted by Preben Alsholm

@Carl Love The chain rule is being used. x(t) is chosen as independent variable _a, _b(_a) is defined as diff(x(t),t).
Leaving out underscores then by the chain rule (and using epsilon=0 for simplicity):

db/da = (db/dt)*(dt/da) = x''(t)*(1/b(a)) = (x(t)-x(t)^3)*(1/b(a) .

Thus  b'(a)*b(a) - a + a^3 = 0. (*)

To get t we use dx/dt = b(a), thus using x(t)=a we get dt/da = 1/b(a) so that t = Int( 1/b(a),a) +C1.

The second constant C2 will appear when the ode (*) is solved.

Is it better than nothing? Good question, but at least the problem has been reduced to solving a first order ode and a subsequent integration. But t is then expessed in terms of a (i.e. x), t = t(x). So we have to invert to find x=x(t).
The stucture is described here:
??ODESOLStruc

@acer With the package LinearAlgebra both work:

restart;
eval(LinearAlgebra);
op(2,eval(LinearAlgebra));

I checked a few other packages, and found the same for

Statistics
Student
Units
LargeExpressions

There may be more.
####################### OK these are named modules ###################
To quote from the help page for named modules:
"Evaluating a named module definition causes, as a side effect, the assignment of the resulting module to the name, and the module name is stored in the attributes of each module member."



@Markiyan Hirnyk This seems to be endpoint problems caused by the fact that V(x,t) cannot be computed for values of x outside of the interval 0..1. Thus a two-sided limit cannot be computed by fdiff at x=0 or x=1.

V(1.00001,0.3);

Vx(0.99999,0.3);
fdiff(V,[1],[1,0.3]);
fdiff(V,[1],[0,.3]);
fdiff(V,[1],[0.0001,0.3]);
Vx(.0001,.3);

As it turns out your version has the same problem, since you exchanged the order of x and t in the definition of VVX.
I suppose you want
VVX := (b, a)-> fdiff(VV(x, a), x = b);
so that x is first as it is in V (and in your VV).

@northpole11 Here is a version, which is slightly different from Markiyan Hirnyk's.
Vx returns unevaluated for non-numeric input:

Vx:=proc(x,t) if not type([x,t],list(numeric)) then return 'procname(_passed)' end if;
   fdiff(V,[1],[x,t])
end proc;
Vx(.5,0.4567);
Vx(r,q);
plots:-animate(plot,[Vx(x,t),x=0..1],t=0..1);
plot3d(Vx(x,t),x=0..1,t=0..1);


@patient In the first few lines of your worksheet the definitions of eq1 and eqc has diff(w2,z) and diff(w2c,z) (respectively) on the right hand side. These will be evaluated to 0 and so eq1 and eqc will have zero right hand sides thereafter even if you later define w2 and w2c.
I guess that was not intended.
Solution: Replace w2 and w2c by w2(z) and w2c(z) in the equations defining eq1 and eqc.

I'm just guessing what you intend. The worksheet is without explanation and (at least to me) it is not obvious what you are trying to do.

@northpole11 In your worksheet example.mw the syntax for fdiff should be (example):

fdiff(V, [1], [.5, .4567]);
# or
fdiff(V(x, t), x, [x = .5, t = .4567]);


@tomleslie I'm sure I filed an SCR for the alpha-version present in Maple 18.02 probably in March.

@Rouben Rostamian  It is my experience after having tested quite a few examples from C.A.H. Paul, A Test Set of Functional Differential Equations (1994) that dsolve handles equations with delay dependent on y(t) quite well. That the plot always is wrong for t<t0 (start) I attribute to the implementation. Since the user knows that the history is constant (and what that constant is) this is not really a problem.
So maybe what is missing is a test for the delay becoming negative.

Although dsolve/numeric/delay assumes constant history (which we don't have here), we can easily get around that as will be seen here. The trick consists in differentiating the 'history' i.e. sin(t) and using a piecewise. Initially on an interval of length = Pi/2 (the delay) the equation is an ode, thus no history is required, just an initial condition. By the time we get to t=0 sufficient history has been built.

eq:=diff(y(t),t)=piecewise(t<0,cos(t),-y(t-Pi/2)):
res:=dsolve({eq,y(-Pi/2)=-1},numeric);
plots:-odeplot(res,[t,y(t)],-Pi/2..10);
plots:-odeplot(res,[t,y(t)-sin(t)],-Pi/2..10); #The maximal error is less than 1e-6.

I realize that you are using Maple 13, where solving delay differential equations numerically is not possible. It is in Maple 18 and Maple 2015.

@yemisi I know nothing about Block BDF.
But certainly it should be easy to modify Rouben Rostamian's Euler code to this new case. The major difference is that y(t) is not constant for t < 0, but equal to sin(t).
Something like this modification should work:

restart;
doit := proc(h, T)
  local n, y, i, t, y_arg, k;
  n := ceil(T/h);   # number of steps
  #Defining y for t <=0:
  for i from 0 to -ceil(evalf(Pi/2)/h) by -1 do y[i] := evalf(sin(i*h)) end do;
  for i from 1 to n do
    t := i*h;
    y_arg := t-evalf(Pi/2);
    # ... we convert that to a grid index  
    k := round(y_arg/h);
    # Euler's method:
    y[i] := y[i-1] - h*y[k]
  end do;
  return [seq([i*h, y[i]], i=0..n)];
end proc:
#Trying with stepsize h=0.01:
res := doit(0.01, 10):
plot(res, style=point, color=blue, symbol=point, labels=[t,y]); p1:=%:
plots:-display(p1,plot(sin(t),t=0..10));
############
Rouben Rostamian's code can be found here:
http://mapleprimes.com/questions/204395-DELAY-DIFFERENTIAL-EQUATIONS

You got plenty of response to your first problem. This problem has constant delay so is much simpler. In fact it can be solved symbolically.
Incidentally (but you probably know already) the solution is y(x) = sin(x) for all x.

######
When is your homework due?

@Markiyan Hirnyk When  I said my ddesolve I meant that it is my private software. The name ddesolve is surely not owned by anyone.

@Rouben Rostamian  I tried eq on my own ddesolve, which I have had for a while. I get a graph that is the same as Maple's dsolve up to 0.84 after which my code won't work (reasonably enough).
So what is going on in Maple for x>0.84 when the delay becomes negative?
One guess is that there is extrapolation going on, as there could be for x < 0. Try plotting for x < 0 where certainly  dsolve's algorithm for computing values for x > 0 assumes that y(x) = 1.
The blue curve is done with my ddesolve, the red with Maple's dsolve. Visual agreement for x > 0 (x<0.84), but a striking difference for x < 0.

@Carl Love While examining the beta-version of dsolve/numeric/delay which was in fact available in Maple 18, I found a problem with output=listprocedure, which makes me suspicious when that (or output=operator) is involved.

restart;
dde:=diff(y(t),t)=-y(t-(1+cos(t)));
res:=dsolve({dde,y(0)=1},numeric,output=listprocedure,delaymax=2);
Y:=subs(res,y(t));
plots:-odeplot(res,[t,y(t)],0..10); #OK
plot(Y,0..10); #OK
X:=Vector([seq(0..10,.1)]);
Y~(X);
#This is still broken in Maple 2015.1:
plot(X,Y~(X));
plot(Y,0..10);
## But this is fine:
plots:-odeplot(res,[t,y(t)],0..10);
##############################
###########
The image you show is basically the same in Maple 2015.1.
One wonders why the difference in the beginning is not roughly 0.
Clearly the understanding in dsolve/delay is that y(0) = 1 means that y(x) = 1 for x<=0. Comparing results from Maple's dsolve with other methods clearly shows that to be true. Plotting for x < 0 should not confuse you, but is likely to:
plots:-odeplot(res,[x,y(x)],-1..1);
#Maybe extrapolation is used?


@Rouben Rostamian  I cannot tell you,but surely it is a good question.

First 115 116 117 118 119 120 121 Last Page 117 of 231