Re: Bug in the integrate.



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Well, this is a patch to the patch.

I run too fast to send the previous one. It worked with
integrate(3^log(x), x);
but it failed with
integrate(5 * 3^log(x), x);

So, please, forget my previous post. Here you are the good version:
< (DEFMFUN $INTEGRATE NARGS
<   (LET ($RATFAC)
<     (COND ((= NARGS 2)
<          (WITH-NEW-CONTEXT (CONTEXT)
<            (IF (MEMQ '%RISCH NOUNL) (RISCHINT (ARG 1) (ARG 2))
<                                     (SININT (ARG 1) (ARG 2)))))
<         ((= NARGS 4) ($DEFINT (ARG 1) (ARG 2) (ARG 3) (ARG 4)))
<         (T (WNA-ERR '$INTEGRATE)))))
- ---
> (defmfun $integrate nargs
>   (let ($ratfac)
>     (cond ((= nargs 2)
>          (with-new-context (context)
>              (let ((arg_1 (arg 1)))
>                (if (and (not (atom arg_1))
>                         (or (memq '%risch nounl)
>                             (search-base-exponent arg_1)))
>                    (rischint arg_1 (arg 2))
>                    (sinint arg_1 (arg 2))))))
>           ((= nargs 4) ($defint (arg 1) (arg 2) (arg 3) (arg 4)))
>         (t (wna-err '$integrate)))))
>
> (defun search-base-exponent (list-args &aux (exp-base '$%E))
>   (cond ((atom list-args)
>          nil)
>         ((atom (first list-args))
>          (search-base-exponent (rest list-args)))
>         ((eq (first (first list-args)) 'MEXPT)
>          ;; We are looking for something like ((MEXPT *) ** ...) with **,
>          ;; the base of the exponential, different from $%E.
>          (if (eq (first (rest list-args)) exp-base)
>              (search-base-exponent (rest (rest list-args)))
>              t))
>         (t
>          (or (search-base-exponent (first list-args))
>              (search-base-exponent (rest list-args))))))
>
>
The only change has been that, previously, one got nil with either (atom list)
or (atom (first list)) because in such situations one may be sintactically 
sure that there is no ((MEXPT *) ** ....) structure. However in the second 
situacion, one must continue digging into the structure (with (cdr list)), 
just in case the pattern we are looking for is deeper.
- -- 
Juan Pablo Hierro Álvarez
hierro en ideafix punto litec punto csic punto es
Clave pública: 0xA8707ADF en pgp.rediris.es 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE8uvFmd1aMoahwet8RAurXAJ9sRuoH4TFOsK0p3KUDJjwLQ/669wCfVK36
qDrm/HTO21Gjw9ReEvuY93Y=
=fG2l
-----END PGP SIGNATURE-----