|
From: Robert L. <Rob...@t-...> - 2018-10-26 14:46:06
|
Hello,
I debugged a bit with slime to see whats going on.
The issue is this:
in hayat.lisp there is a defun diff-expand
which is coded to do something like this
makelist(diff(expintegral_si(x), x, k)/k!, k, 0, 5);
and then tries to evaluate these coefficients with
at(..., x, 0)
(that's done in defun eval-deriv)
But for expintegral_si()
all the various order diffs look basically like this
trigonometric(x) / x^something
and thus "at" cannot evaluate at zero, zero division.
Now in eval-deriv somebody has introduced a
(catch
which simply returns the expression without evaluating it
if an error happens. The result of doing so is a complete
erroneous expression for the taylor coefficient imho.
I've tried this rough workaround:
diff --git a/src/hayat.lisp b/src/hayat.lisp
index b8455c831..9e1893352 100644
--- a/src/hayat.lisp
+++ b/src/hayat.lisp
@@ -2960,7 +2960,7 @@
(defun eval-deriv (deriv var pt)
(let ((errorsw t))
(declare (special errorsw))
- (let ((ans (catch 'errorsw (meval `(($at) ,deriv ((mequal) ,var ,pt))))))
+ (let ((ans (catch 'errorsw (meval `(($limit) ,deriv ,var ,pt)))))
(if (eq ans t)
deriv
ans))))
which uses limit to evaluate the coefficients at the given point.
The result is then correct.
The mischief was introduced with this commit
commit 5d98db3eb50264d7b3a436a61b24262b47890942
Author: Dan Gildea <dgildea>
Date: Sun Jul 29 09:09:02 2012 -0400
and justifies its doing in a commit to produce a taylor series for
taylor(gamma_incomplete(1/2, x), x, 0, 5)
interesting enough the expected result in the same commit
doesn't look correct anyway.
Regards,
Robert Larice
Richard Fateman <fa...@be...> writes:
> Maxima knows taylor coefs for sin.
> it should generate series for sin(z)/z by dividing term-by-term.
> It should generate expintegral_si by integrating term-by-term,
> the series for sin(x)/z.
>
> So Taylor in this case, and in general, doesn't compute derivatives, as Stavros
> points out.
>
> In fact, computing taylor of sin(z)/z and then integrating, gives the
> right answer. Somewhere the data regarding expintegral_si
> is bungled.
> RJF
>
> On 10/26/2018 6:00 AM, Stavros Macrakis wrote:
>
> On Fri, Oct 26, 2018, 02:00 Robert Dodier <rob...@gm...> wrote:
> ...
>
> Naively I suppose that the whole task is just to compute the derivatives
> and assemble the series; I don't know what else might be going on
>
> Um, no. That's not the way taylor works for known functions.
>
> I haven't looked at the OP's issue.
|