Carl Love

Carl Love

28025 Reputation

25 Badges

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

MaplePrimes Activity


These are replies submitted by Carl Love

@Markiyan Hirnyk I (or my guess at least) stand corrected. You should make it an Answer so that I can vote up. I wonder why the intermediate step of GaussianElimination makes a difference. I would think that NullSpace would do that anyway.

I think that "somewhat complicated" is an understatement. Your C5 is a dense 6 x 12 Matrix of "somewhat dense" polynomials in 12 variables. I guess (just guessing here) that this is well beyond the capability of any computer or CAS currently in existence.

I got an error trying to load your C4. The code to generate the matrices seems missing.

Briefly, this issue in handled by the output= permutation option to sort in Maple 17. I see from your header that you are using Maple 15. In that case you can do something like this:

Original list:
L:= [2,4,5,0,-1];
                        [2, 4, 5, 0, -1]
Pair each element with its index number:
L1:= [seq]([L[i],i], i= 1..nops(L));
           [[2, 1], [4, 2], [5, 3], [0, 4], [-1, 5]]
sort(L1);
           [[-1, 5], [0, 4], [2, 1], [4, 2], [5, 3]]

Briefly, this issue in handled by the output= permutation option to sort in Maple 17. I see from your header that you are using Maple 15. In that case you can do something like this:

Original list:
L:= [2,4,5,0,-1];
                        [2, 4, 5, 0, -1]
Pair each element with its index number:
L1:= [seq]([L[i],i], i= 1..nops(L));
           [[2, 1], [4, 2], [5, 3], [0, 4], [-1, 5]]
sort(L1);
           [[-1, 5], [0, 4], [2, 1], [4, 2], [5, 3]]

@somayeh Please repost this as a new Question. Also, show a little of the code for how you obtained the vector before you sorted it. It looks like it may actually be a list rather than a Vector.

@somayeh Please repost this as a new Question. Also, show a little of the code for how you obtained the vector before you sorted it. It looks like it may actually be a list rather than a Vector.

@Markiyan Hirnyk "Compromise" has a second definition different from the one used in that Wikipedia article. I see that that secondary meaning is absent from many of the online dictionaries. The secondary definition is "2. Something that combines qualities or elements of different things" from www.thefreedictionary.com or "1b : something intermediate between or blending qualities of two different things" from www.merriam-webster.com/dictionary . I meant the blending of the ideas of high density and low degree, one of which makes the polynomials larger while the other makes them smaller.

@Markiyan Hirnyk "Compromise" has a second definition different from the one used in that Wikipedia article. I see that that secondary meaning is absent from many of the online dictionaries. The secondary definition is "2. Something that combines qualities or elements of different things" from www.thefreedictionary.com or "1b : something intermediate between or blending qualities of two different things" from www.merriam-webster.com/dictionary . I meant the blending of the ideas of high density and low degree, one of which makes the polynomials larger while the other makes them smaller.

@Markiyan Hirnyk The dense, degree= 1 is a good compromise. I had considered using dense, but decided against having thousands of terms.

@Markiyan Hirnyk The dense, degree= 1 is a good compromise. I had considered using dense, but decided against having thousands of terms.

@Algorithmus Could you upload a worksheet instead of a screen shot?

@erik10 wrote:

I get an error message.

There is an extra right parenthesis ")" in the line beginning anyZero:=.

Also I am unsure if I should use global variables?

It is generally considered a bad programming style, but it is not necessarily an error.

After execution of the procedure, I want two large Vectors 'probVector' and 'lambdaVector' to be available outside this procedure. Maybe I should initially call the procedure with those two large vectors with zeroes?

That's what I would do. But there's no need to initialize them with zeroes. Just declare the number of entries.

And then forget about the global variable?

Ah, the real problem is counter. Unlike the Vectors, counter does need to be initialized to zero. It is tricky to make it a local variable or parameter. I recommend that you keep it global for now, unless you can follow what I did with it in the module. (I called it Index instead of counter.)

Another thing: I am using Vectors here, but could also use lists maybe? What is the most efficient?

They must be Vectors since you are assigning to indexed entries. If there is some good reason to use lists after the procedure has ended (there often is), the Vectors can be easily converted to lists.

I would be very delighted if you would please tell me the minor changes which will make my own code work.

The `if`(anyZero, ... should be `if`(anyZero=0, ....

Maple has a predefined name undefined (lowercase u). You might as well use that instead of some arbitrary value.

You should not pass counter in the recursive call.

You have declared a variable hj where I think that you meant to declare j, and it should be integer.

@erik10 wrote:

I get an error message.

There is an extra right parenthesis ")" in the line beginning anyZero:=.

Also I am unsure if I should use global variables?

It is generally considered a bad programming style, but it is not necessarily an error.

After execution of the procedure, I want two large Vectors 'probVector' and 'lambdaVector' to be available outside this procedure. Maybe I should initially call the procedure with those two large vectors with zeroes?

That's what I would do. But there's no need to initialize them with zeroes. Just declare the number of entries.

And then forget about the global variable?

Ah, the real problem is counter. Unlike the Vectors, counter does need to be initialized to zero. It is tricky to make it a local variable or parameter. I recommend that you keep it global for now, unless you can follow what I did with it in the module. (I called it Index instead of counter.)

Another thing: I am using Vectors here, but could also use lists maybe? What is the most efficient?

They must be Vectors since you are assigning to indexed entries. If there is some good reason to use lists after the procedure has ended (there often is), the Vectors can be easily converted to lists.

I would be very delighted if you would please tell me the minor changes which will make my own code work.

The `if`(anyZero, ... should be `if`(anyZero=0, ....

Maple has a predefined name undefined (lowercase u). You might as well use that instead of some arbitrary value.

You should not pass counter in the recursive call.

You have declared a variable hj where I think that you meant to declare j, and it should be integer.

Using evalf is risky: If the precision is not sufficiently high, you may get a wrong result---not just the absence of a result. Whereas is will add digits of precision sufficient to determine the inequality with certainty. For example:

Digits:= 3:
if Pi < 22/7 then Yes else No fi;
Error, cannot determine if this expression is true or false: Pi < 22/7

if is(Pi < 22/7) then Yes else No fi;
                              Yes
evalf(Pi), evalf(22/7);
                           3.14, 3.14
if evalf(Pi) < evalf(22/7) then Yes else No fi;
                               No

While this example may seem contrived, it is very common in numerical programming for an inequality to be decided by the last digit of precision.

Using evalf is risky: If the precision is not sufficiently high, you may get a wrong result---not just the absence of a result. Whereas is will add digits of precision sufficient to determine the inequality with certainty. For example:

Digits:= 3:
if Pi < 22/7 then Yes else No fi;
Error, cannot determine if this expression is true or false: Pi < 22/7

if is(Pi < 22/7) then Yes else No fi;
                              Yes
evalf(Pi), evalf(22/7);
                           3.14, 3.14
if evalf(Pi) < evalf(22/7) then Yes else No fi;
                               No

While this example may seem contrived, it is very common in numerical programming for an inequality to be decided by the last digit of precision.

First 629 630 631 632 633 634 635 Last Page 631 of 708