Carl Love

Carl Love

26488 Reputation

25 Badges

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

MaplePrimes Activity


These are replies submitted by Carl Love

Maple has many commands that are dedicated to pure integer arithmetic. Most of these commands begin with i, such as iquoisqrt, and igcd shown below. These commands are much more efficient than the equivalent commands that aren't dedicated to pure integer arithmetic.

Your code can be simplified to this:

gap:= (a::realcons, b::realcons)-> sign(b-a)*(b-a) - 1:

HostsNdivisors:= proc(N::posint)
local i, d, L:= isqrt(N), P:= Array(1..0), Q:= Array(1..0);    
    for i from 3 to iquo(N,2) do
        if (d:= igcd(i,N)) > 1 then `if`(d>L, Q, P),= i fi
    od;
    (P:= [seq](P)), (Q:= [seq](Q)), ':-gaps' = map(gap~, P, Q)  
end proc:

HostOfpq:= (p::posint, q::posint)->
local r, alpha:= iquo(q,p,r), s, t;
    [seq]([seq](gap(t*r, p*(s-t*alpha)), t= 1..iquo(p,2)), s= 1..iquo(q,2))
:
HostsNdivisors(55);
      [5, 10, 15, 20, 25], [11, 22], 
        gaps = [[5, 16], [0, 11], [3, 6], [8, 1], [13, 2]]

HostOfpq(5,11);
          [[5, 16], [0, 11], [3, 6], [8, 1], [13, 2]]

HostDiv.mw

@sand15 Your code returns the exponent of the highest power of that divides p, but the original goal was to return the quotient of that division. Of course, it's trivial to get the quotient once the exponent is known.

@Pemudahijrah01 You need to change I(t) to It(t) in the 3rd odeplot command.

@Prakash J f(0) = 0 by your initial conditions, so a plot of f(0) vs anything would just be a horizontal line. A plot of f(c) vs alpha for any constant c0 < c <= 100, is theorethically possible, but it would be a lot of work due to boundary-layer effects and convergence issues for extreme values of alpha.

@Prakash J Yes, the worksheet link in @mmcdara 's Answer is broken. His code was very likely akin to this:

eq1:= diff(f(x), x, x, x)-(1/2)*Sc*sin(alpha)*g(x)*(diff(g(x), x, x))
    +(1/2)*x*cos(alpha)*(diff(f(x), x, x))+(1/2)*sin(alpha)*f(x)*(diff(f(x), x, x)) = 0; 
eq2:= (diff(g(x), x, x, x))/Pm+(1/2)*x*cos(alpha)*(diff(g(x), x, x))
    +sin(alpha)*f(x)*(diff(g(x), x, x))-sin(alpha)*(diff(f(x), x, x))*g(x) = 0; 
eq3:= (diff(theta(x), x, x))/Pr+(1/2)*x*cos(alpha)*(diff(theta(x), x))
    +(1/2)*x*(diff(f(x), x))*(diff(theta(x), x))
    +sin(alpha)*(x*(diff(f(x), x))-f(x))*(diff(theta(x), x))
    -Nb*(diff(s(x), x))*(diff(theta(x), x))
    -Nt*(diff(theta(x), x))^2+(1/4)*Sc*Br*sin(alpha)^2*(diff(f(x), x))^2*(x*(diff(g(x), x))-g(x))
    +(diff(g(x), x))^2*(x*(diff(f(x), x))-f(x)) = 0;
eq4:= diff(s(x), x, x)+S*((1/2)*cos(alpha)*x*(diff(s(x), x))
    +(1/2)*sin(alpha)*f(x)*(diff(s(x), x)))+Nt*(diff(theta(x), x, x))/Nb = 0;

ics := f(0) = 0, (D(f))(0) = 1, g(0) = 0, (D(g))(0) = 1, theta(0) = 1, s(0) = 1;
bcs := (D(f))(100) = 0, (D(g))(100) = 0, theta(100) = 0, s(100) = 0;

params:= alpha = - Pi/6, Sc = 1.0, Pm = .1, Pr = 6.2, Nb = .1, Nt = .1, Br = .5, S = 1;

dsol:= dsolve(eval({eq||(1..4), ics, bcs}, {params}), numeric, maxmesh= 2^9);

plots:-odeplot(
    dsol, `[]`~(x, [f,g,s,theta](x)), legend= [f,g,s,theta](x),
    color= [red, green, blue, black], thickness= 3
);

 

@acer Thank you for the clarification. I should've have said that my Answer applied to the cases where there's been a reversion to adaptive= true, and that that had been made clear by your Answer.

I am disurbed by the following; I think it's a bad design decision: There now exists a "global" plot option (i.e., one that applies to a whole plot rather than to just a plot component) such that 

plot(..., OPT)

may return a substantially different result than

plots:-display(plot(...), OPT)

That OPT is axis= [mode= log]. I would prefer that this option be reserved strictly for post-processing of already computed points.

 

 

I have often had a phenomenon very similar to this occur on my display screen, not in a PDF export (which I don't use often): Minus signs become K, plus signs become C, and there's a few other such changes that I can't remember the characters for. This happened many times for me, but it stopped about 2 years ago. When it happened, it would simultaneously affect all open worksheets. The errors are only on the display, not in the saved versions of the worksheets, so it's safe the save all worksheets and close and restart the entire Maple session, which is the only thing that seemed to fix the problem.

@sija Can you describe the larger actual problem that you're trying to solve? Can you describe it with just words and ordinary (i.e., not necessarily computer code) mathematical expressions?

@Jamie128 To specify partial derivatives, put an index on the D that specifies the position(s) of the differentiation variable(s) within the argument sequence of independent variables. For example, suppose that you intend use (x,y) as the independent variables and you want the 1st derivative wrt y. Then do

L:= D[2]~(lis):  convert(lis(x,y), diff)

For the 2nd derivative wrt x, use D[1,1]. For the mixed partial wrt x and y, use D[1,2]. Remember that the order of the partial derivative is given implicitly by the number of numbers in the index. The numbers themselves specify the variables' positions in the argument sequence.

@Rouben Rostamian  @Preben Alsholm I modified my procedure to first make use of any existing numerically specified VIEW in the PLOT structure, and to proceed with the plottools:-transform process only if such a VIEW isn't found. The new procedure is in the Answer above. Using the new procedure, I get

Please check that this works in Maple 2024 with the various adaptive values.

@Preben Alsholm Hmm, that was the very first example that I tested. Using Maple 2023.2, I get the plot below. What do you get?

I'd do this:

plot(
    f[1](x), x= -5..5,
    legend= typeset("function ", convert(f, `local`)[1](x))
)

@Carl Love The above Answer is doing that taking-forever-to-submit thing that I described a few days ago. This Reply is just to increment the Replies counter and update the Last Action time.

@Joe Riel The problem with directly using the view option as you propose is that the OP wants to use the automatically generated VIEW option if its y-component includes 0. And if it doesn't include 0, the OP wants to enlarge it only so much as is needed to include 0.

@Carl Love The above Answer is doing that taking-forever-to-submit thing that I described a few days ago. This Reply is just to increment the Replies counter and update the Last Action time.

1 2 3 4 5 6 7 Last Page 1 of 688