Carl Love

Carl Love

28035 Reputation

25 Badges

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

MaplePrimes Activity


These are replies submitted by Carl Love

@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]]):

@mmcdara Thanks. The methods in all of our Answers build a new copy of the Array rather than simply use a new indexing method on the existing Array. In some situations, a new indexing method might be more efficient. It would need to be coded from scratch though (not difficult, there is a help page on it).

Regarding your Answer: There's no need to suppose that the dimensions being transposed have the same bounds.

@janhardo I think that saying that it's "only a notation" understates the massive importance of this formula to Number Theory. For one thing, it shows the connection between primes and the Zeta function. Note that the sum side of the formula is by definition Zeta(s), and that s is not necessarily real.

@janhardo Okay, I now understand where you got this idea:

  • There are two approaches to defining a complex function in Maple. Method 1. Make f(x, y) a function of two real variables x, y. Method 2. Make f(z) a function of the complex variable z.

The idea shown in that worksheet is correct; however, the example function used, z-> z^4, is way too trivial to illustrate the pros and cons of either method. (Perhaps the worksheet continues on to some deeper examples that you haven't shown.) But note that the two methods are being used to define the same function

Those two methods have nothing to do with the definitions of one-argument arctan and two-argument arctan as shown by FunctionAdvisor. As I said, those are two different functions that just happen to both be named arctan. It's this coincidence of the name that leads to your confusion.They might as well be named arctan(z) and foobar(y,x). Some simple plots should convince you that they're different. Now, of course, they are related to each other, hence the same-name thing, but that is not the same thing as being the same function defined differently.

Maple has many examples of "families" of functions with the same name that are distinguished only by their number of arguments. I'm not a fan of this practice (partly because it makes the first several lines of those procedures and many of their associated subprocedures difficult to read), but that's the way it is. Some important examples are

  1. the Riemann Zeta function Zeta(...), which is of fundamental importance to the intersection of complex analysis with the study of prime numbers, and is the subject of one of the most-important (perhaps the most-important) unsolved problems in mathematics: the Riemann Hypothesis;
  2. GAMMA, which generalizes factorials to complex numbers; GAMMA restricted to real numbers is of fundamental importance in statistics;
  3. LambertW, the inverse function of x-> x*exp(x); like most functions defined as inverse functions, it has many branches.

Regarding the use of back quotes in that worksheet: They are simply being used to make what are essentially string literals (though the constructed objects are actually type symbol rather than string).  Any characters can be placed between them, including control characters and non-ASCII characters. Usually, but not always, their​​​​​​ prettyprinted display is italicized and without quotes. This is what's being done by the `f(x,y)`, The ` ` doesn't seem to be doing anything other than displaying ` `, for whatever that's worth.

There are many uses of back quotes in Maple, and not only for display purposes. They can seem quite different, but all can be understood in this framework:

  1. The constructed object is always type symbol.
  2. There is some desire or need that the characters in the symbol not be interpreted, at least initially, by the kernel. Often this is because they wouldn't make sense syntactically.
  3. There is some desire that the characters be interpreted in some alternate way, perhaps at some future time. This alternate interpretation can be by the kernel, the display, the plot renderer, some other program, or perhaps simply a human reader.

Can you describe exactly what happens---from your perspective---when it "suddenly crashes"? Do you get a message about a lost "kernel" connection? Any other message? Or does your Maple display, worksheet, everything, suddenly disappear? 

@Joe Riel You wrote:

  • [I]t is generally best if the initialization file produces no printable output.

I totally disagree with that, but perhaps you can state some reason that I haven't considered.

If I want to suppress the output of my initialization file (the usual case), I invoke it with restart:  If I want to see it (because, say, I forgot some detail of what was in it), I invoke it with restart;  That's a one-character decision---trivial. If, instead, my initialization file had all commands ending with colons, I wouldn't have that kind of on-the-fly flexibility.

@janhardo You've misinterpreted what FunctionAdvisor is saying about arctan, and then using that misinterpretation as the basis for an overgeneralization about complex functions.

In Maple, there are two different functions named arctan. In some other languages they have different names, such as ATAN and ATAN2. In Maple, they are only distinguished by their number of arguments. In English, they are sometimes called "one-argument arctan" and "two-argument arctan". Since they are different functions, they have different definitions. All of this is still true if you only consider these functions restricted to real arguments.

You can easily verify numerically that even for real x and y, the equation arctan(x + y*I) = arctan(y, x) is almost always false.

@perr7 You wrote

  • Numerically it seems to me that the sum is exp(1/x), not exp(x) as the formula claims. Is that your conclusion as well?

For m=0, it's totally obvious to me that the series converges to exp(1/x). I don't need numerical confirmation of that for any x. I make no claim whatsoever for any other m.

@The function I set the value of Opts in the first line of my code. It's two options that I wanted added to all the plots, and could be added to any 2d plotting command:

Opts:= labels= [Re,Im](z), scaling= constrained:

@C_R When you put my code in as 2D Input, the string literals "&equals;""&lt;", and "&le;" were changed to "=""<", and "<=". Try it in 1D input (aka Maple Input).

@janhardo I don't think that that can be done by any ordinary-user commands in a web browser. But perhaps it wouldn't be too difficult via some Maple code.

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