Carl Love

Carl Love

28015 Reputation

25 Badges

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

MaplePrimes Activity


These are replies submitted by Carl Love

@admytruk This bug (the inability to use a mouse's scroll wheel in a code edit region) is still present in Maple 2021.2.

@vv Running the first case in Windows 10, Maple 2021.2, I get a loss-of-kernel error.

If I remove with(PolynomialIdeals), then it runs fine.

@jaypantone Loading packages with with changes the environment even if you don't use them. Note that PolynomialIdeals overloads the basic operators insubset, and `<,>`. 

@janhardo You wrote:

  • The function P(t) = -200/(exp(t/100) - 2), the solution of the differential equation, is continuous.

Actually it has a discontinuity when its denominator is 0 at t = 100*ln(2), as shown in that worksheet. However, whether or not it has isolated discontinuities such as this is irrelevant to the solving process.

  • At what stage we can see that P(t)(population notation) should be continuous from a given differential equation?

When solving any IVP (Initial Value Problem), we must always assume that the solution is continuous in some interval of interest. The details of this particular IVP are irrelevant. Usually the assumption of continuity is implicit to the solution process. But the particular solution process shown uses a definite integral with an integrand containing an unknown function (P(t)). The int command does not know that you're trying to solve a differential equation! As I said, when doing a definite integral of an integrand containing an unknown function of the variable of integration (in this case), you must use option continuous or the integral simply won't be done. It's as simple as that, it's nothing particular to this problem, and I don't understand why it causes you confusion.

There are other ways of solving this (and, indeed, most other separable 1st-order ODEs) that don't use an integral requiring option continuous. One such way is shown in your following Reply.

  • Was there not a advisor function for classifying  differential equations?

There was, and, indeed, this problem could be easily solved with dsolve both then and now. But using dsolve would be contrary to Harald Pleym's pedagogical purpose with this worksheet. This problem is a classic textbook problem in 1st-year calculus textbooks. It occurs in the section titled something like "Partial Fractions" in the chapter titled something like "Techniques of Integration". This is not a course strictly about differential equations (which would typically be a 2nd-year course); rather, the integration itself is the central featured item being taught, so it is highlighted in this worksheet.

  • Is y(x) the same as P(t) ? 

Yes, of course.

  • The earlier question for a modern approach for solving differential equations is now be answered with this new ODE(step) functionality

It's never clear to me when you are quoting and when you are writing directly. You should learn to use some unambiguous quoting style. Anyway, I don't see anything particularly "modern" about the solution technique shown for this particular problem. The only difference from Harald's is the use of an indefinite integral and a constant of integration. It's the same method that I learned 41 years ago. 

@taro Thank you. Yes, the code was intended as an educational illustration rather than for any practical computation, and I see that it has served that educational purpose. The output of the code is in fact the MESH form that could be used inside PLOT3D to produce the same plot. In other words, the following two PLOT3Ds produce the same plot:

PLOT3D(GRID(1..2, 1..3, k)), 
PLOT3D(MESH(ExpandGrid(GRID(1..2, 1..3, k)));

@rcorless Inert percent-sign operators are neither obscure nor old. Some form of inertness is needed to achieve the OP's goal. It could also be done with add and ``, but I think Kitonum's solution is the best possible. 

Why not just do the following, which is over 60 times faster than working through the EmpiricalDistribution?

my_data:= [1, 2, 4, 5.5, 5.5, 6]:
Statistics:-Bootstrap(
    Statistics:-Mean, my_data, samplesize= 4, replications= 10000
);

 

@dharr I think that the OP only needs to do this:

interface(typesetting= extended, prettyprint= 3):
Typesetting:-EnableTypesetRule(Typesetting:-SpecialFunctionRules);

I need to do this 2nd line in Maple 2021.2 to enable the MeijerG rule, and others.

@janhardo It's easy to add dots and to change square brackets to parentheses, but I don't know how to remove or change the legend border.

InterPlot:= proc(f1,f2)
local 
    F:= [f1,f2], x:= indets(F, And(name, Not(constant)))[], 
    y, v:= [x,y], Int:= solve(y=~ F, v)
;
    plots:-display(
        plot(
            F, (v=~ (min-1..max+1)~(map(eval~, v, Int)))[],
            legend= (y=~F), color= [blue, red]
        ),
        plot(
            map2(eval, v, Int), style= point, symbol= solidcircle,
            symbolsize= 16
        ),
        plots:-textplot(
            map2(eval, [v[],``(v[])], Int), 
            align= [above, left], color= magenta
        )
    )
end proc
:
pl:= (InterPlot@op)~(
    [x^~[1,3], x^~[2,4], x^~[-1,-2], x^~[2,1/2], [x^3, abs(x^(1/3))]]
):
DocumentTools:-Tabulate(
    widthmode= percentage, width= 75, [pl[1..2], pl[3..4], pl[5..5]]
):

 

Making some small changes to my above code to accommodate the style of your worksheet, I got this:

InterPlot:= proc(f1,f2)
local 
    F:= [f1,f2], x:= indets(F, And(name, Not(constant)))[], 
    y, v:= [x,y], Int:= solve(y=~ F, v)
;
    plots:-display(
        plot(
            F, (v=~ (min-1..max+1)~(map(eval~, v, Int)))[],
            legend= (y=~F), color= [blue, red]
        ),
        plots:-textplot(
            map2(eval, [v[],v], Int), 
            align= [above, left], color= magenta
        )
    )
end proc
:
pl:= (InterPlot@op)~(
    [x^~[1,3], x^~[2,4], x^~[-1,-2], x^~[2,1/2], [x^3, abs(x^(1/3))]]
):
DocumentTools:-Tabulate(
    widthmode= percentage, width= 75, [pl[1..2], pl[3..4], pl[5..5]]
):

Please give a more-elaborate definition of a Bohemian matrix and some small examples. I'm particularly confused by the use of "height" in your definition.

@tomleslie Geez, Tom, give the guy a break. It's obviously his first time on MaplePrimes.

If you want to get all complex solutions, add option complex to fsolve, as in

x =~ {fsolve}(g(x) - y, complex)

The { } makes the result of fsolve into a set. The makes it a set of equations rather than a single equation whose right side is a set.

[I have no expertise in this field. I'm only reporting what I just learned from Wikipedia.]

From my reading of the Wikipedia article "Vapour pressure of water" and the closely linked articles on the various formulas, I get the impressions that

  1. there are numerous approximation formulas used for this,
  2. the formulas have been revised many times in the past century or so,
  3. there is no general agreement as to a single best formula,
  4. the "below 0" range that you're looking at is especially problematic.

Here's a substantial update to the code above to handle all inert forms of exponentiation also. I also added extensive comments.

#This code must be parsed as 1D input.
FlattenPowers:= module()
description 
    "An appliable module to insert an explicit ^ operator into the "
    "prettyprinted forms of expressions with exponents"
;
option `Author: Carl Love <carl.j.love@gmail.com>, 2022-Jan-11`;
uses T= Typesetting;
local
    ModuleLoad:= proc() #Add types
    uses TT= TypeTools, ST= StringTools;
    local
        Types:= [
            [
                #inert functions with any number of %s   
                Inert,
                (f, s::{symbol, string}, n::nonnegint)->
                    f::function and op(0,f)::symbol and
                    ST:-RegMatch("^%+\\" || s || "$", op(0,f)) and 
                    (nargs=3 implies f::(n &under nops))
            ],
            [
                #patfunc to match the beginning arguments and ignore
                #the rest
                Patfunc, 
                (f, T::seq(anything))-> evalb(f::patfunc(T, anything))
            ],
            [
                #combine specfunc and Patfunc
                Specfunc, 
                (f, s, T::seq(anything))-> 
                    f::specfunc(s) and f::Patfunc(T)
            ]
        ]
    ;
        for local T in Types do
            if TT:-Exists(T[1]) then TT:-RemoveType(T[1]) fi;
            TT:-AddType(T[])
        od;
        return
    end proc,
    
    #Procedure Hold maintains a table, _Hold, that matches the typeset
    #forms of implicitly inert expressions with their typeset form
    #correctly annotated as inert.

    _Hold:= table(),
    Hold:= proc(pi, p)
    option remember;
    local ts:= T:-Typeset(T:-EV(pi));
        _Hold[ts]:= T:-mcomplete(ts, T:-_Hold([p]));
        pi
    end proc,
    
    ModuleApply:= proc(ex)
    local 
        `&_p`, `&_pi`, R, p:= "&amp;&lowbar;p", pi:= cat(p, "i"),
        e:= "&ExponentialE;", inert_color:= 'mathcolor'= "#909090"
    ;
        #Step 1: 
        #   a. Replace the main operator in expressions with
        #      superscripted exponents with a neutral `&` binary infix
        #      operator.
        #   b. Retain info to annotate typeset forms of inert
        #      expressions.

        R:= evalindets(
            ex, 
            {
                anything^Not(-1), specfunc(Not(1), exp), 
                Inert~(["^", exp], [2,1])[]
            }, 
            p-> 
                if p::`^` then
                    if op(2,p)::And(rational, negative) then
                        1/(op(1,p) &_p (-op(2,p)))
                    else
                        `&_p`(op(p))
                    fi
                elif p::specfunc(exp) then exp(1) &_p op(p)
                else #inert
                    Hold(
                        if p::Inert(exp) then %exp(1) &_pi op(p)
                        else `&_pi`(op(p))
                        fi,
                        p
                    )
                fi
        );

        #Step 2:
        #   a: Typeset the expression.
        #   b: Add the annotation for inert forms that is stored in
        #      _Hold.
        #   c: Remove extra parentheses (T:-mfenced) around e.

        R:= subsindets(
            subs({indices}(_Hold, 'pairs'), T:-Typeset(T:-EV(R))),
            Specfunc(
                T:-mfenced,
                {
                    Specfunc(T:-mcomplete, Specfunc(T:-mo, e)),
                    Specfunc(T:-mo, e)
                }
            ),
            op
        );

        #Step 3:
        #   a. Replace special neutral `&` operators with "^".
        #   b. Remove extra spaces.
        #   c. Color the "^" appropriately if it's inert.
                
        subsindets(
            R,
            Patfunc(
                anything,
                specfunc(T:-mspace),
                Specfunc(T:-mo, {p, pi}),      
                specfunc(T:-mspace)
            ),
            f-> subsop(
                2= (), 
                3= T:-mo(
                    "^", #could also use "&circ;"
                    `if`(op([3,1], f)[-1]="i", inert_color, '()'),
                    op([3,2..], f)
                ), 
                4= (), 
                f
            )
        )        
    end proc
;
    ModuleLoad()
end module
:
#Example usage:
ex:= [
    1/sqrt(a), a^4/(a+b%^2)^3, %exp(x), a%^x, 1/a, 1/a^2,
    exp(-(x-mu)^2/2/sigma^2), exp(1)
];
FlattenPowers(ex);

 

@mmcdara I mean like this:

A:= Array(1..2, 1..3, 1..4, (i,j,k)-> i+2*j+3*k):
perm:= [2,1,3]:
TA:= Array(rtable_dims(A)[perm], ()-> A[args[perm]]):

First 102 103 104 105 106 107 108 Last Page 104 of 708