Carl Love

Carl Love

28130 Reputation

25 Badges

13 years, 308 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are replies submitted by Carl Love

Please provide a Maple worksheet that produces and contains an example of the matrix. In light of your other Questions today, I don't yet see what. if anything at all, makes these any different from ordinary Maple matrices.

@P2prod Using variable upper limits of integration, I get this:

plot3d(
    (2*Int(3*piecewise(x < 1, x, 1 < x, 2 - x) * 
           piecewise(y < 3/2, y, 3/2 < y, 3 - y) *
           sin(Pi*x/2)*sin((2*Pi*y)/3), 
           [y = 0 .. a, x = 0 .. b])
     )/3, b = 0 .. 2, a = 0 .. 3
);

@roethlisalayna 

If is the set of odd numbers, then

select(isprime, A)

@vs140580 You didn't answer my second question: Does trunc~(A) do what you want?? If that doesn't help, how about

trunc~(rtable(A, datatype= anything));

@AmirHosein Sadeghimanesh You wrote:

  • Recently a colleague showed me that it is better to use `__i` instead of `[i]` for indexed variable names.

I wouldn't categorically say that one is better than the other: They each have their uses. One thing that you can never do is make independent assignments to both and x[i], but you can do it with x and x__i.

Your cat(j, '__', i) can be replaced by cat(j__, i). One drawback to using cat is that the variables so constructed are always global. This is true of all programmatically constructed names, regardless of whether the construction is done with catnprintf||, or parse.

@lcz I certainly expected some comments on this procedure.

@dharr You wrote:

  • Code Edit Regions are similar regions embedded in the worksheet, with full error messages (but not error location).

Embedded Code Edit Regions also use the red wiggly underlines, although they may be small and difficult to see.

Perhaps you need to specify where on your computer "networkx" is stored.

1. Could you show in a Maple worksheet an example of the type of Python output you're referring to?

2. Does trunc~(A) do what you want?

Did you mean for x to be k? In that case the product is n!. If not, the product is x^n, but is undefined. 

@Earl 

&under is documented in the last paragraph of the "Description" section of help page ?type,structure. You can also get a full understanding of it by expanding its trivial one-line code:

showstat(`type/&under`);

Please post your code as plaintext, not as an image! I don't feel like re-typing it!

@Carl Love [The code of this Reply requires Maple 2019 or later and 1D input.]

The 2nd differences (or 2nd discrete derivative) of the sequence 2*k^2 is 4. This is obvious by some small hand calculation, and it can also be verified by any of these three methods:

DiscreteDiff:= (f::{list(algebraic), algebraic}, n::seq(name))->
local r:= `if`(f::list, f[2..]-~f[..-2], eval(f, [n][1]= [n][1]+1) - f);
    `if`(nops([n])=1, r, thisproc(r, n[2..]))    
:
A:= [seq](2*k^2, k= 0..9);
          A := [0, 2, 8, 18, 32, 50, 72, 98, 128, 162]

DiscreteDiff(A, k$2);
                    [4, 4, 4, 4, 4, 4, 4, 4]

simplify(rsolve({DiscreteDiff(S(k), k$2) = 4, S(0)=0, S(1)=2}, S(k)));
                                 2
                              2 k 

simplify(DiscreteDiff(2*k^2, k$2));
                               4

This knowledge can be used in the Verify procedure thus:

Verify:= proc(N::And(odd, positive, Not(1)))
local n:= N, k:= -2;
    do if isprime(n) then return true fi until (n-= (k+= 4)) < 0;
    false
end proc
:

 

@student1EE You're welcome. It's a very easy mistake to make. Like I said, there are situations where it is appropriate to redefine a symbol. Whether it's appropriate almost always depends on how you want to affect the human readability of the code. Controlling the order of evaluation is the usually the more-appropriate way to affect how Maple interprets the code.

There's a lot of subtle and likely new-to-you information in the Answer above. I'd be happy to answer any follow-up questions that you have about it.

@dharr I suspect that that strange vector substitution was merely the OP's futile attempt to work around the bug.

A workaround that I think will work in almost any Maple version that has this bug is

subs(Pr= P[convert(r, `local`)], H)

if you want the subscript r and the naked r to be considered as completely independent entities.

 

First 130 131 132 133 134 135 136 Last Page 132 of 710