Carl Love

Carl Love

28055 Reputation

25 Badges

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

MaplePrimes Activity


These are answers submitted by Carl Love

Simple solve works:

solve(abs(x^2-3*x) + 4*x - 6, x);
              1, -3 

Or are you looking for a way to solve it "by hand" that doesn't involve breaking it into two cases? I don't think that there's any better way. It is the way that I teach it.

Indeed, there is a package named Student:-VectorCalculus, but it's not needed to create vector-valued functions. No package is needed. For example,

Helix:= t-> <cos(t), sin(t), t>

is a vector-valued function.

Simply

ColorTools:-NearestNamedColor~(c);

Surely something like that must've occurred to you?

The order of a permutation is the least common multiple of the lengths of its orbits. So, the order of the permutation that you show is 3. The order of the permutation from your last question is 20. 

If the order is o, then P^e = P^(e mod o).

The mathematical constant that you have as "pi" is spelled Pi (with uppercase P) in Maple. Once you make this correction, the pdetest will take an extremely long time (20 minutes or so), and will not provide a very useful answer (it'll have an unevaluated limit).

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.

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