Carl Love

Carl Love

28100 Reputation

25 Badges

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

MaplePrimes Activity


These are replies submitted by Carl Love

@emendes Do you mean that the function is literally named anglebracket? Or is it one of `<,>` or `<|>`?

@emendes Given that inner is undocumented, there's no guarantee that it'll always be available. However, given its simplicity and the fact that it's used in Maple library code, I'd say that it's likely to be around. If not, it's a one-liner if you need to rewrite it. In Maple 2016:

Inner:= (u,v)-> add(u*~v):

Why do you say that it's Maple that's wrong rather than the other program? The points of intersection of the two graphs can be computed exactly and then evaluated to an arbitrary number of decimal places. I have done so (using 50 digits), and I can find no mistake in the Maple plot.

@sand15 

Use c__p/c__v. The p will never be evaluated that way. The name c__p doesn't contain the name p, just like cp doesn't contain p. The double underscore isn't an "operator". To Maple's kernel, it's just another two characters in a name. It's only purpose is that it's displayed differently by the GUI.

Regarding the syntax x__||(1..3): It's more flexible than the seq alternative: It can appear on the left side of the assignment operator, and the numbers can be letters.

@tomleslie You can change the default way that Arrays print with a `print/` procedure, like this:

`print/Array`:= ()-> `print/rtable`(<Array(args)>);

You can put that in your initialization file.

This is documented, albeit minimally, at ?print in the last paragraph of Description and the last example.

Note that you don't need to explicitly invoke a `print/` procedure. It'll be invoked automatically whenever the GUI has an Array to display. That's why I say that the procedure changes the default.

@Christian Wolinski That syntax was phased out about 20 years ago. The `.` is now the noncommutative multiplication operator, such as for matrices. The concatenation operator is now `||`. If you replace your `.` with `||`, your code will work fine.

@acer Also cat(X__, 1..3) or X__||(1..3).

@Vic ^%T is indeed transpose. But you've incorrectly transcribed what I typed. It should be ^~%T, which maps the transpose over the list that it's applied to. The reason that I used it is that I wanted the solution vectors to print horizontally. You can omit it if you're happy with them printing vertically.

Try this:

try
     SolLAM:= [LAM:-LinearSolve(2, LAM:-Mod(2, Ab, integer[]), 1, inplace= false)]^~%T
catch "matrix is singular":
     SolLAM:= NULL
end try:
SolLAM;

Only the first vector in the list is a solution. The other vectors, if any, are a basis for the null space.

 

@ What can be done in evalhf or compiled code is extremely limited. In particular, there are no lists, sets, tables, or symbolic varaibles. There's no point in encouraging such usage because then there'd be little point in using a CAS.

@taro 

The expression x^(2*a) is a function composition of the form f(x, g(2, a)). All such cases are handled by expand, to whatever extent they've been programmed in. In particular, see showstat(`expand/power`).

The order that factors are placed in a product or whether extra parentheses are used makes no difference to Maple: The expressions are seen as exactly the same. Indeed, the expressions are identical and stored at the same address, so there's only one copy kept.

However, the ability to use subs or eval for this problem, is, as I pointed out earlier, based on a quirk of the internal representation. That internal representation has changed in the past, and it may change in the future. Thus, I wouldn't rely on a method that uses subs or eval. You are right to worry about it. The subtlety of this issue shows why it can extremely difficult to maintain backwards compatibility.

Yes, some algebraic simplifications are more tedious with Maple than with a pencil. But with Maple the chance of making a mistake is close to 0.

@Kitonum The applyrule method is great. Vote up!

@taro Thank you. I'm sorry that my technique is so complicated. Kitonum's first method is simpler but only works because of a lucky quirk in Maple's internal representation of expressions: The 2 is stored separately from the rest of the exponent. I think that Kitonum's second method, using applyrule, is the best alternative.

@Kitonum I considered trying what you did, but I decided against it because I didn't think that ex was a syntactic subunit of the exponent. Notice that it doesn't appear in indets(e, anything). However, looking at dismantle(e), I can see that it is. It's the PROD(5) on line 5, and it's distinct from the coefficient 2 on line 20.

SUM(5)
   POWER(3)
      NAME(4): g
      SUM(3)
         PROD(5)              #This is ex
            SUM(7)
               NAME(4): sigma
               INTNEG(2): -1
               NAME(4): k
               INTPOS(2): 1
               INTPOS(2): 1
               INTPOS(2): 1
            INTPOS(2): 1
            SUM(5)
               INTNEG(2): -1
               INTPOS(2): 1
               NAME(4): sigma
               INTPOS(2): 1
            INTNEG(2): -1
         INTPOS(2): 2            #This is the coefficient 2
   INTPOS(2): 1
   PROD(3)
      NAME(4): tau
      INTPOS(2): 2
   INTNEG(2): -1

@ Okay, good point. Yes, the semantics of

y[index]:= anything;

differs depending on whether y is a mutable or immutable container. Lists and sets are immutable containers; tables and rtables are mutable containers. It's impossible to change the contents of an immutable container. Any attempt to change the contents results in the creation of a new container with copied and modified contents. The failure to understand this is probably the number-one cause of inefficient Maple code. Maple shouldn't allow the statement above when y is a list, but it does, begrudgingly, and only if y has fewer than 100 elements.

In your most-recent example, it's important to realize that it's not the statement y:= x that causes the list to be copied! It's the statement y[2]:= 3 that makes the copy. This can be verified like this:

restart:
addressof~([x,y]);
     [18446744792117435038, 18446744792117435070]

x:= [1,2,3]:  addressof~([x,y]);
     [18446744792119857038, 18446744792117435070]

y:= x:  addressof~([x,y]);
     [18446744792119857038, 18446744792119857038]  #x and y point to the same object.

y[2]:= 3:  addressof~([x,y]);
     [18446744792119857038, 18446744792119860222]  #x and y point to different objects.

So, regardless of whether x is a Matrix, a list, a name, or just a scalar, the statement y:= x never makes a copy of x; it just makes a new pointer to an existing object. It's behavior is consistent.

What you want to do is very easy with { }, fsolve, and select. But before I show you how to do that, I need to know what you mean by "function value at a root is positive." By the definition of root, the function value at a root is 0.

First 393 394 395 396 397 398 399 Last Page 395 of 709