declare L a member of an integer sequence



Nijso Beishuizen <nijso at hotmail.com> writes:
> I was wondering if I could declare that
>
> ds : -(L+6)/4
>
> is a positive integer, so L=-10,-14,..
>
> so basically integerp(ds) would give true and ds>0 would be true?

As explained in the manual, integerp isn't the function you are looking
for. Something like askinteger is probably closer to what you want for
testing with.

If you want to say that ds is an integer, you can either do:

  declare (ds, integer);

or you can tell Maxima something about L. The problem with the first
approach is that if I call something like

  askinteger (ds)

after what you've written above, it gets translated to

  askinteger (-(L+6)/4)

before askinteger (or integerp or whatever) gets to run. As a result,
any declaration on ds won't have any effect.

Now, I don't know how to tell Maxima directly that L is one of (-10,
-14, ...). However, I can write ds slightly differently, with

  ds : -((-10 - 4*K) + 6)/4;

and now I can tell Maxima that K is a non-negative integer. Ahah! A
transcript:

  Maxima 5.29.1 http://maxima.sourceforge.net
  using Lisp GNU Common Lisp (GCL) GCL 2.6.7 (a.k.a. GCL)
  Distributed under the GNU Public License. See the file COPYING.
  Dedicated to the memory of William Schelter.
  The function bug_report() provides bug reporting information.
  (%i1) ds : -((-10 - 4*K)  + 6)/4;
                                      4 K + 4
  (%o1)                               -------
                                         4
  (%i2) assume (K >= 0)$ declare (K, integer)$

  (%i4) is (ds > 0);
  (%o4)                                true
  (%i5) askinteger (ds);
  (%o5)                                 yes


Is this what you were after?

Rupert
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 315 bytes
Desc: not available
URL: <http://www.math.utexas.edu/pipermail/maxima/attachments/20130210/147edcc9/attachment.pgp>;