Leo Butler | 1 Jul 15:44 2010
Picon
Picon

Re: Problems with residue


On Tue, 29 Jun 2010, David Chappaz wrote:

< 
< Hi everyone,
< 
<  
< 
< About a year ago, I reported a few problems with the “residue” function, in particular where
residue(expr, z, z0) returns an expression that depends on z….
< 
< More details here:
< 
<  
< 
< http://www.math.utexas.edu/pipermail/maxima/2009/016877.html
< 
<  
< 
< At the time, I was using maxima 5.18.1. I have now updated to 5.21.1 and as far as I can tell, the residue
function still suffers from the same problems.
< 
< But it seems there are now a few more issues:
< 
<  
< 
< In maxima 5.18.1 I used to observe the following behaviour (which is correct):
< 
<  
< 
(Continue reading)

Dan | 1 Jul 16:18 2010
Picon

Re: exporting/displaying in programming code style

On Mon, 28 Jun 2010, W Eryk Wolski wrote:

> Maxima is great, so I started to use it but I am still a newbe
> (searched for quite a while the manual) and can't figure out how
> to export/display an maxima result (some equation)
> in a programming language style?
>
> So instead of getting something like this:
>                 4            3         2     2       3                4    2
> L = - ((2 m2  - m1 m2  - 2 m1  m2  - m1  m2 + 2 m1 ) L3
>
> I would prefer to get a display such as:
>
> L = - ((2 * m2^4  - m1^3 * m2^2  - 2* m1^2 * m2^2  - m1^3  * m2 + 2 *
> m1^4 ) * L3^2

For exporting, stringout() is handy.

HTH,

Dan
Mario Rodriguez | 1 Jul 18:42 2010
Picon

Re: mini / maxi functions


If there are no objections, I'll commit (minmax.lisp) the changes
proposed by Barton and make the corresponding changes in the
documentation and in the descriptive package:

(defmacro opapply (op l)
  `(simplify (cons (list ,op) ,l)))

(defun $lmax (x)
  (cond ((or ($listp x) ($setp x)) (opapply '$max (margs x)))
     (($matrixp x)
      (opapply 'mlist (mapcar #'(lambda (s) (opapply '$max s))
(transpose (mcx (margs x))))))
     (t (merror "The argument to 'lmax' must be a list, set, or
matrix."))))

(defun $lmin (x)
  (cond ((or ($listp x) ($setp x)) (opapply '$min (margs x)))
     (($matrixp x)
      (opapply 'mlist (mapcar #'(lambda (s) (opapply '$min s))
(transpose (mcx (margs x))))))
     (t (merror "The argument to 'lmin' must be a list, set, or
matrix."))))

mini & maxi will be removed from the documentation and transformed into
lmin & lmax wrappers to maintain back portability.

Thanks.

--
(Continue reading)

Stavros Macrakis | 1 Jul 19:23 2010
Picon

Re: mini / maxi functions

I disagree that lmax should perform column-wise max.  I certainly understand that this is a useful and important operation, but I don't think it should be the meaning of lmax, especially since Maxima doesn't allow 'max' on lists (a.k.a. vectors).


            -s

On Thu, Jul 1, 2010 at 12:42, Mario Rodriguez <biomates <at> telefonica.net> wrote:

If there are no objections, I'll commit (minmax.lisp) the changes
proposed by Barton and make the corresponding changes in the
documentation and in the descriptive package:



(defmacro opapply (op l)
 `(simplify (cons (list ,op) ,l)))

(defun $lmax (x)
 (cond ((or ($listp x) ($setp x)) (opapply '$max (margs x)))
    (($matrixp x)
     (opapply 'mlist (mapcar #'(lambda (s) (opapply '$max s))
(transpose (mcx (margs x))))))
    (t (merror "The argument to 'lmax' must be a list, set, or
matrix."))))

(defun $lmin (x)
 (cond ((or ($listp x) ($setp x)) (opapply '$min (margs x)))
    (($matrixp x)
     (opapply 'mlist (mapcar #'(lambda (s) (opapply '$min s))
(transpose (mcx (margs x))))))
    (t (merror "The argument to 'lmin' must be a list, set, or
matrix."))))



mini & maxi will be removed from the documentation and transformed into
lmin & lmax wrappers to maintain back portability.

Thanks.

--
Mario

_______________________________________________
Maxima mailing list
Maxima <at> math.utexas.edu
http://www.math.utexas.edu/mailman/listinfo/maxima

_______________________________________________
Maxima mailing list
Maxima <at> math.utexas.edu
http://www.math.utexas.edu/mailman/listinfo/maxima
Viktor T. Toth | 2 Jul 03:06 2010

Re: itensor problem

Gianluca,

I think it's a case of garbage in, garbage out. You are feeding an invalid
tensor expression to itensor, so you shouldn't expect a valid result.

To itensor, l([a,b])^2 means nothing. It evaluates to l([a,b])*l([a,b])
which has the same indices repeated in the covariant position. This is not a
valid itensor expression and it simply will not work.

To express the contraction of l with itself (I presume that's what you had
in mind), you should be using the expression l([a,b],[])*l([],[a,b]).
However, to carry out the differentiation you also need to tell Maxima how
l([a,b],[]) and l([],[a,b]) are related to one another. Something like this:

load(itensor);
imetric(g);
components(l([],[i,j]),l([a,b],[])*g([],[a,i])*g([],[b,j]));
ishow(diff(l([a,b],[])*l([],[a,b]),l([i,j],[])))$
remcomps(l);
ishow(rename(contract(%th(2))))$

In this code, the second line is needed to make sure that itensor
automatically applies any contraction rules related to the metric. The third
line spells out the contravariant form or l in terms of its covariant form
and the metric, to make sure that all occurrences of the covariant l are
explicit in the expression prior to differentiation. The fourth line carries
out the differentiation. The fifth line (remcomps) is used because we no
longer need or want Maxima to rewrite l([],[a,b]) in terms of the
l([a,b],[]) and the metric during final simplification. The sixth line is
the simplification.

You can also forego this components() business altogether by just writing
down the contraction of l with itself in explicit form:

load(itensor);
imetric(g);
l([a,b],[])*l([c,d],[])*g([],[a,c])*g([],[b,d]);
ishow(contract(diff(%,l([i,j]))))$

In both cases, you get the correct result which, incidentally, is
2*l([],[i,j]) and not 2*kdelta([i,j],[]).

I hope this helps.

Viktor

-----Original Message-----
From: maxima-bounces <at> math.utexas.edu [mailto:maxima-bounces <at> math.utexas.edu]
On Behalf Of Gianluca Malato
Sent: Wednesday, June 30, 2010 2:02 PM
To: maxima <at> math.utexas.edu
Subject: [Maxima] itensor problem

Hi all. I need to differentiate a contraction of tensors in a way such 
that expressions like

diff(contract(l([a,b])^2),l([i,j]));

are to be simplified as

2*kdelta([i,j],[])

and not as

2*kdelta([a],[i])*l([a,b],[])*kdelta([b],[j])

I know that the things I've written aren't correct tensorial expressions 
(there are no repeated indices...) but I need them to be in this form. I 
already know that the things I've writtend correspond to a metric tensor 
equal to unity (no difference between upper and lower indices), but I 
cannot implement it in Maxima.

Can anyone help me?

--

-- 
Gianluca Malato

_______________________________________________
Maxima mailing list
Maxima <at> math.utexas.edu
http://www.math.utexas.edu/mailman/listinfo/maxima
Mario Rodriguez | 2 Jul 07:50 2010
Picon

Re: mini / maxi functions

Stavros Macrakis escribió:
> I disagree that lmax should perform column-wise max.  I certainly 
> understand that this is a useful and important operation, but I don't 
> think it should be the meaning of lmax, especially since Maxima 
> doesn't allow 'max' on lists (a.k.a. vectors).

Then, let's rewrite the functions in descriptive. But I don't like 
col_min, as you proposed in a previous post, since other functions 
(mean, std, etc.) also operate in column wise form without prefix col_ 
in their names.

I prefere smin and smax for the sample min and max. These names also 
follow the name convention of lmin and lmax.

--
Mario
Alexander Shulgin | 2 Jul 22:00 2010
Picon

Hash tables, anyone?

Hi all,

Is it possible to get a reference to a hash table in maxima?

Specifically, I'm trying to write a function which will re-group an
(expanded) expression of a special form

\sum z_j e^{iwk} x^n

where x^n and e^{iwk} are not unique, to a list or a hash table, where
at the top level would be unique x^n's, and at the next level --
unique e^{iwk} terms, and at the last level -- sums of z_j's:

{
  x^{n_1} => {
    e^{iw_1k} => { z_1 + z_2 + ... + z_s },
    e^{iw_2k} => { u_1 + u_2 + ... + u_t },
    ...
  },
  x^{n_2} => { ... },
  ...
}

My plan is to use hash tables to accumulate and efficiently find x^n's
and corresponding e^{iwk} terms, by simply using expressions as
indexes into undeclared arrays (i.e., hash tables).

The rough code sketch is like this:

merge_parts_by_eiwk(k, expr, B) :=
  /* basic checks skipped */
  block(
    [eiwk, rst], /* split expr somehow into eiwk: e^{iwk}, and rst: the rest */
    /* check if unassigned */
    if subvarp(B[eiwk]) then B[eiwk]: rst
    else B[eiwk]: B[eiwk] + rst,
    B);

parts_by_eiwk(k, expr) := merge_parts_by_ewik(k, expr, B /* [1] */);

merge_parts_by_xn(x, k, expr, A) :=
  if atom(expr) then error("merge_parts_by_xp: atom")
  else if op(expr) = "+" then map(lambda([t], merge_parts_by_xn(x, k,
t, A)), to_list(expr))
  else if op(expr) = "*" then block(
    [xn, rst], /* split expr somehow into xn: x^n, and rst: the rest */
    /* check if unassigned */
    if subvarp(A[xn]) then A[xn]: parts_by_eiwk(k, rst)
    else merge_parts_by_eiwk(k, rst, A[xn]),
    A);

parts_by_xn(x, k, expr) := merge_parts_by_xn(x, k, expr, A /* [2] */);

/* [1,2] a function like makehashtable() would fit greatly here */

This kinda works, but the problem is that global namespace is polluted
by 'A' and 'B' indexes, so when parts_by_eiwk() is called for a second
time, it doesn't work with a clean 'B', but with one used in the first
invokation.

If it would be possible to create a new hash table with some function
every time, it would be really great.

Any pointers?

--
Alex
Dieter Kaiser | 2 Jul 22:17 2010
Picon

Cartesian product and integer partitions

We have the open bug reports:

ID: 1990099 wrong integer_partitions(0)
ID: 1993208 cartesian_product incorrect on empyt argument list

The bug reports suggest to do the following changes:

integer_partitions() -> {[]}
cartesian_product()  -> {[]}

Furthermore, when we do the above changes we should change the following
too:

num_partitions(0)          -> 1
num_distinct_partitions(0) -> 1

I think we have two possibilities:

1. We close the bug reports as "won't fix".
2. We do the suggested changes.

I tend to do the changes.

Opinions?

Dieter Kaiser
Richard Fateman | 2 Jul 22:48 2010
Picon

Re: Hash tables, anyone?

I do not know if I am answering your question, but how about this...

f[n,w]:=0;

g(n,w,z) :=    f[n,w]:  f[n,w]+z

then you could  replace  terms of the form  z*exp(%i*w)*x^n    by   
g(n,w,z).
Alexander Shulgin | 3 Jul 05:52 2010
Picon

Re: Hash tables, anyone?

On Fri, Jul 2, 2010 at 23:48, Richard Fateman <fateman <at> cs.berkeley.edu> wrote:
> I do not know if I am answering your question, but how about this...
>
> f[n,w]:=0;
>
> g(n,w,z) :=    f[n,w]:  f[n,w]+z
>
> then you could  replace  terms of the form  z*exp(%i*w)*x^n    by
> g(n,w,z).

Thanks, that's something, but I don't think it would work for me.

I forgot to mention I also need to verify that the initial expression
was in real domain (by checking that for every [x^n, exp(%i*w*k), a +
%i*b] there's [x^n, exp(-%i*w*k), a - %i*b], and that requires the
knowledge of all x^n's and their corresponding exp's, so we are back
to the original question).

And after checking that, I need to derive another expression of the
same structure, but with different coefficients in place of
(a+%i*b)'s, and this is the goal of my problem.  I cannot derive the
desired expression from the initial one, due to it's ungroupped
nature...

--
Alex
_______________________________________________
Maxima mailing list
Maxima <at> math.utexas.edu
http://www.math.utexas.edu/mailman/listinfo/maxima

Gmane