1 Sep 2007 02:41

### Re: bfloat roots of polynomials

```On 8/31/07, Raymond Toy (RT/EUS) <raymond.toy <at> ericsson.com> wrote:

> Hope nobody minds, but I'm appending a small maxima program to compute
> the roots of a polynomial with bfloat coefficients.

Looks good to me -- I hope you'll consider committing it.

Robert
```
1 Sep 2007 02:42

### Re: "`map' is truncating" message and other assorted messages

```On 8/31/07, Raymond Toy (RT/EUS) <raymond.toy <at> ericsson.com> wrote:

> After looking at the Lisp code, I see there is an undocumented variable
> mapprint that controls whether to print the messages or not.
>
> Perhaps mapprint should be documented, and maybe set to false.

Agreed on both counts.

Robert
```
1 Sep 2007 02:55

### Re: Efficient Lisp functions -- using results of symbolic calculations numerically

```On 8/31/07, Bruno Daniel <bruno.daniel <at> gmx.net> wrote:

> #'(LAMBDA (X)
>     (DECLARE (TYPE DOUBLE-FLOAT X) (VALUES DOUBLE-FLOAT)
>      (OPTIMIZE (SPEED 3) (SPACE 0) (SAFETY 0) (DEBUG 0)))
>     (+ (* 2 (COS (EXPT X 2))) (- (* (/ (EXPT X 2)) (SIN (EXPT X 2))))))

Bruno, as mentioned by Stavros, the Maxima-to-Lisp translator
can exploit some declarations to generate faster Lisp code.
Here is an example.

Without declaration for x:

g(x):=2*cos(x^2)-sin(x^2)/x^2\$
translate (g);
:lisp #'\$g
=>
#<FUNCTION \$G (\$X) (DECLARE (IN-DEFUN \$G) (SPECIAL \$X))
(BLOCK \$G
(ADD* (MUL* 2 (SIMPLIFY (LIST '(%COS) (POWER \$X 2))))
(*MMINUS (MUL* (POWER \$X -2) (SIMPLIFY (LIST '(%SIN) (POWER \$X 2)))))))>

With declaration for x:

h(x):=(mode_declare(x,float),2*cos(x^2)-sin(x^2)/x^2)\$
translate (h);
:lisp #'\$h
=>
#<FUNCTION \$H (\$X) (DECLARE (IN-DEFUN \$H) (SPECIAL \$X) (FLONUM \$X))
(BLOCK \$H
```

1 Sep 2007 12:57

### Re: bfloat roots of polynomials

```Hi

I'm trying to use your program for polynomial given by recurence
relation ( see: http://fraktal.republika.pl/mset_centers.html);
My polynomial :
P(n):=if n=0 then 0 else P(n-1)^2+c;
List of coefficients:
give_coefficients(n):=block( P(n):=if n=0 then 0 else P(n-1)^2+c,
Pn:expand(P(n)), degree:hipow(Pn,c),
a:makelist(coeff(Pn,c,degree-i),i,0,degree) );
example of use:
a:give_coefficients(3);
(%o7) [1,2,1,1,0]

but :
polyroots(a);
does not work.
What I do wrong?

Raymond Toy (RT/EUS) pisze:
> Hope nobody minds, but I'm appending a small maxima program to compute
> the roots of a polynomial with bfloat coefficients.  It uses
> Jenkins-Traub to compute the roots, much like allroots.  But this
> doesn't have all the refinements of allroots.  The code is simple, and
> could probably be done much better---I'm not a very good maxima
> programmer.
>
> The polynomial is given as a list of the coefficients, arranged in
```

1 Sep 2007 14:20

### Re: bfloat roots of polynomials

```Adam Majewski wrote:
> Hi
>
> I'm trying to use your program for polynomial given by recurence
> relation ( see: http://fraktal.republika.pl/mset_centers.html);
> My polynomial :
> P(n):=if n=0 then 0 else P(n-1)^2+c;
> List of coefficients:
> give_coefficients(n):=block( P(n):=if n=0 then 0 else P(n-1)^2+c,
> Pn:expand(P(n)), degree:hipow(Pn,c),
> a:makelist(coeff(Pn,c,degree-i),i,0,degree) );
> example of use:
> a:give_coefficients(3);
> (%o7) [1,2,1,1,0]
>
> but :
> polyroots(a);
> does not work.
> What I do wrong?
>
>
Did you get the second e-mail with the new_poly function in it?  You
need that.  And since the coefficients are rational, the roots will only
have double-float precision.  If you want more precision, you need to
convert them to bfloats and set fpprec appropriately.

However, even with that, it doesn't work either.   The constant term
is zero, which confuses the algorithm.   If you remove that, polyroots
works:

```

1 Sep 2007 14:40

### roots of polynomials

```Hi

I'm trying to compute roots of polynomial given by recurence
relation

My polynomial :
P(n):=if n=0 then 0 else P(n-1)2+c;

I'm using allroots
see: http://fraktal.republika.pl/mset_centers.html
but for n>6 roots seems to be wrong to me.

Can it be done better ?

```
1 Sep 2007 17:05

### Bug in limit?

```Hello group,

Consider

,----
| (%i21) tlimswitch : false;
| (%o21)                               false
| (%i22) limit(sqrt(x^2 + x +1) + x, x, minf);
| Is  x  positive or negative?
|
| pos;
|                                         1
| (%o22)                                - -
|                                         2
| (%i23) limit(sqrt(x^2 + x +1) + x, x, minf);
| Is  x  positive or negative?
|
| neg;
| (%o23)                               minf
`----

If we take a limit as x -> -oo, then we should assume that x is
negative and no question should be asked at all.  %o22 is the right
answer for the original limit, although in the given context is
wrong or, rather, meaningless.  And of course %o23 is wrong.

Best,
Nikos
```
1 Sep 2007 17:56

### Re: "`map' is truncating" message and other assorted messages

```Re maperror and mapprint,

Controlling the behavior of functions by global variables is ugly and
error-prone.  For libraries of Maxima code to have predictable
behavior, every use of "map" needs to be surrounded by something like

block([maperror:<some value>,mapprint:<some value>], ... map(...) ...)

We should bite the bullet and decide what behavior we want map to
have, and get rid of both maperror and mapprint.

The argument for allowing different lengths of argument is
convenience, for example, my favorite map("+",-list,rest(list)) for
differences (though it would be nice if "-" were also a binary

The argument for forbidding different length of arguments (or warning)
is to help the user catch certain kinds of error.

Though I'm usually in the second camp, I concede that in this case I'm
seduced by convenience for explicit calls to map.  On the other hand,
I'm not comfortable with extending silent truncation to the implicit
case, e.g. [a,b,c]+[d,e] => [a+d,b+e], which creates a very weird kind
of vector operation where a 3-vector plus a 2-vector is a 2-vector and
ignores the 3rd component of the 3-vector.  True, it allows
rest(list)-list instead of rest(list)-rest(list,-1), which is exactly
parallel to the explicit case above, and I like that convenience, but
it still feels like an abuse of notation. (Yes, this is because Maxima
conflates vectors and lists, but until that changes....)

```

1 Sep 2007 18:14

### Re: Efficient Lisp functions -- using results of symbolic calculations numerically

```> The code generated for h is not so different from the code you
> showed, and it runs just a little bit slower.

Thanks for the clarification, Robert. I didn't know that. So Maxima is already
much better than other computer algebra systems in this respect.

Interfacing to other programs is another topic that seems to be important for
many users if you look at other systems (Mathematica makes a lot of fuss about
MathLink, for example, which is very slow because it involves interprocess
communication and task switches), and it can easily be handled in Maxima by
adding the cffi (or uffi) module to the Lisp installation. As I noticed in my
original mail, Maxima can even be used as a programming library -- impossible
in other systems and being the major goal of the Ginac project:
http://www.ginac.de/ . This could have some implications for the research
topic of partial evaluation (or multi-stage programming) which deals with
making programs more efficient by reoptimizing functions at runtime using
runtime knowledge.

> The Maxima translator has some known bugs, and hasn't received
> much attention lately. Perhaps you would be interested in fixing
> up the translator. That would be useful to many people.

Ok, I'm going to analyze the code. Is there already a collection of unit tests
exposing the known bugs?

Best regards
Bruno Daniel
```
1 Sep 2007 20:02

```Hi,

I'm working with Clisp with Maxima loaded by saved
image.

1. I did'nt find Lisp function for Tex output. Is
there one?

2. Maxima's Tex function give the output as "false"
and the Tex-formatted expression as side-effect, so
tex-formatted-expr: tex(expr);
or, in Lisp:
(setf tex-formatted-expr #\$tex (expr)\$)
not working. What is the way to assign the
tex-formatted expression to Maxima's or Lisp's
variable?

3. Why \$tex function is undefined in Clisp, even
though I can use \$parse_string or \$file_search, for
example?

Thanks for the help in advance and have a good day.

Yigal Asnis

____________________________________________________________________________________
Sick sense of humor? Visit Yahoo! TV's
Comedy with an Edge to see what's on, when.
http://tv.yahoo.com/collections/222
```