Stavros Macrakis | 1 Dec 03:19 2004
Picon

Re: exp(x) vs %e^x in displayed output?

> I guess this      ^^^^^^^^^^^^^^    wants to be $%edispflag.

Oops.

> Stavros, if it seems to work do you want to commit this
> patch to cvs??  I would argue in favor of that.

I have no objections, as long as others find it useful.  The main
arguments against it are:

1) increased complexity (as always with new options);

2) what if someone really wants 1/exp(x) instead of exp(-x)?

But I'll let The Users (something like The People) decide.

         -s
Raymond Toy | 1 Dec 15:48 2004
Picon

Running testsuite


I've added a few tests in tests/rtesthyp.lisp for the hypergeometric
function simplifier, hgfred, and when I try to run the tests via
run_testsuite, I get different results.  But when I enter in each
expression by hand, I get the desired results.

For example,

(%i1) assume(not(equal(z,0)));

(%o1)                          [not equal(z, 0)]
(%i2) hgfred([v+1/2],[2*v+1],2*%i*z);

                     v/2                               %i z
                    4    bessel_j(v, z) gamma(v + 1) %e
(%o2)               ---------------------------------------
                                       v
                                      z

But when I run the test suite, I get

********************** Problem 4 ***************
Input:
        1
hgfred([- + v], [1 + 2 v], 2 %i z)
        2

Result:
            1
%f    ([v + -], [2 v + 1], 2 %i z)
(Continue reading)

jean-denis fouks | 2 Dec 12:48 2004
Picon

using functions as arguments

Hi everybody,

Some arguments of a user-defined function can be functions:
----------------------------------------
C1) double(f,a):=2*f(2*a);
(D1)                double(f, a) := 2 f(2 a)
(C2) double(sin,%pi/3);
(D2)                     SQRT(3)
----------------------------------------

A function can be defined as the derivative of another one:
----------------------------------------
(C3) sin2x2(x):=2*sin(x2);
                       2
(D3)                 sin2x2(x) := 2 SIN(x )
(C4) df(x):=''(diff(sin2x2(x),x));
                          2
(D4)                  df(x) := 4 x COS(x )
(C5) df(3);
(D5)                    12 COS(9)
----------------------------------------
The previous construction can be used in the definition of a function:
----------------------------------------
(C6) N(a):=block(dg(x):=''(diff(sin2x2(x),x)),dg(2*a));
                        2
(D6)          N(a) := BLOCK(dg(x) := 4 x COS(x ), dg(2 a))
(C7) N(3);
(D7)                   24 COS(36)
-----------------------------------------
So i don't understand why this does not work:
(Continue reading)

Viktor T. Toth | 2 Dec 14:51 2004

RE: using functions as arguments

You want to make sure that the differential operator is executed AFTER f is
substituted but BEFORE the substitution for x has been made. I.e., when you
call Nf(sin,3), you want to make sure that at one point, diff(sin(x),x) (and
NOT diff(sin(8),8) or diff(f(8),8)) gets evaluated.

I'm sure there's a more elegant way, but the following does the trick and is
not terribly ugly:

(%i1)
Nf(f,a):=block([u,v],fd(x):=''(diff(f(x),x)),u:ev(fd(v),diff),ev(u,v=a+5))$
(%i2) Nf(sin,3);
(%o2)                               cos(8)
(%i3) Nf(sin,x);
(%o3)                             cos(x + 5)

The idea is to evaluate fd(x) first with a dummy (non-numeric) argument that
causes the differentiation to be carried out, and only then substitute the
actual argument that could be a number or expression that cannot serve as
the second argument to diff().

Come to think of it, there is a more elegant way, one that doesn't even use
a "local" function:

(%i4) Nf(f,a):=block([x,fd],fd:diff(f(x),x),ev(fd,x=a+5))$
(%i5) Nf(sin,3);
(%o5)                               cos(8)

The reason why this works is that fd being an assignment gets evaluated with
f having its proper value, but x being a dummy parameter, so the
differentiation is carried out with respect to x BEFORE the call is made to
(Continue reading)

Raymond Toy | 2 Dec 23:04 2004
Picon

jacobi_p expansion?


jacobi_p(2,1/2,-1,1-2*x) is a polynomial (of course).  But maxima
doesn't expand that out.  Should it?

Note that if n is an integer, jacobi_p(n,1/2,-1,1-2*x) gives a series
expression, which I can then use via ev(%,n=2) to get a polynomial.

Ray
Fabrizio Caruso | 3 Dec 16:14 2004
Picon

parameter passing

Hello,

I have a serious problem with parameters in Maxima.
I don't understand parameters passing in Maxima:

(1) is there a way to pass an array/matrix as a parameter by  reference?
For example, in order to have a function change some elements in an 
array/matrix,
do I always need to copy the whole array/matrix locally?

(2) how do I declare an array local? do I need to use the "local"
command. Putting it in brackets after the "block" command seems not to work.

Could you give me a toy example?
like for instance a function that modifies a matrix passed as a parameter
by setting one value to zero.

   Thanks in advance

    Fabrizio Caruso
Fabrizio Caruso | 3 Dec 17:23 2004
Picon

list manipulators

Hello,

Sorry for my newbie questions.

Is there a way to take portions of lists
which is consistent:
part([a,b,c,d,e,f],[2,2]) yields [b,b].
I think the result should be [b]
This also happens if I use create_list.

If you use these commands you'll have to check all
the times if the range is trivial.

Is there a clean way to do this?

   Thanks

    Fabrizio Caruso
jean-denis fouks | 3 Dec 17:38 2004
Picon

Re: parameter passing

Hello,
Fabrizio Caruso wrote:

> Hello,
>
> I have a serious problem with parameters in Maxima.
> I don't understand parameters passing in Maxima:
>
> (1) is there a way to pass an array/matrix as a parameter by  reference?
> For example, in order to have a function change some elements in an 
> array/matrix,
> do I always need to copy the whole array/matrix locally?
>
> (2) how do I declare an array local? do I need to use the "local"
> command. Putting it in brackets after the "block" command seems not to 
> work.
>
> Could you give me a toy example?
> like for instance a function that modifies a matrix passed as a parameter
> by setting one value to zero.
>
>   Thanks in advance
>
>    Fabrizio Caruso

Here is a basic example:
(C1) t:[1,2];
(D1)                     [1, 2]
(C2) h(m):=block(m[1]:0,m);
(D2)                h(m) := BLOCK(m  : 0, m)
(Continue reading)

Richard Fateman | 3 Dec 17:54 2004
Picon

Re: parameter passing

Fabrizio Caruso wrote:

> Hello,
> 
> I have a serious problem with parameters in Maxima.
> I don't understand parameters passing in Maxima:
> 
> (1) is there a way to pass an array/matrix as a parameter by  reference?
> For example, in order to have a function change some elements in an 
> array/matrix,
> do I always need to copy the whole array/matrix locally?

The issue is... if you do  array(z,3,3)  and
have a function
    f(h):= ..... h[2,2] ...  then call as  f(z),
  a (new) array, h, appears to be used, rather than z[2,2].
Something like  f(h):= ...  q:ev(h),  q[2,2]:...   would
seem to be needed,  or an assignment statement that
evaluates h[2,2]:::  differently.
A way around this is to NOT pass z as a parameter, but leave
it global.

> 
> (2) how do I declare an array local? do I need to use the "local"
> command. Putting it in brackets after the "block" command seems not to 
> work.
> 
maybe block ([a], array(a,3,3)... )  will do what you want?
> Could you give me a toy example?
> like for instance a function that modifies a matrix passed as a parameter
(Continue reading)

Barton Willis | 3 Dec 18:07 2004

Re: list manipulators

part(expr, n1) returns the n1-th part of expr and part(expr, n1,n2) 
returns the n2-th part of the
n1-th part of expr.  The documentation isn't clear on what  part(expr, 
[n1,n2]) means.
I think part(expr, [n1,n2])  behaves something like

part(expr, [n1,n2])  == apply(op(expr), [part(expr,n1), 
part(part(expr,n2)]).

My recommendation is that if you want to extract a sublist of a list, 
write your
own function.

Barton

"Fabrizio Caruso" <fabrizio_caruso <at> hotmail.com>
Sent by: maxima-admin <at> math.utexas.edu
12/03/2004 10:23 AM

 
        To:     maxima <at> math.utexas.edu
        cc: 
        Subject:        [Maxima] list manipulators

Hello,

Sorry for my newbie questions.

Is there a way to take portions of lists
which is consistent:
(Continue reading)


Gmane