Carl Love

Carl Love

28025 Reputation

25 Badges

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

MaplePrimes Activity


These are answers submitted by Carl Love

You can remove the inequalities and filter the solutions like this:

select(type, eval~(' '[x,y]' ',  {isolve}({x^2+y^2 = 29})), list(posint));

Or, for this specific problem, you could use a dedicated command:

NumberTheory:-SumOfSquares(29);

You've defined the expression to be plotted as

Bst:= [some long expression, 0]

What do you mean by that? I'm pretty sure that Maple's interpretation of what that means---a list of two separate algebraic expressions---is not what you intended it to mean.

It is done like this:

P:= Matrix(10, shape= identity)[convert([[1,4,6,9,10],[2,3,5,7]], permlist, 10)];

The convert(..., permlist, 10applies the permutation to the list [1, 2, ..., 10].

Using a list to index a Matrix permutes the Matrix's rows as specified by the list. If the Matrix that that's being done to is the identity matrix, the result is a permutation matrix.

All that you need is

op~(0, indets(x, function))

Do you want to know why that works? Or do you want to know why it continues to work after you put {name, `+`, `*`} after function?

If A and are lists with the same number of elements, then 

​​​​​​`[]`~(A,B)

is the list of pairs that you want.

The syntax of kernelopts is kernelopts(settingvalue),

so,

kernelopts(assertlevel= 2);

For this application, I would use Records. Deep type checking is much easier with Records than with tables. But why do you copy the record? I think that you should update the input record inplace. Copying will cost both time and memory. So, here's my version of your foo3:

foo3a:= (input::record(x::algebraic, y::algebraic, result::identical()))->
    (input:-result:= input:-x*input:-y)
:
foo3a((input:= Record("x"= 4, "y"=6, "result"= ())));
                               24

eval(input);
               Record(x = 4, y = 6, result = 24)

 

This is a bit more efficient than has, and definitely more to-the-point:

remove~(`=`, A, 0);

Note that if had a sublist such as [f(x,0), 3, 4], then has would cause the f(x,0) to be removed because f(x,0) has 0.

Here's another way that returns more of the points so that you can have denser plots.

k1k2:= proc(U::posint, a::posint:= 10, b::posint:= 1)
local K1, K2, p:= 1, k1:= 0, k2:= 0;
    while p < U do
        p:= nextprime(p);
        if isprime(a*p+b) then 
            k2:= k2+1; K2[p]:= k2
        else 
            k1:= k1+1; K1[p]:= k1
        fi
    od;
    K1, K2
end proc
:
(K1,K2):= CodeTools:-Usage(k1k2(10^7)):
memory used=3.58GiB, alloc change=72.00MiB, 
cpu time=21.78s, real time=21.51s, gc time=1.78s

plot(
    [
        [seq([p,K2[p]], p= combinat:-randcomb({indices}(K2, nolist), 999))],
        [seq([p,K1[p]], p= combinat:-randcomb({indices}(K1, nolist), 999))]
    ],
    style= point, symbol= solidcircle, legend= [k2, k1]
);

1. What [-4, 2] X [-4, 5] means: It's a common mathematical notation (but not a Maple notation) to represent domains[*2] (such as an area over which to make a plot or calculate a double integral) as a Cartesian product[*1], such as [-4, 2] X [-4, 5]. This means the rectangle (including its interior) whose lower left corner is the point (x,y) = (-4,-4) and whose upper right corner is (x,y) = (2,5). The Maple notation for this is

x= -4..2, y= -4..5

or variables other than x and y may also be used.

[*1] Definition: Given two sets A and B, their Cartesian product, denoted B, is the set of all ordered pairs (ab) where a is in A and b is in B. This is one of the most-fundamental concepts of mathematics. The definition can be extended to any number of set factors, even infinite, but I won't go into that here.

[*2] The precise mathematical definition of domain varies according to the source, and any of those definitions involve topological concepts that I'd rather not go into here. For our purposes here, just think of it as a "blob" in the xy-plane. A more-detailed discussion can usually be found in a multivariable calculus textbook in the double-integrals chapter or section.
 

2What grid means in a plotting contextMany plotting commands have a grid option. In a two-dimensional situation, such as with implicitplot, this is a list of 2 positive integers such as grid= [25,25] that represents the specific points within the plotting domain where the underlying computations are done. For the specific example at hand, grid= [25,25] means that 25 evenly spaced x-values are chosen in the interval -4..2, and 25 evenly spaced y-values are chosen in -4..5, for a total of 25x25 = 625 evaluation points. (Note that the set of evaluation points is the Cartesian product of the sets of x- and y-values.) 

The grid option usually does not directly translate into something that can be seen definitively on a plot, unless the values given are unusually small. Rather, larger grid values tend to make smoother plots but require more computational effort. If you actually want to see a grid in the background of your plot, the option for that is gridlines.
 

3. What Grid meansGrid (with uppercase G) is a Maple package that has nothing to do with plotting nor even mathematics. It allows you to control several processors or CPUs simultaneously (i.e., a "grid" of processors) with little-to-no sharing of memory between the processes. There is also a package Threads that does similarly but with a high-degree of memory sharing. Using either of these packages requires significant programming skills.

For the examples where Maple did give a result, you used t as the independent variable but told the fourier command that x was the independent variable. 

Apparently, the PDEtools:-declare in your version of Maple isn't sophisticated enough to display (Ax)t. Apparently, this is fixed in Maple 2020. If you remove the declare, Maple can handle the mathematics fine without the fancy display.

For more perspective, look at showstat(`print/diff`) both before and after the declare command. In my Maple 2020.0, its number of numbered statements goes from 68 to 119 (and its byte count goes from 3200 to 5972). The major work that declare does is to modify this procedure. In Maple 2016.2, its number of numbered statements goes from 66 to 116 (and its byte count goes from 2895 to 5842). That extra statement ((119-68) - (116-66) = 1) is probably what makes the difference. 

I don't know if this is available in your version of Maple. Look up the help page
?DataFrame. If it's available, then you can do something like

S:= <0,9,8,0,7; 3,5,6,5,1; 1,0,0,3,2>:
fancyS:= DataFrame(
    S, 
    rows= [small, medium, large], 
    columns= [Rose, Teal, Plum, Sand, Peach]
);

An alternative with less programmatic flexibility but similar display, which'll definitely work in your version, is

fancyS:= <
     <<Rose | Teal | Plum | Sand | Peach>, S> |
     <``, small, medium, large>
>;

using the same S as in the first case.

The assumptions made by an assuming clause are only in effect for the command to which the clause is applied. On the other hand, assumptions made with the assume command remain until they are explicitly lifted.

In your particular case, this distinction happens to make no difference, but it could easily make a difference for another example.

The operator for noncommutative multiplication is . not *. This operator can be applied to symbolic entities, as in

A.B + B.A

However, other than that, Maple has little-to-no support for symbolic linear algebra, and the transpose of a symbolic variable is just itself.

First 101 102 103 104 105 106 107 Last Page 103 of 395