Carl Love

Carl Love

28055 Reputation

25 Badges

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

MaplePrimes Activity


These are replies submitted by Carl Love

@tomleslie Using Maple 2016.1 with Digits = 15, I get


                 [1, 1] = 2.04426478581227e40
                 [1, 2] = 2.04426478581227e40
                [1, 3] = -2.04426478581227e39 
                   [2, 1] = -Float(infinity)
                    [2, 2] = Float(infinity)
                    [2, 3] = Float(infinity)
                    [3, 1] = Float(infinity)
                    [3, 2] = Float(infinity)
             [3, 3] = Float(infinity)*omega[1, 1]^2

If I use Digits = 10, then I get what you got. A much higher setting of Digits is required. There was little change between 50 and 100 Digits, so I trust those results more.

@mmcdara Your restart is still not in its own execution group. The problems that can be caused by this are somewhat unpredictable, and I have a suspicion that this has some role in the strangeness that you are experiencing. To put it in its own execution group, enter restart; at a prompt, and hit the Enter key (or Return key). Then enter your other commads.

@candy898 

When you have m^n, it tries to use the procedure `^` recursively, but what you want is to fall back to the original `^`. To do that, change m^n to `:-^`(m,n).

@candy898 You should follow Joe's advice. Put the entire code of the module, and all of its procedures, into a single plaintext file, which you'd load with the read command, followed by with.

However, it's another issue that's causing your sortcollect problem. In the return statement of procedure M, you have an extra space after sortcollect. This extra space would make no difference in a plaintext file. But since you're using 2D input, the extra space becomes a multiplication operator. This operator is plainly visible in the code that you copy-and-pasted directly above.

@candy898 

You need to have

option package;

in the module, and

with(Q);

before you use the module.

All you've shown is a lot of code that apparently works. We need a negative example. Please post a worksheet showing something not working. Point out explicitly in a comment where it is wrong and what you expected to get instead.

I reduced your upper for loop limits from 20 to 5, just so that I could get somewhere with this computation. The huge exponents of the coefficients of the resulting polynomials and the mixture of positive and negative terms indicate that the expression has no numerical significance.

So, time to rethink this whole operation. What exactly are you trying to do?

@acer Here's why I said that something must've changed with respect to Matrix (rtable) evaluation:

I took the worksheet that the OP posted in their first response to VV's answer. (This worksheet is named Forum_Question_V2.mw.) I loaded it into Maple 2016 without changing anything, and I "executed entire worksheet." It worked in the sense that I got a fully evaluated numeric Matrix. Then I did the exact same thing in Maple 16, and it didn't work: the result of the two-argument eval was a symbolic Matrix.

Now, if the issue is how the Matrix is entered (using palettes, using unevaluation quotes, etc.), that would be the same in both of my cases above, right?

Does anyone here know what precisely changed between Maple 15, where the rtable_eval is necessary, and Maple 2016, where it isn't?

@tomleslie

Suppose that you're at a "1-D math input" command prompt. Hit Ctrl-T. Now you're in "text mode". Now you can type ordinary formatted word-wrapped text as if you were in a word processor. This is good for putting extended formatted comments in your worksheets, much nicer than a bunch of lines beginning with #. You can also insert inert, formatted mathematical expressions into the text. When you're done with the text, hit Ctrl-J to get to the next command prompt.

@Mac Dude I didn't mean to imply that "putting it anywhere in the 'Maple 2015' directory" would work, although I can see how you might misread it as that. I only meant that putting it (or any other file) anywhere in that directory or any of its subdirectories isn't recommended. Indeed, it's disrecommended.

@Carl Love I have more time today, so I'll point out your syntax errors:

1. Curly braces {} can't be used instead of parentheses for algebraic grouping. So 2^(i) or 2^i are correct (and mean the same thing), but 2^{i} isn't.

2. Don't use the name of the function (aka procedure) in the function's header. So

f:= (x,y,i,j)-> ...

is correct, but

f:= f(x,y,i,j)-> ...

isn't.

3. A function definiton arrow has only one hypen. That is, -> is correct; --> isn't.

4. A procedure's return value is the value of the last statement executed by the procedure. So, the end of CreaF should be

     end do;
       V   #returns V
end proc;

rather than

end do;
end proc;

You can force a return from anywhere in a procedure, including its last line, by using the return statement.

5. This one is quite subtle, and I don't know if you'll understand this explanation. The "lexical" variables in a function are evaluated at the time the function is called, not when it's defined. In your case, j is a lexical variable because it's defined in CreaF and used in the lower-level functions g[n]. And the end of the loop, the value of j is 2^i. This is the value that j will have in every g[n]. The way to get around this is to use unapply:

g[n]:= unapply([f(x,y,i,j)], (x,y));

You also had four efficiency errors. These don't effect the correctness of your result, just the amount of time and/or memory needed to obtain it.

1. The first, and by far the most important, is that you shouldn't create a sequence, list, or set by iteratively appending to an existing sequence, list, or set. Unfortunately that is the natural way to try doing it. There are a great many ways to avoid this. My Answer shows one.

2. The values of your n and j are always the same. Thus, there's no need for both.

3. You never refer to previously computed values of g[n], so there's no need to save them. In other words, g[n] could be replaced by simply g.

4. The value of each item in the sequence V doesn't depend on the previous values. Thus the entire for loop can be replaced by a seq statement:

V:= seq(unapply([f(x,y,i,j)], (x,y)), j= 1..2^i-1);

The seq statement also addresses efficiency error 1, and obviously it also addresses 2 and 3.

Putting it all together, the following version of CreaF will follow your intended design (that it returns a sequence of functions):

CreaF:= proc(i::posint)
local x, y, j;
     seq(unapply([f(x,y,i,j)], (x,y)), j= 1..2^i-1)

end proc;

Simply saying "standard worksheet interface not run properly" isn't enough information for anyone to be able to help you. Could you provide more details, specifically, in what ways didn't it run properly?

@Vic To programmatically check for no solutions and print an appropriate message, you could do something like this

S:= solve(whatever);
if S = NULL then print("No solutions") else
whatever else end if;

@Les Even if your constant k_ is correctly defined in a correctly placed initialization file, it can't be accessed as ScientificConstants:-k_. The accessing syntax is

ScientificConstants:-GetValue(ScientificConstants:-Constant(k_));

The best place to put your initialization file is C:\Users\Leslie\maple.ini. Putting it anywhere in the "Maple 2015" directory or any of its subdirectories isn't recommended, I believe, simply because that's not a place for personal files.

First 407 408 409 410 411 412 413 Last Page 409 of 709