rcorless

630 Reputation

12 Badges

4 years, 70 days

Social Networks and Content at Maplesoft.com

Editor-in-Chief of Maple Transactions (www.mapletransactions.org), longtime Maple user (1st use 1981, before Maple was even released). Most obscure piece of the library that I wrote? Probably `convert/MatrixPolynomialObject` which is called by LinearAlgebra[CompanionMatrix] to compute linearizations of matrix polynomials in several different bases. Do not look at the code. Seriously. Do not look. You have been warned.

MaplePrimes Activity


These are questions asked by rcorless

I'm using Windows, and putting 

Typesetting:−Settings(parserwarnings=false):

into my maple.ini didn't seem to work.  The command

rsolve({u(0) = a, u(1) = b, u(n + 1) = 2*u(n) - (-e^2 + 1)*u(n - 1)}, u(n))

generated a (to me, useless) warning that "e" is sometimes used by people to represent the base of the natural logarithms, and if I meant that, then I'd have to use the palette or exp(1).  Well, as Freud once said, sometimes "e" is just a symbol, not necessarily the base of the natural logarithms.

If I issue the command *in the worksheet* it works.  But, I really *never* want to see that warning so I would like to put it in my maple.ini file.  I have some other things in that file, which *do* get executed, so...

But maybe this is a Windows thing?

My question: how do I turn those warnings off, so I never, ever see them?

The initialization file in question:

#
# Minimal maple.ini file
# RMC 2023-05-01
plots:-setoptions(font = ["Arial", 16], labelfont = ["Arial", 16],
                  axes = boxed,
                  gridlines = true,
                  colour = black ):
Typesetting:−Settings(parserwarnings=false):
print(" Initialization complete. " );

FunWithFibonacci.mw contains a short program with curious behaviour.

f := proc(n) option remember; if n < 2 then 1; else f(n - 1) + f(n - 2); end if; end proc;
F := Compiler:-Compile(f);

This gives a warning message that I don't understand, but never mind*.  I don't know much about the compiler, except that it uses float[8] or complex[8] as universal data types somehow. And maybe I am wrong about that, too.

Now F(n) returns the same number as combinat[fibonacci](n+1) for small n.  This is fine, the difference is one of indexing.  Both f and F return the same thing for small n.  Good.  Both return *integers*.  Checking with whattype confirms that.

Now, F(100) returns a large NEGATIVE integer.  Ok then, this looks like an overflow of an unsigned integer somewhere.

Even before that, though, F(91) returns an integer that is *plausible* but *wrong* :  7540113804746345472 where it should be 7540113804746346429.

So.  My explanation is that the compiler is, indeed, using float[8] internally, and then (for whatever reason) silently converting to integer on return.  Because floats are being used internally, numbers bigger than 2^53 cannot be represented exactly and rounding errors occur.  This happens at f(78) and F(78) which return 14472334024676221 and 14472334024676220 respectively.  

The sign error happens with F(92), where f(92) is just bigger than 2^63.  This suggests that an unsigned 64 bit integer is what the compiler is silently casting its result as.

The help file says "Integer data are limited to word-sized integers on the current hardware. Computations that produce larger integers will raise an overflow exception." So, the overflow exception is being suppressed?

* I may have figured out the error message: if I replace "f" internally by procname, maybe that will fix it.  Will try. Ok, if I do that, the warning message is suppressed, great.  G(30) works, great, though curiously slowly.  G(100) goes into an infinite loop.

Documentation doesn't talk about recursive programs or interaction with option remember.  So maybe that's not allowed?

Consider F := Int( 1/(1+x^n), x=0..1 ).  Once upon a time in Maple ("when tigers smoked pipes") I got it to tell me that F = hypergeom( [1,1/n], [1+1/n], -1 ).  This is true, compact, and very helpful.   n is a positive integer.

I don't seem to be able to do this any more; the combinations of Int, Sum, int, sum, convert/hypergeom, etc are not working for me. I am probably forgetting just which trick I used---I don't think that Maple's capabilities have changed, except that now sometimes I get a finite sum for the integral going from k=0 to k=floor(n/2) which I don't remember seeing before.

Any ideas?

BTW "recusant" is an old word, religious in origin, for someone who refuses to do what they're told, or believe what they're told to believe.

Here's my problem:

phi := (1+sqrt(5))/2;

plots[pointplot]([seq([n, sin(n*phi)], n = 1000 .. 2000)], symbol = point, axes = boxed, labels = [n, typeset('sin(n*phi)')], labeldirections = [horizontal, vertical])

produces a label sin( n phi ).  I want it to say sin( phi n ). 

I've tried the noncommuting times &*  (which prints &*) and the matrix product . (which prints as a function call).

Is there a way to typeset this product in the order that I want?  Here "n" is the variable and "phi" is the constant (yes that looks weird, but so does the graph).  I suspect that there is; I think "typeset" is probably much more powerful than I have been kludging it as.  Help?

screenshot:

maxcharheight.mw

The above worksheet contains some computations I needed for a paper I am writing for the next issue of Maple Transactions.  The computations are within reach of hand computation (which is why I know the right answers).  I wanted Maple to be able to do them, however.

I couldn't make Maple do anything but verify that I was right (this is useful, I will admit).  But can anyone find any artful ways to simplify or solve any of those steps?  I suspect that this is quite hard in general, but with these things involving phi = (1+sqrt(5))/2 it's likely that others would find some "art" useful.  By the way, phi is not built-in to Maple, as far as I know.  Any more votes for including it?

There is an undocumented feature reported here that is useful: asympt works with "leadterm" and this turns out to be necessary.  I forget how I found out that leadterm works with asympt.  It's not in ?asympt, though I think that it should be.

-r

1 2 Page 1 of 2