Carl Love

Carl Love

28035 Reputation

25 Badges

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

MaplePrimes Activity


These are replies submitted by Carl Love

@Goysa2 I added code to allow the user to change the rounding mode, which is controlled by the environment variable Rounding (see ?Rounding). The updated code is in the Answer above. This will definitely change the results for this example for some values of Digits because the critical number of terms is often exactly what will make the first unused digit 5. The second argument, the rounding mode, is optional.

@tomleslie You're right. I meant n > 2. I was posting from memory having just woken up.

@Dim What do you mean by "now" in the phrase "now need to put"? Has there ever been a Maple-related product that accepted sY(s) as a product? I doubt it. You at least need a space between the factors.

@tomleslie The OP's first expression is a Maple product command entered in 2D form. If that expression is entered with the assuming clause, the evaluation will still be in terms of GAMMA functions, but their arguments will be completely different and will never be negative when n >= 2

Please try it. I'd post a worksheet, but I'm currently stuck in an AirBnB with broken WiFi, so I'm posting this from my phone.

@ssllys I'm confused by your simultaneous use of D in both its indexed (D[i]) and non-indexed (D@@2) forms. The non-indexed form only makes sense for functions of exactly 1 independent variable. The indexed form only makes sense for functions of 2 or more variables, except possibly in a degenerate case where all the indices equal 1.

I think (but I'm not sure) that you may be making the common mistake of thinking that D[2] means the second derivative. It doesn't: It means the first derivative with respect to the second variable.

I'm glad that you highlighted normal mathematical function. That the resulting object would behave like a normal Maple mathematical function would be quite an achievement. I think that that documentation should be changed to normal numerical function.

@vv Why is your f, sin(x), "more relevant" than sqrt(1+x^2)?

@mark128384 If you got the correct answer, it's just happenstance. The planes aren't parallel, as VV pointed out, and that makes the problem nonsensical. Are you sure that you transcribed all of the coefficients correctly?

If you want to display 1/sqrt(6) without it changing to sqrt(6)/6, enter

1/'sqrt'(6);

@mmcdara I think that the OP is trying to create a random variable (let's call it S) that is a sum of binomial random variables R[j] where the 'n' parameter of each R[k] is some function (let's call if f) based on random draws from R[j] $ j= 0..k-1. After S is created, they want a random draw or draws from it. I just can't figure out what f is, precisely.

@peter2108 Great, I'll convert it to an Answer then.

@peter2108 I think that a .mw worksheet would work better than a .maple file. Is that a possibility for you?

Could you just say in words precisely what you're trying to do? I can't entirely figure it out from your code. What is A[1] supposed to be? Is it supposed to be a random draw from the first distribution? If so, what's supposed to happen if the sum of the A[i] grows larger than N-n?

@shimaa sadk Would you please post your code, or a simplified example from it? It's not entirely clear whether you're talking about a list, a Vector, or a table. I know that you said "list", but it's very easy for a new user to mix those three types up, and my answer would be different for each. It could even be that you're starting with a list and inadvertently turning it into a table.

That being said, if L is a list, then L[1] is its first (and perhaps only) member. So, if x[i] is a list, then x[i][1] is the member.

@Adam Ledger The command kernelopts(level) will tell you how deep your "stack" is, that is, how deeply nested you are, whether that's through recursion or simply through A calls B calls C, etc. But mere depth is not the whole problem. If you go too deep, you get the relatively benign "stack limit exceeded" error. I think that a more-important factor may be breadth of recursion. Does recursive procedure R spawn one copy of itself, or two or more? Consider the naive way of computing Fibonaci numbers without a remember table:

F:= n-> F(n-1)+F(n-2): F(0):= 0: F(1):= 1: F(100)

I've had more trouble with recursive user-defined types than with straightforward procedures, especially when they're used for declared type restrictions on local variables and kernelopts(assertlevel) is set to 2.

An extremely informative command related to the level is debugopts(callstack). This'll tell you exactly how you got to the level that you're at: what procedures were called, and what were their arguments. Apparently, you can cause some havoc with this command according to its help page. I've never had trouble, but save your work if you're worried. The worst that can happen is that you'll crash the kernel again and you'll learn something.

When I'm trying to track down a difficult deeply nested error, I put the offending code in a try catch statement and put

    lprint(debugopts(callstack));
    error

in the catch block.

@Jjjones98 The nodes X[k] and weights C[k] depend on the number of evaluation points n, although they do not depend on the integrand. It's not just adding one more point; the nodes and weights change completely when you go from n=4 to n=5 (*footnote). So call my procedure NodesAndWeights for n=5 also.

In Maple, what you have as $\pi$ is Pi (uppercase P, lowercase i). So the function f becomes

f:= x-> cos(Pi*sin(x));

By default, Maple uses 10 digits of precision in its internal decimal computations. (Computations with non-decimal numbers are done exactly, always!) This precision is controlled by setting the Digits environment variable. Since it looks like your final goal has 10 digits, I recommend that you set Digits higher. At the start of the worksheet, do

Digits:= 15;

I didn't just pick 15 arbitrarily. In some senses it is the most efficient setting for Digits due to built-in features of nearly all computer chips. Here I'm accounting efficiency as roughly  -log(|error|) / (time usage * memory usage). Due to extreme optimizations done by chip and OS designers over the decades, the time and memory usage are essentially constant for all values of Digits <= 15 (and Digits is roughly -log10(|error|)).

*footnote: In some cases, the nodes for n = 2*N+1 will reuse all the nodes from n = N. The weights will still be different. These cases are extremely useful, and are called Gauss-Kronrod quadrature. See the Wikipedia article "Gauss-Kronrod quadrature formula".

First 337 338 339 340 341 342 343 Last Page 339 of 708