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

Does "level curve f(x,y) = c" mean the intersection of the level surface f(x,y,z) = c with the plane z=0? I'm asking for a response from anyone who knows; I think this OP is unlikely to respond.

@dharr Thank you for spotting my error. I corrected the code and plot in my Reply above.

@dharr Here is Maple code to construct @Tokoro 's  1-ohm and 2-ohm graphs:

GT:= GraphTheory:
G__1ohm:= (GT:-Graph@`union`@op@(`{}`~)~)(
    [$1..12],
    [   #Edges forward from vertex...
        #  1       2     3     4       5      6
        {2,3,4}, {3,5}, {8}, {7,10}, {6,8}, {7,8}, 
        # 7     8        9       10      11    12
        {9}, {11,13}, {11,12}, {12,13}, {13}, {13}
    ]
);
  G__1ohm := Graph 6: an undirected unweighted graph with 13 
     vertices and 21 edge(s)

G__2ohm:= (GT:-Graph@`union`@op@(`{}`~)~)(
    [$1..14],
    [   #Edges forward from vertex...
        # 1      2       3      4     5      6       7
        {2,3}, {4,5}, {4,5,6}, {5}, {6,7}, {9,13}, {8,11},
        #  8        9       10      11    12     13      14
        {10,11}, {10,12}, {11,12}, {14}, {14}, {14,15}, {15}
    ]
); 
  G__2ohm := Graph 7: an undirected unweighted graph with 15 
     vertices and 25 edge(s)

Surprisingly, both are planar:

(print~@subs)(
    FONT("HELVETICA","DEFAULT",6)= FONT("TIMES","BOLD",8),
    GT:-DrawGraph~([G__1ohm, G__2ohm], style= planar, size= [500$2])
):

@mehdi jafari Letting m:= M-1, I factored out m^(m-s) from beta(j,s) and then combined that factor with t^(m-s) to get (m*t)^(m-s). But it's no problem to put that m^(m-s) in beta itself, like this:

Lpoly:= proc(t::algebraic, M::And(posint, Not(1)))
uses It= Iterator;
local
    beta:= proc(j,s)
    local k;
        J[]:= <seq(0..j-1), seq(j+1..m)>;
        mm/(-m)^s/mul(j-~J)*add(mul(J[[seq](k)]), k= It:-Combination(m,s))
    end proc,
    m:= M-1, mm:= m^m, J:= rtable(0..m-1, datatype= integer[4]), j, s
;
    [seq](add(beta(j,m-s)*t^s, s= 0..m), j= 0..m)
end proc
:    

 

@Guimzo 

Types versus properties as Boolean predicates in Maple:

To answer your question carefully, I need to tell you about the distinction that Maple makes between types and properties. Whether this distinction matters in this particular case depends on how complicated the values returned by your f can be, which I don't know having not seen f. Also, you may already be well aware of this distinction.

A single example expression should suffice to explain this. Consider

ex:= (1 + sqrt(2))^2 + (1 - sqrt(2))^2;
      

It's trivial to see by hand computation that ex = 6. On the other hand, we can see from the prettyprinted output that Maple didn't automatically make this simplification. (The fact that we could give a command to Maple (e.g., expand) with which it could very easily make that simplification to is irrelevant to the point that I'm making; what matters here is that it didn't do it automatically.) We could say that ex = 6 in the mathematical sense of =, but that ex <> 6 in the sense of raw data structures in a computer's memory. Since 6 is an integer, we'd say in Maple's terminology that ex has the property integer but that it's not of type integer. The command for checking properties is is:

is(ex, integer);
      true

type(ex, integer);
      false

As you can probably imagine, checking properties is much more computationally expensive than checking types.

So, with that in mind, note that the code below checks that the type of f(i) is integer, rather than whether f(i) is an integer in the mathematical sense. If there are cases where those two things differ, post the code of f and I will adjust it.

Let be a set or list of the desired arguments to f. Each command below will form a sequence whose element order logically corresponds to the order in A.

To form the sequence of all in such that f(i) is integer:

select(type, A, integer &under f)[]

To form the sequence of all integers f(i) for in A:

This code that you had will work, as you've mentioned, but it's unnecessarily elaborate:

select(is@ `type`, f~([{seq}(k, k = a)[ ]]), integer)[ ]

It can be simplified to

select(type, f~([A[]]), integer)[]

@evanhowington The interpretation of a <= b as not being exactly the same as (a < b or a = b) is perhaps idiosyncratic to Maple, but one doesn't need to use sqrt or any other possibly complex-valued operation to see its effect. Compare

is(x <= x);
      false

is(x <= x) assuming x::real;
      
true

The default assumption on symbolic variables in relations with algebraic operands is that they're complex; any other assumptions need to be explicitly stated.

@Guimzo Just change is@`<` to is@`>`.

Note that select(is@`<`, ..., b) is equivalent to 

select((x,b)-> is(x < b), ...)

but I think that the former is a bit more efficient (not sure about that). More generally, f@g is equivalent to (x,y)-> f(g(x,y)) (if g takes two arguments), and select(f@g, ..., y) is equivalent to 

select((x,y)-> f(g(x,y)), ..., y)  

Putting an infix operator in backquotes usually allows it to be used as a function name; for example `<`(a,b) is equivalent to a<b and `+`(a,b) is equivalent to a+b. To use an operator without explicit operands (such as using is@`<` or simply `<` as the first argument to select) requires that the operator be used in its function-name form (which is almost always the operator in backquotes).

Using is(x < b) is a bit more accurate than evalf(x) < b for those cases where higher-than-default decimal precision is needed to decide the inequality.

@acer You wrote:

  • It seems just as easy to just make real assumptions on t,x,lambda (as I had shown in my Answer) than it does to call evalc and make complex assumptions on epsilon1,epsilon2lambda1.

Yes, certainly that's true in this case. I use evalc by habit because I think that in general it does some simplifications that simplify doesn't even though the simplify is given equivalent assumptions. As a simple example, none of the following do anything for me (using Maple 2019 at the moment):

simplify(exp(I*x)) assuming x::real;
simplify(exp(I*x)) assuming real;
simplify(exp(I*x), assume= real);

@Carl Love Does my Answer work for you?

@Ronan You wrote:

Thanks for spotting that analogy to my earlier Answer. In that case, I represented your iterated sum's multi-index as a cartesian product. In the present case, I represented it as all s-combinations from a master index set. That can be generalized thus: Let Iter be any operation using an index variable taking a finite number of values (such as sumproductaddmul, or a for loop). Suppose that we wish to compute

Iter(Iter( ... (
    Iter(
f(k[1], k[2], ..., k[s]), k[s]= J[s](k[1], ..., k[s-1])),
     
...), k[2]= J[2](k[1])), k[1]= J[1]()
)                                                           (eq. 1)

where s (the nesting level) is an arbitrary positive integer not known at the time that the code is written and J[1], ..., J[s] are set-valued functions (each of which may depend on all prior indices). In theory, the index tuples (k[1], ..., k[s]) can always be generated as a combinatorial object and the computation of (eq. 1) reduced to a single call to Iter somewhat like this

Iter(f(seq(K)), K= CombGen(...)),    (eq. 2)

where CombGen is some sort of generator of combinatorial objects. (The syntax shown in (eq. 2) is just an example that needs to be adjusted on a case-by-case basis.)  However, in practice, there may not be an efficient way to generate the combinatorial object.

@acer You can safely use evalc in situations where only some of the variables are intended to represent reals by assuming that the others have property complex.

I can't tell whether you actually want an Explore (or other interactive plot) with parameter a or you simply want to plot two functions together.

@acer His integrand is missing the arclength differential, sqrt((dx/dt)^2 + (dy/dt)^2).

I'm guessing that t is the independent variable of the polynomials. What do you mean by t with a subscript, such as t[j] and t[i]? Are these meant to be symbolic variables independent of t itself?

Is there a reason that you specifically want a recursive method? There are also several very good non-recursive ways to do it in Maple.

First 96 97 98 99 100 101 102 Last Page 98 of 708