Carl Love

Carl Love

28065 Reputation

25 Badges

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

MaplePrimes Activity


These are answers submitted by Carl Love

Continuing with Preben's fine advice, you should investigate initial conditions x(0) = c, where c is between a and b/2. This is the middle band, where the more-interesting (and usually more-practical) solutions lie. 

The issue is not that you're trying to differentiate a matrix. Rather, the issue is that you're differentiating with respect to x, a vector, not a single variable. Use Gradient instead of diff:

restart:
x:=<x1,x2>;
W:=<<w11, w12>|<w21, w22>>;
Cal:= (W.x)^%T.(W.x);

VectorCalculus:-Gradient(Cal, [seq(x)]);

Note that I've made x a vector rather than a matrix, and this makes Cal a scalar rather than a one-element matrix.

The issue is simply a misplaced parenthesis, as pointed out by Tom. The purpose of this Answer is to show you two ways to construct more robustly so that perhaps you would've been able to figure that out just from the error message. Your L:= proc(N) N end is not really an identity function; rather, it's a projection function of its first argument. Note that L(1,2) returns 1. Here are two ways to make better:

1. L:= proc(N, $) N end proc: This makes a true one-argument identity function: Any attempt to pass more (or less) than one argument will give an error message. So, the error message from your plot command would've been:

Error, invalid input: too many and/or wrong type of arguments passed to L; first unused argument is k = 0 .. 10

I think that it's obvious from that message that misplaced parentheses are the issue.

2. L:= ()-> args: This makes a true identity function of an arbitrary number of arguments: All arguments are returned. The error message would've been:

Error, (in plot) incorrect first argument [min(5, max(-5, 5^(10*x)+5^(x*k))), k = 0 .. 10]

In this case, the special evaluation rules of seq prevent it from seeing the k= 0..10 as its optional second argument because that expression is part of the result from L. L hasn't yet been evaluated; that's the "special" part. So, seq sees the call to as its sole argument, and it does what it usually does when it only has one argument, which is kind of trivial in this case: It returns the operands of L, which are the arguments. It's just a coincidence that this is what L would've done anyway. Those special evaluation rules could be made normal by replacing seq with (value@%seq). I'm not suggesting that you do this, because it's obvious that you didn't intend for k= 0..10 to be passed to L anyway. Nonetheless, this modification does give the correct plot.

The command is ssystem. See its help page (?ssystem). If the result is a number in string form, use parse to make it a number. I think that it'd be preferable (and perhaps necessary) to make your shell commands into a single command. The assignment to result within the shell seems superfluous. So, for example,

Result:= ssystem("`python model.py 1 2 3 4 5 6 7 8 9 10`"); #Inner quotes may not be needed.
if Result[1]=0 then result:= parse(Result[2]) fi;

You may also be interested in Maple's built-in Python interpreter. See ?Python.

No, there's no software that can do that.

First, you need to choose a name for the independent variable. I chose x. Then

dsolve({diff(y(x),x$2)-y(x), y(0)=0, y(1)=1})

The returned result is obviously equivalent to sinh(x)/sinh(1), but if you want Maple to express it in this form, a few extra steps are needed.

I think that using the method= custom option of Sample means that the sampling procedure to be used should be supplied as the RandomSample option of the Distribution command.

I propose the following algorithm for generating a random sample of size n from MIXTURE:

1. Generate a sample S of size from Uniform(0,1).
2. Count members of S less than p. Call this n1, and let n2:= n - n1.
3. Generate samples S1 and S2 of sizes n1 and n2 from U1 and U2, respectively.
4. Return the concatenation of S1 and S2 in the appropriate rtable format.

This should work for any U1 and U2, regardless of whether they're uniform or whether their supports are disjoint or overlapping.

Edit: I just saw that you proposed a sampling method that uses solve. I think that the above will be faster because it's purely numeric.

Where did you find RandomSampleSetup

There are eight simple algorithms (really just interpolation formulas) that Maple can use for quantiles of raw data, including quartiles. These are documented on help page ?QuaNtile (not ?QuaRtile), but the same method options can be used with either command. To get 2.5, do

Statistics:-Quartile([1,2,3,4,5,6,7,8], 1, method= 4); 

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.

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