Carl Love

Carl Love

28025 Reputation

25 Badges

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

MaplePrimes Activity


These are replies submitted by Carl Love

The type of analysis that I saw in the worksheet that you'd earlier attached (curvature, etc.) does require either Student:-VectorCalculus or plain VectorCalculus. I would advise against you working through this Folium of Descartes example if you do not understand the underlying calculus, which comes from third-semester or multivariable calculus.

@janhardo I don't know what you mean by "high-level commands" other than simply "any command that I haven't seen before" or perhaps "any command whose name contains punctuation marks". To me, they are low-level commands because they are built-in to the kernel rather than being defined in terms of other Maple commands (the vast majority of Maple commands).

Most of the prefix-form operators come from quoting the symbol of an infix operator, and are thus obvious; for example, a + b is equivalent to `+`(a, b). There are only 8 operators whose prefix forms are not so obvious:

`if` #conditional expression
`{}` #set constructor
`[]` #list constructor
`<,>` #matrix/vector constructor by rows
`<|>` #matrix/vector constructor by columns
`?[]` #indexing
`?()` #function application
`~` #elementwise (similar to map)

@naili You say "until here it works perfectly". Have you looked at the output?? The line H:= F(x, -1.8) is nonsense because it treats the expression F as if it were a function that could be applied to arguments. Consequently, the line ListeH:= ... is also nonsense. The definition of should be

H:= eval(F, y= -1.8);

@janhardo I think that you'll learn best by taking a symbolic example and deconstructing my commands. Please execute the following:

L:= [a, b, c]: 
f:= 'f': #i.e., f is just a symbol, to be used as a function
f~(L); #most-basic use of ~; similar to map(f, L)

`[]`(3, 7); #equivalent to [3, 7]
`[]`~([3], [7]);
`[]`~([a,b], [1,2]);
`[]`~(L, f~(L));

Using "functional-programming" syntax (such as mapzip, and ~) often requires that operators be used in "prefix operator-functional" form. `[]` is that form for the list-building operator [...]. All such forms are enclosed in back quotes: `...`

@ Here's my worksheet. The only things that are different from your worksheet are kernelopts(version)f:= (x,t)-> x - t, and the inclusion of k > 0 in the assuming clause.
 

restart

kernelopts(version);

`Maple 2020.0, X86 64 WINDOWS, Mar 4 2020, Build ID 1455132`

 

f:= (x,t)-> x-t:

eq := diff(u(x, t), t)-k*(diff(u(x, t), x, x)) = f(x, t)

diff(u(x, t), t)-k*(diff(diff(u(x, t), x), x)) = x-t

ic := u(x, 0) = 0

u(x, 0) = 0

"G(x,t):=1/(sqrt(4*Pi*k*t))exp(-(x^(2))/(4*k*t))"

proc (x, t) options operator, arrow, function_assign; exp(-(1/4)*x^2/(k*t))/sqrt(4*Pi*k*t) end proc

ans := u(x, t) = int(G(x-y, t-s)*f(y, s), y = -infinity .. infinity, s = 0 .. t)

u(x, t) = (1/2)*(int(piecewise(-csgn(1/(k*(-t+s))) = 1, -2*(-x+s)*Pi^(1/2)/(-1/(k*(-t+s)))^(1/2), infinity)/(Pi*k*(t-s))^(1/2), s = 0 .. t))

`assuming`([simplify(pdetest(ans, [eq, ic]))], [t > 0, k > 0])

[0, 0]

NULL


 

Download InhomoHeat.mw

@janhardo This is perhaps too "clever" to bring up at this point, but at least you can see some of the awesome power of Maple syntax. Acer's

map(p-> [p, f(p)], L)

is functionally equivalent to any of

`[]`~(L, f~(L))  #"clever"

or

[for p in L do [p, f(p)] od]  #very straightforward

or

[seq]([p, f(p)], p= L)  #in between

or

[D[], f]~(L);  #too clever

The explanation of the last one is that the "zeroeth-order derivative" of a "function"[*1] is itself, so the operator that "creates" that derivative is the just identity function. But Maple should provide a dedicated built-in identity function just for such functional-programming constructions. is not built-in to the kernel, and I think it'd be confusing to use a derivative operator anyway. And, I'm not sure that this functionality won't be changed in the future.[*1]

[*1] When D is used like this, it unintentionally ignores that its argument is not a really a function. 

@Preben Alsholm This bug has been fixed.

@ It's not a bug. The given result is mathematically equivalent to 0 under certain assumptions, which you did not provide. For example, if you specify a simple such as f:= (x,t)-> x-t and include the assumption k > 0, then the pdetest will quickly return [0, 0].

Permutation arithmetic in Maple is quite easy, and it's expressed naturally with ordinary arithmetic operators. Let's use the permutation from your previous Question:

Orb(1):= Perm([[1,4,6,9,10]]):
Orb(2):= Perm([[2,3,5,7]]):
P:= Orb(1) . Orb(2):

Your problem:

P^4567;
           
 (1, 6, 10, 4, 9)(2, 7, 5, 3)

Compare with (note: 4567 mod 20 = 7,  7 mod 5 = 2,  and 7 mod 4 = 3):

P^7;
Orb(1)^2 . Orb(2)^3;

@DanishMapleFan Great. Let me know if you have any trouble with it or questions about it.

It works quite efficiently for most numbers whose prime factors have at most (approximately) 28 decimal digits and whose overall length is at most (approximately) 56 decimal digits.

@DanishMapleFan The attached worksheet contains my module for the sum-of-four-squares problem along with several examples. Sum4Squares.mw

@David Sycamore 

1. My output data contains the information for every prime, all 1 million of them. If you tried to display this large amount of data in a GUI worksheet, it could cause problems. That's why I used a colon at the end of the command to suppress the display of the output. I was hoping that post-processing the data with Statistics:-TallyInto as I showed would provide the data to you in a more-useful format.

2. The plots that I showed are not linear; they are indeed O(n/ln(n)). But n/ln(n) is close enough to a line that it's difficult to visually distinguish it from a line. If you look very closely, you'll see that my curves are concave down.

3. Please pay attention to the distinction between lowercase and uppercase K.

You asked:

  • When you say "N::posint" does this tell the proc that you intend to use a number called N which is declared as a positive integer and that its value will be given later?

Almost. When the notation A::T appears in the parentheses following proc, that makes A a parameter of the procedure. Yes, the value will be given later, but the user does not need to call it (or call it anything at all). The name is only meaningful between the proc and end proc. If the value given later is not of type (positive integer in this case), then an error message will be given.

The line between od and end proc (the K1,K2 in this case) is the return value of the procedure.

You may re-ask your other questions if you pay respect to the difference between k and K.

4. The best book about Maple is available in the help system. See ?ProgrammingGuide.

 

@ Pi and pi mean different things to Maple, even though they both display as the lowercase Greek letter. The lowercase version is just a variable, like x.

The pdetest will take a long time to produce a not-very-useful result.

@DanishMapleFan If you're looking for solutions of the sum of four squares problem (there's at least one solution for every nonnegative integer), I've written a module that finds either all solutions or some desired number of them. I'll post it if you want.

@nm A problem with your first solution---

remove(`=`,op~(0,indets(x)),symbol)

---is that it'll find things that aren't functions for which op(0, ...is defined. An example would be an indexed name such as a[2], whose zeroeth operand is a. Also, since you are only removing a single element from a set, that part should be done as op~(0, indets(x)) minus {symbol}, which'd be faster for a large set.

In your second solution, why convert from set to list to set? And it seems that you do not trust that

indets(x, some type)

works.

First 190 191 192 193 194 195 196 Last Page 192 of 708