Carl Love

Carl Love

28055 Reputation

25 Badges

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

MaplePrimes Activity


These are replies submitted by Carl Love

Could you give a small example of a PDE which has two polynomial solutions, one of which is returned by PDEtools:-PolynomialSolutions and the other of which is the homogeneous polynomial that you want?

@notgoodatmaple This worksheet should help you understand many of the details from my (rather terse) Answer, although I haven't endeavored to explain every nuance of the syntax. Nonetheless, after you've experimented some with this worksheet, feel free to ask any specific questions about the syntax.
 

restart:

ode:= diff(theta(t),t) = 1+A+(A-1)*cos(theta(t));
Q:= dsolve({ode, theta(0)= -Pi/2}, numeric, parameters= [A]):
PlotQ:= proc(A)
    Q(parameters= [A]);
    plots:-odeplot(Q, args[2..], gridlines= false)
end proc
:
MultiPlot:= proc(
    As::list(realcons), trange::range(realcons):= -2..2,
    {Legend::truefalse:= false}
)
    local k, N:= nops(As)-1;
    plots:-display(
        seq(
            PlotQ(
                As[k+1], t= trange,
                color= COLOR(HUE, .85*k/N),
                `if`(Legend, legend= [A=As[k+1]], NULL)               
            ),
            k= 0..N
        ),
        legendstyle= [location= right], _rest
    )
end proc
:

diff(theta(t), t) = 1+A+(A-1)*cos(theta(t))

The procedure PlotQ produces the plot for a single value of A, which is its first argument:

PlotQ(-2, t= -9..9, thickness= 3);

You can interogate what the current parameter value is:

Q(parameters);

[A = -2.]

As as there is a numeric value for the parameter, you can request specific numeric values of theta(t):

Q(-4), Q(4), Q(-9), Q(9), Q(99), Q(-99);

[t = -4., theta(t) = HFloat(1.9104993102616643)], [t = 4., theta(t) = HFloat(-1.9106294563198518)], [t = -9., theta(t) = HFloat(1.9106329863105198)], [t = 9., theta(t) = HFloat(-1.9106337351769633)], [t = 99., theta(t) = HFloat(-1.9106329949645597)], [t = -99., theta(t) = HFloat(1.910633435519435)]

PlotQ(0, t= -5..5, thickness= 3, color= red);

Oviously, A=1 is a straight line:

PlotQ(1, t= -5..5, thickness= 3, color= orange);

PlotQ(2, t= -5..5, thickness= 3, color= yellow);

PlotQ(4, t= -5..5, thickness= 3, color= green);

The procedure MultiPlot plots several curves on the same axes, using several specified values of A. The curves are color coded using the visible spectrum (red, orange, yellow, green, blue, violet and all continuous gradations between), so the first specified A is red, the last is violet, and the others are somewhere in between.

MultiPlot([-2, -1, 0, 1, 2, 4], -5..5, thickness= 3, Legend);

The following does the same thing for -2 <= A <= 4, spaced by 0.05

MultiPlot([seq(-2..4, 0.05)], thickness= 0);

To produce the animation shown in my Answer, I used 200 frames, each frame being a call to MultiPlot with 40 A values evenly spaced over an interval of width 2. Here's a smaller animation:

plots:-animate(
    MultiPlot,
    [['seq'(A_red..A_red+1, .2)], thickness= 3],
    A_red= -3..3, frames= 60
);

 


 

Download ODE_parameter_plot.mw

 

Considering how often Questions about fsolve returning unevaluated appear here on MaplePrimes, it would be appropriate if it returned a message akin to the "solutions may have been lost" that solve returns. Then the help page could advise on things to try when that message appears. This change can be made while still maintaining backwards compatibility.

@mehdi jafari If you have initial conditions that make this system interesting, I'd be curious to see them.

@Carl Love The bug is fixed. Either download the code again, or simply change the exponent of -1 from j to k-j.

@mehdi jafari Thank you. There's a small bug in that code regarding the alternation of signs in computing the initial conditions. It'll probably take me a few minutes to fix.

By "normalize", do you mean that you want to rescale the amplitude to [-1, 1]?

Hint: What's equivalent to the remainder of p(x)/(x-a) for a polynomial p?

@Thomas Dean As I said above, it's documented at ?evalapply.

@Thomas Dean Yes, [f,g](a,b) becomes [f(a,b), g(a,b)]. It's as simple as that. In terms of a theory of operators, the function application operator distributes over the list-building operator.

I think that he means the syntax by which [cos,sin](t) becomes [cos(t),sin(t)]. If that's what you want, it's documented at ?evalapply, but there isn't much to say about it: It works that way, and that's it.

Another possibility is the prefix-form list constructor `[]`

@goli  The command textplot3d does not support any directional or rotational options, even in Maple 2020.

However, the colored-dots Answer below can be easily adapted to 3D plots, even in Maple 15.

@Carl Love I just posted a new Answer that doesn't use textplot.

@goli Sorry, there's no rotation option for textplot in Maple 15. This is a situation where you'll need a newer version.

I can concoct a solution that uses colored symbols (that are not arrowheads) to indicate the direction of travel.

@goli Did you re-execute the entire worksheet by clicking on the !!! on the toolbar?

First 211 212 213 214 215 216 217 Last Page 213 of 709