Carl Love

Carl Love

26386 Reputation

25 Badges

11 years, 140 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are replies submitted by Carl Love

But your example, in the red ellipse, does show yellow rectangles around the matching brackets. Can you show the example where it does not work?

@Markiyan Hirnyk So, as I continue to work on the original problem, I'd like to know if you intended a uniform distribution? Sorry if that wasn't clear from my last post. It doesn't really change the problem, but the average computational effort required will be different for many algorithms. I'd guess that an algorithm tailored to the logarithmic distribution would have a much better average time when the intervals were drawn from that distribution.

I'm working on a O(n~ +  h) algorithm, where n is the number of intervals and h is the number of pairs of intervals that "hook" together.

Note that the default for RandomTools:-Generate(float(range= a..b)) is a logarithmic distribution. If one of the endpoints is 0, then there is an extreme bias towards values close to 0. I don't think that that is what you intended. You can override the default thus: RandomTools:-Generate(float(range= a..b, method= uniform)). See ?RandomTools,flavor,float.

@kswong89 The minus sign in front is because 1/I = -I, assuming that by I you meant sqrt(-1), which is the default in Maple. If you just meant for I to be a variable, then we need to change that default, which is not difficult to do.

@kswong89 The minus sign in front is because 1/I = -I, assuming that by I you meant sqrt(-1), which is the default in Maple. If you just meant for I to be a variable, then we need to change that default, which is not difficult to do.

@Karla How does Markiyan's solution differ from what you "would like to have as an answer"?

@Karla How does Markiyan's solution differ from what you "would like to have as an answer"?

This is not a comment on the piecewise aspect of the question. I just want to point out that the trivial type of list flattening done in Adri's answer can be accomplished much more simply by appending [] (empty square brackets). Also, the digits=2 needs to be inside the parentheses of float(...) in order to be effective. With these changes, Adri's code becomes

N := 5:
Y := [seq( randpoly(x,degree=2), i=1..N )]:
X := sort( [seq(RandomTools:-Generate(float(range=1..10.0, digits=2)), i=1..N)] ):
H := seq( [x<=X[i],Y[i]][], i=1..N ):
yp := piecewise( x<=0, 0, H, 0 );

This is not a comment on the piecewise aspect of the question. I just want to point out that the trivial type of list flattening done in Adri's answer can be accomplished much more simply by appending [] (empty square brackets). Also, the digits=2 needs to be inside the parentheses of float(...) in order to be effective. With these changes, Adri's code becomes

N := 5:
Y := [seq( randpoly(x,degree=2), i=1..N )]:
X := sort( [seq(RandomTools:-Generate(float(range=1..10.0, digits=2)), i=1..N)] ):
H := seq( [x<=X[i],Y[i]][], i=1..N ):
yp := piecewise( x<=0, 0, H, 0 );

@kswong89 I wrote w(x,y) = .... You changed it to w(x,y):= ....

@kswong89 I wrote w(x,y) = .... You changed it to w(x,y):= ....

@dhonkabulo I don't know why it doesn't work, but it has nothing to do with the a[0] or with the convert(a, `local`). The plot shows up on your screen, right? with the a[0], right? Your original question was how to get the a[0] on the plot, right?

Does saving the plot to postscript work without a[0], or with "a[0]", as you originally had it?

@dhonkabulo I don't know why it doesn't work, but it has nothing to do with the a[0] or with the convert(a, `local`). The plot shows up on your screen, right? with the a[0], right? Your original question was how to get the a[0] on the plot, right?

Does saving the plot to postscript work without a[0], or with "a[0]", as you originally had it?

@awass  How does one know if a package is a module? Trial and error?

It is a good way in this case, if make the trial part with the :-. If the left operand of :- is not a module, you will quickly get an error message that says exactly that. This differs from the situation with square brackets. Nearly any expression that you can make with square brackets, as long as they are balanced, is potentially meaningful to Maple, and hence does not produce an error message.

@awass  How does one know if a package is a module? Trial and error?

It is a good way in this case, if make the trial part with the :-. If the left operand of :- is not a module, you will quickly get an error message that says exactly that. This differs from the situation with square brackets. Nearly any expression that you can make with square brackets, as long as they are balanced, is potentially meaningful to Maple, and hence does not produce an error message.

First 643 644 645 646 647 648 649 Last Page 645 of 687