Rouben Rostamian

MaplePrimes Activity

These are replies submitted by Rouben Rostamian

Here is a reply to my own reply.  In the code above, under the PS, I noted that f(b_) returns [b_, 0] while it should have returned [0,b_].  Tracking down the source of the error, it turns out that it is due to the following.



type(b_, PhysicsVectors);


type(b_, scalar);


So Maple considers b_ to be both a scalar and a vector!  One way to get around this is by testing b_ for Vector before testing it for scalar.  Then the outputs (1), (2), and (3) in the worksheet below are correct, but the final calculation is still problematic due to the blurring of scalar and vector zeros.



This proc accepts a scalar, a vector, or a list of [scalar,vector]

for its argument.  In all cases, it returns a list of [scalar,vector].

f := proc(p::{scalar,PhysicsVectors,[scalar,PhysicsVectors]})
    if type(p, PhysicsVectors) then return [0,p];
    elif type(p, scalar) then return [p, 0];
    else return p;
    end if;
end proc:


[a, 0]



[0, b_]



[a, b_]



Error, invalid input: f expects its 1st argument, p, to be of type {scalar, PhysicsVectors, [scalar, PhysicsVectors]}, but received [a, 0]




Hello again, Edgardo,

Your response arrived as I was preparing to post an extended explanation for why I am asking the question, and why I need to distinguish between a scalar zero and zero vector.  Have a look at this:



This proc accepts a scalar, a vector, or a list of [scalar,vector]

for its argument.  In all cases, it should return a list of [scalar,vector].

f := proc(p::{scalar,PhysicsVectors,[scalar,PhysicsVectors]})
    if type(p, scalar) then return [p, 0];
    elif type(p, PhysicsVectors) then return [0,p];
    else return p;
    end if;
end proc:


[a, 0]


[b_, 0]


[a, b_]


Error, invalid input: f expects its 1st argument, p, to be of type {scalar, PhysicsVectors, [scalar, PhysicsVectors]}, but received [a, 0]

I have been doing the equivalent of this with the LinearAlgebra package but I would rather transition to Physics[Vectors] for the reasons that you have explained .  My attempt, however, to convert everything from LinearAlgebra to Physics[Vectors] failed right near the beginning for the reason shown above.

I may be able to work around the issue by blurring the semantical differences between scalar and vector zeros, but I am afraid the resulting code will be ugly.  Your suggestion of OR(0,PhyicsVectors) seem promising.  I will try it out tomorrow and report what I find out.


PS:  Opps, in the code above we see that f(b_) return [b_, 0].  It should have returned [0,b_].  I will have to find out why tomorrow.  It's past midnight here.

Hi Edgardo, that's excellent.  It would be good to have the documentations of that and the other Physics types available in an easy-to-find place in the help pages, although I understand that documenting 114 types would be a monumental task.

Now that I know how to check for PhysicsVectors in the arguments of a proc, I have run into a new problem.  It appears that multiplying a Physics Vector with zero results in the scalar zero rather than the zero vector.  Shouldn't there be a zero vector in the Physics package?  In contrast, in LinearAlgebra, multiplying a Vector by zero results in a zero vector, not the number zero.

The lack of the zero vector in the Physics package has the following adverse consequence:




f := (v_::PhysicsVectors) -> v_ . v_;

proc (v_::PhysicsVectors) options operator, arrow; Physics:-Vectors:-`.`(v_, v_) end proc






Error, invalid input: f expects its 1st argument, v_, to be of type PhysicsVectors, but received 0


I can't tell whether there may or may not be an easy fix for this. In any case, want to bring this to your attention.


@tomleslie Thanks for the details.  It shows that I am not just imagining things.  Sometimes the graph is colored black, even in Maple 2022 on my machines.  I need to do some more work to get to the bottom of this.

@Christopher2222 Thanks for your demo.  It shows that I am not just imagining things.  Sometimes the graph is colored black, even in Maple 2022 on my machines.  I need to do some more work to get to the bottom of this.

@acer Thanks for checking this.  My problem may be due to a bug in my Linux distribution (I am using Ubuntu MATE).  I am thinking of booting another distribution of Ubuntu from a flash drive, installing Maple, and seeing how that works.

@Scot Gould Thanks again for checking my test file.  It's become a puzzle for me.

As to your dual-monitor setup, I have no experience with such things.  Perhaps if you ask, they may offer an explanation.

Thank you Christian WolinskiScot Gould, and tomleslie for looking into this. I have examined the details of the troublesome plot structures and reduced them to a minimal form that still exhibits the issue.  As before, specifying two distinct colors produces the expected result but specifying two identical colors results in one of the two graph being rendered in black.  Here is the minimal file:

I have tried this on three computers with three different graphics cards, and different versions of Ubuntu Linux.  Perhaps this issue is specific to Linux?  I am stymied.

@delvin You are writing D^alpha * u(x,t) for the derivative of order alpha of u(x,t).  That's far from correct.  Here are a few observations.

  1. Your notation does't say whether that's derivative with respect to x or t. How is Maple to know which do you mean?
  2. The asterisk in your notation indicates multiplication.  But you don't mean to multiply D^alpha and u(x,t).  What is needed there is a differentiation operator acting on u(x,t), not a multiplication.
  3. The notation D^alpha means D raised to the power alpha.  But you don't mean to exponentiate D here, do you?  You mean to compose D by itself alpha times.  The Maple notation for that is D@@alpha.
  4. But knowing that won't help you since the D@@alpha notation does not say whether it is a derivative with respect to x or with respect to t.
  5. Furthermore, the notation D@@alpha is valid only for integer values of alpha.  But your alpha is a fraction, so you should forget about the D operators altogether.
  6. Fractional order derivatives are calculated through the fracdiff command in Maple as I illustrated in my original reply.

The problem that you are attempting to solve is far too advanced for a beginner user of Maple.  You should start with much simpler problems to learn about Maple's syntax.  Since you are interested in differential equations, you should get a firm grasp of the differential operator D.  Try analyzing some basic ordinary differential equations.  Then try some classical partial differential equation, such as the heat and wave equations and compare your results to what you have learned from textbooks.

Take up fractional differential equation only after you have gained mastery of the classical ones.  But don't expect that to happen quickly.  These things take time to learn. 

Here is what is being asked.  My brief attempt to verify the assertion was not successful.

Consider the fractional Burgers' equation:

fracdiff(u(x,t), x, alpha) assuming alpha > 0, alpha < 1:
FPDE := % + u(x,t)*diff(u(x,t),x) + diff(u(x,t),x,x) = 0;

int((x-tau)^(-alpha)*(diff(u(tau, t), tau))/GAMMA(1-alpha), tau = 0 .. x)+u(x, t)*(diff(u(x, t), x))+diff(diff(u(x, t), x), x) = 0

Show that the substitution of the traveling wave

u(x,t) = y(xi),  xi = x - v*t^alpha,  v = lambda*t^alpha / GAMMA(alpha+1);

u(x, t) = y(xi), xi = x-v*t^alpha, v = lambda*t^alpha/GAMMA(alpha+1)

reduces the FPDE to the following ODE:

diff(y(xi), xi, xi) + y(xi)*diff(y(xi),xi) - lambda*diff(y(xi),xi) = 0;

diff(diff(y(xi), xi), xi)+y(xi)*(diff(y(xi), xi))-lambda*(diff(y(xi), xi)) = 0

PS: The original question does not specify the range of alpha.  I have added the conditions
alpha > 0, alpha < 1, but these may not be what is intended.

@nm You wrote: "but it is d'Alembert ode. Maple itself says so". 

Yes, I see that Maple says so.  But look up the definition of the d'Alembert ODE in the help page that I noted in my answer.  Compare that with your ODE.  Is yours of that form?  No!  To put it in that form, you need to square the two sides of your ODE as I explained before.  Probably that's what Maple does (unwisely) when it declares that your ODE is of d'Alembert type.

If you replace the right-hand side of your ODE by its negative, you obtain a completely different ODE.  However, the distinction between the two ODEs disappears when you square the two sides. You can have no assurance that the solution of the squared ODE is that of one or the other ODE.

It's not difficult to verify that the two solution produced by Maple's d'Alembert's method are solutions to the ODE with the changed sign.  Neither one is a solution of your original ODE.

Maple's calculation is correct, but Maple Learn's interpretation of the result is wrong.

The constraint g=x+y=0 is equivalent to y=−x, and therefore the function f = x*y subject to that constraint reduces to f = −x^2 which has a maximum at x=0, not a saddle. That's also evident just by looking at the accompanying plot.

PS: The error lies in the getVals( ) function where SecondDerivativeTest( ) is applied to f while ignoring the constraint.

@vv That's exactly how I have been solving these equations.  I had hoped that Maple may help automate the process.

@tomleslie Thanks for confirming the fix in the Physics update.  I don't have Maple 2022 which is required for that fix.  I will try it out later when I get my hands on Maple 2022.

As I had noted in my original question, my ODE of interest is significantly more complex than the toy example I had posted.  I had only partial success with applying the suggestions that I have received from Acer and Edgardo.  The following worksheet shows the issue.



assume(b > a);

Maple solves this ODE correctly:

de1 := diff(u(x),x$4) = Heaviside(x - a)*u(x);

diff(diff(diff(diff(u(x), x), x), x), x) = Heaviside(x-a)*u(x)

dsol1 := dsolve(de1, u(x), parametric);

dsol1 := u(x) = piecewise(x < a, (1/6)*_C1*x^3+(1/2)*_C2*x^2+_C3*x+_C4, a <= x, ((1/24)*(a^3-3*a^2+6*a-6)*exp(-x+a)+(1/24)*(a^3+3*a^2+6*a+6)*exp(x-a)+(1/24)*((2*a^3-12*a)*cos(x)+(6*a^2-12)*sin(x))*cos(a)+(1/12)*sin(a)*(a^3*sin(x)-3*a^2*cos(x)-6*a*sin(x)+6*cos(x)))*_C1+((1/8)*(a^2-2*a+2)*exp(-x+a)+(1/8)*(a^2+2*a+2)*exp(x-a)+(1/8)*(2*a^2*cos(x)+4*a*sin(x)-4*cos(x))*cos(a)+(1/4)*sin(a)*(a^2*sin(x)-2*a*cos(x)-2*sin(x)))*_C2+((1/4)*(a-1)*exp(-x+a)+(1/4)*(a+1)*exp(x-a)+(1/4)*(2*a*cos(x)+2*sin(x))*cos(a)+(1/2)*sin(a)*(a*sin(x)-cos(x)))*_C3+((1/2)*cos(a)*cos(x)+(1/2)*sin(a)*sin(x)+(1/4)*exp(x-a)+(1/4)*exp(-x+a))*_C4)

That's the correct solution.  Let's verify continuity at x = a:

simplify(limit(dsol1, x=a, left) - limit(dsol1, x=a, right));

0 = 0


but it has trouble with solving this one:

de2 := diff(u(x),x$4) = Heaviside(x - a)*u(x) - Heaviside(x - b)*u(x);

diff(diff(diff(diff(u(x), x), x), x), x) = Heaviside(x-a)*u(x)-Heaviside(x-b)*u(x)

dsol2 := dsolve(de2, u(x), parametric);

dsol2 := u(x) = piecewise(x < a, (1/6)*_C1*x^3+(1/2)*_C2*x^2+_C3*x+_C4, x < b, _C1*exp(x)+_C2*exp(-x)+_C3*sin(x)+_C4*cos(x), b <= x, (1/6)*_C1*x^3+(1/2)*_C2*x^2+_C3*x+_C4)

That's certainly wrong.  The solution is not even continuous!

simplify(limit(dsol2, x=a, left) - limit(dsol2, x=a, right));

0 = (1/6)*_C1*a^3+(1/2)*_C2*a^2+_C3*a+_C4-_C1*exp(a)-_C2*exp(-a)-sin(a)*_C3-_C4*cos(a)



4 5 6 7 8 9 10 Last Page 6 of 84