arbitrary length input

View: New views
20 Messages — Rating Filter:   Alert me  
< Prev | 1 - 2 - 3 | Next >

arbitrary length input

by Fabrizio Caruso-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

how can I define a function, say lcm,
with an input of arbitrary length, e.g.:
lcd(2,3), lcm(4,5,6,6)?

   Thanx in advance

  Fabrizio Caruso


 

_______________________________________________
Maxima mailing list
Maxima@...
http://www.math.utexas.edu/mailman/listinfo/maxima

Re: arbitrary length input

by Barton Willis :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Fabrizio Caruso wrote on 07/26/2006 11:49:46 AM:

> Hi,
>
> how can I define a function, say lcm,
> with an input of arbitrary length, e.g.:
> lcd(2,3), lcm(4,5,6,6)?

If you need a lcm function, the lcm function in
/share/simplification/functs.mac
might work for you:

(%i1) ? lcm;
 - Function: lcm (<expr_1>, ..., <expr_n>)
     Returns the least common multiple of its arguments.  The arguments
     may be general expressions as well as integers.
     `load ("functs")' loads this function.
(%o1) false
(%i2) load(functs)$
(%i3) lcm(4,5,6,6);
(%o3) 60

If not, here is an example of how to define a function that takes an
arbitrary number of arguments:

(%i4) avg([x]) := apply("+",x) / length(x)$
(%i5) avg(a,b);
(%o5) (b+a)/2
(%i6) avg(a,b,c);
(%o6) (c+b+a)/3

Barton


_______________________________________________
Maxima mailing list
Maxima@...
http://www.math.utexas.edu/mailman/listinfo/maxima

RE: arbitrary length input

by Richard Fateman :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

try

lcd([n]):=

then refer to length(n),  n[1], n[2], etc.

So you could do if length(n)=1 then n[1] else lcd(n[1],apply(lcd,rest(n));

or some such thing.

RJF
 

-----Original Message-----
From: maxima-admin@... [mailto:maxima-admin@...] On
Behalf Of Fabrizio Caruso
Sent: Wednesday, July 26, 2006 9:50 AM
To: maxima@...
Subject: [Maxima] arbitrary length input

Hi,

how can I define a function, say lcm,
with an input of arbitrary length, e.g.:
lcd(2,3), lcm(4,5,6,6)?

   Thanx in advance

  Fabrizio Caruso


 

_______________________________________________
Maxima mailing list
Maxima@...
http://www.math.utexas.edu/mailman/listinfo/maxima

_______________________________________________
Maxima mailing list
Maxima@...
http://www.math.utexas.edu/mailman/listinfo/maxima

ICMS, EACA and my wishes

by Fabrizio Caruso-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all,

I was recently at the ICMS and EACA conferences in Spain,
where I showed my Maxima package and the electronic book
which uses it.
It was a pitty not to see any of you there.

I think we should do something to be more visible.

I think I managed to convince somehow to use Maxima
or at least give it a try.

There were a few people who have used Maxima.
One of which is the implementer of the Texmacs interface
which will get some bugfixes very soon.

---------

I also have a wish for the very next version of xmaxima:
namely, the possibility to reedit a former input line and
evaluate it even when the (re)editing starts from the beginning
Note:
If I have
(%i1) 2+2;
    4
and I re-edit as:
(%i2) 3+2+2;
    4
(3 is shown in a different color)

but (in the latest xmaxima under Windows)

(%i2) 2+2+3;
    7

In Linux the previous xmaxima had the same problem
even when the re-editing was done from the end.

----------

I also have 2 wishes for the next version
of (x)maxima (I guess this is possible only after 5.10):

1. name spaces
(2 level name space system would do in most cases)

2. history in xmaxima
(useful when the output is hundreds of lines and
you want to see what you typed before)

   Regards

   Fabrizio

_______________________________________________
Maxima mailing list
Maxima@...
http://www.math.utexas.edu/mailman/listinfo/maxima

Re: ICMS, EACA and my wishes

by Jaime E. Villate :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, 2006-09-15 at 22:52 +0200, Fabrizio Caruso wrote:
> I was recently at the ICMS and EACA conferences in Spain,
> where I showed my Maxima package and the electronic book
> which uses it.
> It was a pitty not to see any of you there.
When and where did those conferences take place? I've received
several announcements of conferences in Spain where a
paper related to Maxima could perfectly fit. I do not
have enough time and funds to attend all of them, so I've just
picked up one (SIIE06 in University of Leon, by the end
of October).
If I knew you had sent a contribution on Maxima to the
ICMS and EACA I might have tried to attend any of those.

> I also have a wish for the very next version of xmaxima:
> namely, the possibility to reedit a former input line and
> evaluate it even when the (re)editing starts from the beginning
> Note:
> If I have
> (%i1) 2+2;
>     4
> and I re-edit as:
> (%i2) 3+2+2;
>     4
> (3 is shown in a different color)
You have found yet another bug. Thanks for reporting it. I'll
try to fix it.

Regards,
Jaime


_______________________________________________
Maxima mailing list
Maxima@...
http://www.math.utexas.edu/mailman/listinfo/maxima

Re: ICMS, EACA and my wishes

by Jaime E. Villate :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, 2006-09-15 at 22:52 +0200, Fabrizio Caruso wrote:
> I also have 2 wishes for the next version
> of (x)maxima (I guess this is possible only after 5.10):
...
> 2. history in xmaxima
> (useful when the output is hundreds of lines and
> you want to see what you typed before)

That has already been implemented in Xmaxima. Use
Alt-p and Alt-n to navigate the history of previous
commands (or select "Previous Input" and "Next Input"
in the "Edit" menu).

If you want to recall the commands you've typed before,
starting with something, for instance "int", type int
and then press Alt-p one or more times.

Regards,
Jaime

_______________________________________________
Maxima mailing list
Maxima@...
http://www.math.utexas.edu/mailman/listinfo/maxima

Re: ICMS, EACA and my wishes

by Jaime E. Villate-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, 2006-09-15 at 22:52 +0200, Fabrizio Caruso wrote:
> I was recently at the ICMS and EACA conferences in Spain,
> where I showed my Maxima package and the electronic book
> which uses it.
> It was a pitty not to see any of you there.
When and where did those conferences take place? I've received
several announcements of conferences in Spain where a
paper related to Maxima could perfectly fit. I do not
have enough time and funds to attend all of them, so I've just
picked up one (SIIE06 in University of Leon, by the end
of October).
If I knew you had sent a contribution on Maxima to the
ICMS and EACA I might have tried to attend any of those.

> I also have a wish for the very next version of xmaxima:
> namely, the possibility to reedit a former input line and
> evaluate it even when the (re)editing starts from the beginning
> Note:
> If I have
> (%i1) 2+2;
>     4
> and I re-edit as:
> (%i2) 3+2+2;
>     4
> (3 is shown in a different color)
You have found yet another bug. Thanks for reporting it. I'll
try to fix it.

Regards,
Jaime

_______________________________________________
Maxima mailing list
Maxima@...
http://www.math.utexas.edu/mailman/listinfo/maxima

Re: ICMS, EACA and my wishes

by Jaime E. Villate-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, 2006-09-15 at 22:52 +0200, Fabrizio Caruso wrote:
> I also have 2 wishes for the next version
> of (x)maxima (I guess this is possible only after 5.10):
...
> 2. history in xmaxima
> (useful when the output is hundreds of lines and
> you want to see what you typed before)

That has already been implemented in Xmaxima. Use
Alt-p and Alt-n to navigate the history of previous
commands (or select "Previous Input" and "Next Input"
in the "Edit" menu).

If you want to recall the commands you've typed before,
starting with something, for instance "int", type int
and then press Alt-p one or more times.

Regards,
Jaime


_______________________________________________
Maxima mailing list
Maxima@...
http://www.math.utexas.edu/mailman/listinfo/maxima

Re: ICMS, EACA and my wishes

by Robert Dodier-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Fabrizio,

It's too bad there was nobody from the Maxima project to meet
you at the conferences you mentioned. I hope that sooner or later
we can all meet in person.

> 1. name spaces

Dunno if you saw this already --
http://maxima.sourceforge.net/wiki/index.php/User-level%20namespaces%20in%20Maxima
http://www.math.utexas.edu/pipermail/maxima/2006/014401.html

The namespace code as it stands seems to work OK but there
is some strangeness. I think what annoys me the most is that
every symbol in a function (including arguments and local variables)
gets displayed with the namespace name, which makes the
function definition more verbose. Since Maxima variables are
dynamic, not lexical, it must be like that, I think. Doubtless there
is more strangeness than that.

> 2. history in xmaxima

Aside from alt-p + alt-n, there is also the playback function
which displays previous inputs and outputs.

best,
Robert
_______________________________________________
Maxima mailing list
Maxima@...
http://www.math.utexas.edu/mailman/listinfo/maxima

Macsyma is still being sold, isn't it?

by Fabrizio Caruso-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi

I stumbled upon http://www.symbolics.com/

Is Macsyma still being sold?

If any of you has a copy of it,
could they tell me if it does something
that Maxima doesn't do or if it performs better
than Maxima?

If Macsyma were somehow still in business
would the owner of Macsyma be allowed to use
and sell portions of our code in their software?

   Regards

   Fabrizio

_______________________________________________
Maxima mailing list
Maxima@...
http://www.math.utexas.edu/mailman/listinfo/maxima

Re: Macsyma is still being sold, isn't it?

by Stavros Macrakis :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 9/21/06, Fabrizio Caruso <caruso@...> wrote:
> I stumbled upon http://www.symbolics.com/
> Is Macsyma still being sold?

Apparently.

> If any of you has a copy of it, could they tell me if it does something
> that Maxima doesn't do or if it performs better than Maxima?

Commercial Macsyma forked from DOE Macsyma (the basis of Maxima) in
1982.  It has many man-years of professional development in it in many
areas, both mathematical and user-interface.  On the other hand, there
is no longer either a development or even a support staff any more.
Without access to source code, users cannot modify the core
functionality or fix bugs in it.

> If Macsyma were somehow still in business would the owner of
> Macsyma be allowed to use and sell portions of our code in their software?

Almost all of Maxima is covered by GPL, so it could not be folded in
to the commercial Macsyma codebase unless it were released under a
compatible free/open source license.  On the other hand, there is
presumably nothing preventing a user from individually loading in
Maxima code to Macsyma, assuming the interfaces are the same.

                 -s
_______________________________________________
Maxima mailing list
Maxima@...
http://www.math.utexas.edu/mailman/listinfo/maxima

Re: Macsyma is still being sold, isn't it?

by Richard Fateman :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



> -----Original Message-----
> From: maxima-bounces@... [mailto:maxima-
> bounces@...] On Behalf Of Stavros Macrakis
> <snip>

>
> > If Macsyma were somehow still in business would the owner of
> > Macsyma be allowed to use and sell portions of our code in their
> software?
>
> Almost all of Maxima is covered by GPL, so it could not be folded in
> to the commercial Macsyma codebase unless it were released under a
> compatible free/open source license.

Almost all of Maxima "by weight" not necessarily "by value" is contained in
the code from the US Department of Energy, "DOE-Macsyma" from 1982. This
code is not under GPL. Code added to that base is subject to whatever
licensing was placed on it by the author.

  On the other hand, there is
> presumably nothing preventing a user from individually loading in
> Maxima code to Macsyma, assuming the interfaces are the same.

A user can load a piece of "GPL code" into commercial Macsyma, and use it
himself. The GPL comes into play if that user wished to distribute that
package further.  

If you are afraid that someone will use your code without your permission,
you can mark it as copyright (your name), and then either give permission or
not. You can both keep a copy (to sell to Macsyma Inc, and to give free to
Maxima project). Alternatively, you can mark a copy as GPL or LGPL.

RJF

_______________________________________________
Maxima mailing list
Maxima@...
http://www.math.utexas.edu/mailman/listinfo/maxima

help: outputing a function depending on a function parameter

by Fabrizio Caruso-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi

I am trying to write a function that takes an ordering on sequences
as a parameter and output the corresponding (total) degree
compatible ordering.
So, the output should be again a boolean function.
I thought that one way to do it could be through
lambda expressions but what I do is wrong.

I would like to do something like:
makeDegreeCompatible : /* or makeDegreeCompatible(order) := ... */
  lambda([order],
    lambda([x,y],
      (sum(x[i],i,1,length(x))<sum(y[i],i,1,length(y))) or
      (sum(x[i],i,1,length(x))=sum(y[i],i,1,length(y))) and
      order(x,y))
    );

but it does not work because the parameter order is within
a lambda expression and it is not substituted with the
value passed as a parameter.

Could someone please help me?

  Fabrizio

 
_______________________________________________
Maxima mailing list
Maxima@...
http://www.math.utexas.edu/mailman/listinfo/maxima

Re: help: outputing a function depending on a function parameter

by Barton Willis :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Maybe you need to use buildq. Something like:

(%i1) makeDegreeCompatible(order) ::= buildq([order],
   lambda([x,y],
      (sum(x[i],i,1,length(x))<sum(y[i],i,1,length(y))) or
      (sum(x[i],i,1,length(x))=sum(y[i],i,1,length(y))) and
      order(x,y)))$
(%i2) f : makeDegreeCompatible(lambda([p,q], is(p[1] > q[1])));
(%o2) lambda([x,y],sum(x[i],i,1,length(x))<sum(y[i],i,1,length(y)) or
sum(x[i],i,1,length(x))=
sum(y[i],i,1,length(y)) and lambda([p,q],is(p[1]>q[1]))(x,y))
(%i3) f([1,2,3],[4,5,6]);
(%o3) true

Barton

maxima-bounces@... wrote on 09/26/2006 08:35:43 AM:

> Hi
>
> I am trying to write a function that takes an ordering on sequences
> as a parameter and output the corresponding (total) degree
> compatible ordering.
> So, the output should be again a boolean function.
> I thought that one way to do it could be through
> lambda expressions but what I do is wrong.
>
> I would like to do something like:
> makeDegreeCompatible : /* or makeDegreeCompatible(order) := ... */
>   lambda([order],
>     lambda([x,y],
>       (sum(x[i],i,1,length(x))<sum(y[i],i,1,length(y))) or
>       (sum(x[i],i,1,length(x))=sum(y[i],i,1,length(y))) and
>       order(x,y))
>     );
>
> but it does not work because the parameter order is within
> a lambda expression and it is not substituted with the
> value passed as a parameter.
>
> Could someone please help me?
>
>   Fabrizio
>
>
> _______________________________________________
> Maxima mailing list
> Maxima@...
> http://www.math.utexas.edu/mailman/listinfo/maxima
_______________________________________________
Maxima mailing list
Maxima@...
http://www.math.utexas.edu/mailman/listinfo/maxima

Re: help: outputing a function depending on a function parameter

by Richard Fateman :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

maybe try  apply(order,[x,y])    instead of order(x,y).

RJF
 

>

_______________________________________________
Maxima mailing list
Maxima@...
http://www.math.utexas.edu/mailman/listinfo/maxima

apply(matrix,...) fails

by Fabrizio Caruso-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


With the latest version of Maxima I have encountered
a new problem maybe caused by some limited buffer or
new default setting:

If I do a
"
apply(matrix,Hilbert(100))
"
where for instance Hilbert(100) is the 100x100 Hilbert matrix,
I get an error message on both the latest Windows and
Linux versions of Maxima:
"
Maxima encountered a Lisp error:
..... MACSYMA-TOP-LEVEL [or a callee] requires less than one
hundered arguments
.....
"

Is there a way to fix this or to convert a a 100x100 list
of lists into a 100x100 matrix?

  Regards

   Fabrizio

_______________________________________________
Maxima mailing list
Maxima@...
http://www.math.utexas.edu/mailman/listinfo/maxima

Parent Message unknown Re: apply(matrix,...) fails

by Barton Willis :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

with linearalgebra:

(%i9) load(linearalgebra)$
(%i10) m : hilbert_matrix(100)$
(%i11) m[42,42];
(%o11) 1/83

without:

(%i12) q: genmatrix(lambda([i,j],1/(i+j-1)),100,100)$
(%i13) q[42,42];
(%o13) 1/83

The limitation of apply('matrix, ...) comes from the
Lisp you are using. Maybe before your Maxima was compiled
with a different Lisp.  I believe that this limit on
the number of function arguments is allowed --- it's not
a Lisp bug.

Barton

-----maxima-bounces@... wrote: -----

>To: maxima@...
>From: Fabrizio Caruso
>Sent by: maxima-bounces@...
>Date: 09/28/2006 06:48PM
>Subject: [Maxima] apply(matrix,...) fails
>
>
>With the latest version of Maxima I have
>encountered
>a new problem maybe caused by some limited buffer
>or
>new default setting:
>
>If I do a
>"
>apply(matrix,Hilbert(100))
>"
>where for instance Hilbert(100) is the 100x100
>Hilbert matrix,
>I get an error message on both the latest Windows
>and
>Linux versions of Maxima:
>"
>Maxima encountered a Lisp error:
>..... MACSYMA-TOP-LEVEL [or a callee] requires
>less than one
>hundered arguments
>.....
>"
>
>Is there a way to fix this or to convert a a
>100x100 list
>of lists into a 100x100 matrix?
>
>  Regards
>
>   Fabrizio
>
>_______________________________________________
>Maxima mailing list
>Maxima@...
>http://www.math.utexas.edu/mailman/listinfo/maxim
>a
>
>
_______________________________________________
Maxima mailing list
Maxima@...
http://www.math.utexas.edu/mailman/listinfo/maxima

Parent Message unknown Re: apply(matrix,...) fails

by Barton Willis :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

...third method:

(%i19) funmake('matrix, makelist(makelist(1/(i+j-1),i,1,100),j,1,100))$

Barton

_______________________________________________
Maxima mailing list
Maxima@...
http://www.math.utexas.edu/mailman/listinfo/maxima

Re: apply(matrix,...) fails

by Robert Dodier-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 9/28/06, Barton Willis <willisb@...> wrote:

> The limitation of apply('matrix, ...) comes from the
> Lisp you are using. Maybe before your Maxima was compiled
> with a different Lisp.  I believe that this limit on
> the number of function arguments is allowed --- it's not
> a Lisp bug.

Well, this behavior falls into the category of features which may
as well be bugs. By default GCL allows 64 function arguments max.
I'm pretty sure we need to rework matrix (and maybe other functions
which take an arbitrary number of arguments) so that the user
is much less likely to bump into this.

I believe something as simple as
:lisp (fmakunbound '$matrix)
:lisp (defmspec $matrix (L) `(($matrix) ,@(mapcar #'meval (cdr L))))
(plus the error-checking now present in $matrix) would solve this problem
(by avoiding a Lisp function call). Comments?

Other Lisp implementations also limit the number of arguments,
but the limits are greater. I don't remember what the numbers are.

best
Robert
_______________________________________________
Maxima mailing list
Maxima@...
http://www.math.utexas.edu/mailman/listinfo/maxima

Re: apply(matrix,...) fails

by Stavros Macrakis :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 9/29/06, Robert Dodier <robert.dodier@...> wrote:
On 9/28/06, Barton Willis <willisb@...> wrote:
> The limitation of apply('matrix, ...) comes from the
> Lisp you are using....
Well, this behavior falls into the category of features which may
as well be bugs. By default GCL allows 64 function arguments max.
I'm pretty sure we need to rework matrix (and maybe other functions
which take an arbitrary number of arguments) so that the user
is much less likely to bump into this.

I agree.  If the underlying Lisp has a silly limitation, we should code around it, not expose it to the Maxima user.

             -s


_______________________________________________
Maxima mailing list
Maxima@...
http://www.math.utexas.edu/mailman/listinfo/maxima
< Prev | 1 - 2 - 3 | Next >