Carl Love

Carl Love

28025 Reputation

25 Badges

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

MaplePrimes Activity


These are answers submitted by Carl Love

In the following, I've changed your integral to one that is actually possible.

J:= unapply(int(W^2*(CN-CT*sin(theta)), theta= 0..Pi), [W,CN,CT]);
F:= (w, Cn, Ct)-> sigma/2/Pi/v^2*add(J~(w, Cn, Ct)):
F(w, Cn, Ct);

 

Another way:

N:= 5:
Matrix([[0$(N+1)], [$1..N]], scan= band[0,1]);

The option scan= band is often a convenient way to define matrices that are organized along diagonals. The [0,1] represents nonzero diagonals below the main and 1 above.


 

I agree that that increasing the offset sends you back to 1902 is a bug, but it's easy to explain how it occurs. The timestamp must be a 32-bit signed integer, so values between 2^31 and 2^32-1 are treated as negatives. If you pass such a value directly to option timestamp, you'll rightly get an error. But apparently option offset is allowing some hardware arithmetic with those 32-bit integers.

The Eastern Standard (EST) epoch ends precisely at 

StringTools:-FormatTime("%Y-%m-%d %R:%S", 2^31-1-iolib(25));
                     
"2038-01-18 22:14:07"

Recall from my previous Answer that the EST epoch began "1969-12-31 19:00:00". So the epoch ends precisely 68 years, 18 days, 3 hours, 14 minutes, and 7 seconds after it began. I'm going to add 1 second to that; you'll see why in a moment. So, it's 8 seconds. If we take the start of the epoch and subtract that amount of time from it, we get precisely "1901-12-13 15:45:52". So, if I "add 1 second to" the FormatTime input, I'll get that. Lo and behold:

StringTools:-FormatTime("%Y-%m-%d %R:%S", 2^31-iolib(25));
                     "1901-12-13 15:45:52"
 

I don't know to what extent it helps to know this, but infinity (like Pi) is both a name and a constant. But they aren't names which have been explicitly assigned values (outside of a floating-point context). How they are treated depends on the code that they are passed to looking for them and treating them specially. If they get no special treatment, then they act just like any other unassigned name.  

Other than that, several of the "arithmetic of infinity" examples that you show are bugs: Automatic simplification is causing the subtraction of identical symbolic terms to be before "noticing" that those terms contain infinity (rather than any other name) and thus deserve special handling.

There is a special command for redefining I. If you want to change it to _i, do

interface(imaginaryunit= _i):

At this point, you can simply use as a variable, or you can declare it local with no warning message.

The imaginary unit is the only constant that Maple treats in this weird way. It's not a name, nor will any amount of quotes (either ' or `) "unevaluate" it to a name.

I recommend that you never use the method shown by Tom Leslie because it is extremely inefficient for long L. Even if you don't plan on having a long list, using this method is reinforcing a bad habit that is likely the number-one cause of unnecessarily slow Maple programs.

The precise thing NOT to do is this: Build a list, sequence, or set by iteratively adding elements to an existing list, sequence, or set. That operation requires time proportional to the square of the final size; whereas building a container should ideally require only time proportional to the final size itself. Unlike these immutable containers--lists, sequences, sets--the mutable ones--Arrays, Vectors, tables (as used by Kitonum)--do not have this problem.

If you have Maple 2019, the following will build your list efficiently, yet retain most of your original code structure:

restart:
(x, y, s):= (12, 46, 0):
L:= [
    while 0 < y do
        if y::odd then s+= x; --y else x*= 2; y/= 2 fi;
        (x,y,s)
    od
];
L := [24, 23, 0, 24, 22, 24, 48, 11, 24, 48, 10, 72, 96, 5, 72, 
  96, 4, 168, 192, 2, 168, 384, 1, 168, 384, 0, 552]

 

The epoch starts at midnight, 01-Jan-1970, in the GMT time zone. The corresponding time in the Eastern Standard time zone (EST) is 7:00:00 pm, 31-Dec-1969. If you're in EST and you format the hours, minutes, and seconds for timestamp= 0, that's the time that you'll get.

There is a recursive formula to count partitions which is fairly simple computationally but fairly weird mathematically (as recursive formulas go). Here it is coded in Maple:

restart:
nPart:= proc(n::integer)
option remember;
local k;
    if n<=0 then `if`(n=0,1,0)
    else
        -add(
            (-1)^k*(thisproc(n-k*(3*k-1)/2) + thisproc(n-k*(3*k+1)/2)),
            k= 1..floor((sqrt(24*n+1)+1)/6)
        )
    fi
end proc:

For large n, there are some more-complicated formulas that are faster. But the above isn't horribly slow for moderately large n.

I post this not because it's any better than combinat:-numbpart but because it's simple enough to have significant educational value.

You have 6 algebraic equations to fit 6 parameters. So it's very likely that the solution space is a 6 - 6 = 0-topological-dimension subset of C^6 (C = complex numbers), so the probability that there's an integer 6-tuple in that subset is infinitesimal. 

Note that you mistakenly used in the solve command.

Here are four non-hackish ways to do it. The first, unapply, requires that the recurrence have a closed-form solution. The others have no such requirement.

The second, makeproc, requires that the recurrence be expressible as a single algebraic formula. The remaining two do not have that requirement, and they allow formulas and procedures of arbitrary complexity.

The third, module, is a very general technique that's important to learn. They're like classes in C++. Both the local and export variables retain their values between invocations, thus avoiding the need for globals. Nearly all large pieces of Maple code are written as modules.

The fourth, procname/thisproc, is also important to learn. It uses a technique called memoization: building a table matching all input with its output. Memoization can also be made automatic by giving a procedure option remember. In this technique, the procedure's own name takes the place of the global.

restart:
Last:= unapply(rsolve({f(n)=4*f(n-1)+n, f(0)=1}, f(n)), n):
seq(Last(k), k= 1..10);

restart:
Last:= rsolve({f(n)=4*f(n-1)+n, f(0)=1}, f(n), makeproc):
seq(Last(k), k= 1..10);

restart:
Last:= module()
local _Last, ModuleApply:= (k::posint)-> (_Last:= 4*_Last+k);
export Init:= N-> (_Last:= N);
end module:
Last:-Init(1):
seq(Last(k), k= 1..10);

restart:
Last:= (k::posint)-> (procname(k):= 4*thisproc(k-1) + k):
Last(0):= 1:
seq(Last(k), k= 1..10);

 

It can be done like this:

Ab:= Matrix(M$2):
Ab[[1,-1], ..]:= A[[1,-1], ..]:
Ad:= A - Ab;

 

You have more unknowns than equations, so a purely numeric solution is not possible. I assume that you want to solve for x[0]x[1]y[0]y[1]? A solution in terms of t can be easily obtained with solve:

Sol:= solve({eq||(1..4)}, {x[0], x[1], y[0],  y[1]});

Then you can get numeric solutions for a given t by (for example),

evalf([allvalues(eval(Sol, t= 1.2))]);

The environment variable printlevel controls the nesting level to which the results of statements within do-, if-, and proc-blocks are displayed. See ?printlevel.

Yes, it has occasionally happened for me that the kernel crashes (with the boxed message) but the Save is grayed out on the File menu. In those cases, clicking the X to the right of the worksheet's name on the tabs bar will bring up a Save File dialog. (If there's only one worksheet shown on the tabs bar, that X is all the way to right edge of the window.) Either way that you save the worksheet, you'll get that kernel crash message again, but you can ignore it.

The kernel crash message says you should close Maple entirely. In my experience, this is totally false, and it's only necessary to close the worksheet(s) attached to the crashed kernel. Not closing the GUI will save you a lot of time, especially if you have a lot of open worksheets. I've done this hundreds of times without any problem.

Ordinarily, when you use evalb(...=...) to test equality, it only checks whether the objects are absolutely identical, that is, that they are in fact the exact same object with only one memory address. Many common objects in Maple, such as regular sets, are called immutable, and there's an ongoing process (happening in the background such that the user is generally unaware of it) called automatic simplification that ensures that only one copy of each such object is stored. On the other hand, for objects considered mutable, multiple copies of them that are mathematically equal may exist. And, as I said, ordinarily evalb(...=...will not say that such objects are equal. But, the object/module MultiSet overloads the = operator to bypass what ordinarily happens. You can see the overload procedure via

showstat(MultiSet:-`=`);

But, that overloading is not sophisticated enough (nor is there any existing mechanism in Maple by which it could be) to detect when you've constructed more-complicated structures which contain the MultiSets.

I'd guess that the issue with the file saving is just a case of read/write permissions. It seems unlikely to me that it has anything to do with the content of the file. To test that theory, try 

X:= 7;
save X, "file.m";
restart:
read "file.m":
X;

First 117 118 119 120 121 122 123 Last Page 119 of 395