Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement at for symbolics #385

Closed
williamstein opened this issue Jun 7, 2007 · 9 comments
Closed

implement at for symbolics #385

williamstein opened this issue Jun 7, 2007 · 9 comments

Comments

@williamstein
Copy link
Contributor

On 6/7/07, Randy LeVeque <rjl@amath.washington.edu> wrote:
> By the way, I'm just trying to figure out how sage does Taylor series.
> Maybe you can pass this on to whoever the best person is to chat with about
> this...
> 
> In maple I can do things like
> 
> > mtaylor(u(x+h,t+k),[h,k],3);
>                                                                      2
> u(x, t) + D[1](u)(x, t) h + D[2](u)(x, t) k + 1/2 D[1, 1](u)(x, t) h
> 
>                                                      2
>       + h D[1, 2](u)(x, t) k + 1/2 D[2, 2](u)(x, t) k
> 
> 
> which is very convenient for numerical analysis when computing truncation
> errors of finite difference methods (h and k are mesh widths in space and
> time).  In sage a general expansion of this sort doesn't seem possible even
> in a single variable, e.g.,
> 
> sage: taylor(u(x+h),h,0,4)
> x + h
> 
> Apparently an undefined function like u(x) is taken to be the identity map?

To define a formal function, do u = function('u').  Then

sage: u = function('u')
sage: u(x + h)
u(x + h)
sage: diff(u(x+h), x)
diff(u(x + h), x, 1)

To get the Taylor expansion you would do this:

sage: taylor(u(x+h),h,0,4)

-- however -- this currently doesn't work in SAGE since we hadn't considered
doing this yet.   What happens is Maxima does the computation and outputs
the following expression:

'u(x)+(?%at('diff('u(x+h),h,1),h=0))*h+(?%at('diff('u(x+h),h,2),h=0))*h^2/2+(?%at('diff('u(x+h),h,3),h=0))*h^3/6+(?%at('diff('u(x+h),h,4),h=0))*h^4/24

SAGE doesn't know yet how to parse the "at" function, so you get
an error -- it will have to be added.   [Note that I don't necessarily consider
maxima the ultimate underlying engine for SAGE's symbolic computation
capabilities -- but it does provide a very quick way for SAGE to have
a powerful symbolic system for which a lot of subtle bugs have
already been fixed (over the last 40 years of Maxima development). ]

Definitely point out lots of things like this in your talk at SD4!

 -- William

CC: @jasongrout @burcin @williamstein @mwhansen

Component: calculus

Author: Karl-Dieter Crisman

Reviewer: David Joyner

Merged: sage-4.2.1.alpha0

Issue created by migration from https://trac.sagemath.org/ticket/385

@williamstein williamstein self-assigned this Jun 7, 2007
@sagetrac-mabshoff sagetrac-mabshoff mannequin added this to the sage-2.9.1 milestone Sep 10, 2007
@garyfurnish garyfurnish mannequin assigned garyfurnish and unassigned williamstein Mar 16, 2008
@kcrisman
Copy link
Member

comment:4

This would also resolve #3914.

@kcrisman
Copy link
Member

kcrisman commented Oct 9, 2009

Author: Karl-Dieter Crisman

@kcrisman
Copy link
Member

kcrisman commented Oct 9, 2009

comment:5

Try this patch. It should do the trick. Notice that I do not make it a normal symbolic function like in functions/other.py or something, because it's only for use here for now. If necessary, I could do that, though - it's a nice second way to do things instead of .subs(), so I could also import it globally if appropriate. I put in doctests for this, #3914, and a direct call.

@robert-marik
Copy link
Mannequin

robert-marik mannequin commented Oct 10, 2009

comment:6

Attachment 'trac_385-at-evaluate.patch' not found :(

@kcrisman
Copy link
Member

Based on 4.1.2.alpha4

@kcrisman
Copy link
Member

comment:7

Attachment: trac_385-at-evaluate.patch.gz

Replying to @robert-marik:

Attachment 'trac_385-at-evaluate.patch' not found :(

It must have gotten lost somewhere during the latest Trac outage. This should work now.

@wdjoyner
Copy link

comment:8

Passes sage -testall and does what it claims. Adds some very very useful functionality.

@mwhansen
Copy link
Contributor

Reviewer: David Joyner

@mwhansen
Copy link
Contributor

Merged: sage-4.2.1.alpha0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants