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

Taylor polynomial in two variables does not work #7472

Closed
robert-marik mannequin opened this issue Nov 16, 2009 · 24 comments
Closed

Taylor polynomial in two variables does not work #7472

robert-marik mannequin opened this issue Nov 16, 2009 · 24 comments

Comments

@robert-marik
Copy link
Mannequin

robert-marik mannequin commented Nov 16, 2009

make

taylor(x*y^3,[x,y],[1,-1],4)

work

Component: calculus

Keywords: taylor polynomial, derivative

Author: Robert Mařík

Reviewer: Karl-Dieter Crisman

Merged: sage-4.3.1.rc1

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

@robert-marik robert-marik mannequin added c: calculus labels Nov 16, 2009
@robert-marik robert-marik mannequin assigned burcin Nov 16, 2009
@robert-marik
Copy link
Mannequin Author

robert-marik mannequin commented Nov 16, 2009

comment:1

I hope it has been fixed by the attached patch.

@robert-marik robert-marik mannequin added the s: needs review label Nov 16, 2009
@robert-marik
Copy link
Mannequin Author

robert-marik mannequin commented Nov 16, 2009

Attachment: trac-7472-taylor.patch.gz

@robert-marik
Copy link
Mannequin Author

robert-marik mannequin commented Nov 16, 2009

this patch should be installed on the top of previous patch and improves documentation

@robert-marik
Copy link
Mannequin Author

robert-marik mannequin commented Nov 16, 2009

comment:2

Attachment: trac-7472-taylor-fixed_doc.patch.gz

@robert-marik

This comment has been minimized.

@kcrisman
Copy link
Member

comment:3

I'm waiting for a build of 4.2.1... but in the meantime, is the new syntax (list for variables, list for numbers) more or less equivalent to other Sage functionality, or Mathematica/Maple syntax? I honestly don't know, just asking. It would be good to have compatibility, though. For instance, plotting has the variable and range together (x,-5,5), so maybe [x,4] and [y,1] would be more appropriate? Looks like Mma allows for different "distance" for different variables, see here... Just thinking out loud here.

@robert-marik
Copy link
Mannequin Author

robert-marik mannequin commented Nov 16, 2009

comment:4

Replying to @kcrisman:

I'm waiting for a build of 4.2.1... but in the meantime, is the new syntax (list for variables, list for numbers) more or less equivalent to other Sage functionality, or Mathematica/Maple syntax? I honestly don't know, just asking. It would be good to have compatibility, though. For instance, plotting has the variable and range together (x,-5,5), so maybe [x,4] and [y,1] would be more appropriate? Looks like Mma allows for different "distance" for different variables, see here... Just thinking out loud here.

Can be done easily, the expression is passed to Maxima and Maxima allows many possibilities how to use taylor command. I wanted to do as minotr change as possible. I was thinking for example also on the possibility to use different order for different variable, but I do not know if there is a demand for this.

I do not know to much about habits in Sage notation, but I think that we evaluate expansion about point in n-dimensional space, so the coordinates should be together.

@burcin
Copy link

burcin commented Nov 23, 2009

Reviewer: Karl-Dieter Crisman

@burcin
Copy link

burcin commented Nov 23, 2009

comment:5

FWIW, I also like the MMA notation better. It is more consistent with the interface to integrate, plot, etc. as kcrisman mentioned.

@burcin
Copy link

burcin commented Nov 23, 2009

Author: Robert Marik

@burcin burcin added this to the sage-4.3 milestone Nov 23, 2009
@robert-marik
Copy link
Mannequin Author

robert-marik mannequin commented Nov 23, 2009

comment:6

OK. what about this, is it acceptable?

sage: y=var('y');taylor(sin(x)*exp(y),(x,y),(0,1),4)
1/6*(y - 1)^3*x*e - 1/6*(y - 1)*x^3*e + 1/2*(y - 1)^2*x*e - 1/6*x^3*e + (y - 1)*x*e + x*e
sage: y=var('y');taylor(sin(x)*exp(y),(x,0,4),(y,1,4))
-1/144*((y - 1)^4*e + 4*(y - 1)^3*e + 12*(y - 1)^2*e + 24*(y - 1)*e + 24*e)*x^3 + 1/24*((y - 1)^4*e + 4*(y - 1)^3*e + 12*(y - 1)^2*e + 24*(y - 1)*e + 24*e)*x
sage: y=var('y');taylor(sin(x)*exp(y),x,0,4)
-1/6*x^3*e^y + x*e^y
sage: y=var('y');taylor(sin(x)*exp(y),(x,0,4))
-1/6*x^3*e^y + x*e^y

Note that in the first example the degree of polynomial is 4 and in the second example the degree of polynomial is 7.
(Not yet documented in the experimental patch)

@robert-marik
Copy link
Mannequin Author

robert-marik mannequin commented Nov 23, 2009

apply on the top of the two other patches

@robert-marik
Copy link
Mannequin Author

robert-marik mannequin commented Nov 23, 2009

comment:7

Attachment: trac-7472-taylor-experimental.patch.gz

@robert-marik
Copy link
Mannequin Author

robert-marik mannequin commented Nov 23, 2009

comment:8

btw: it seems that taylor command in Maxima may return not only Taylor polynomial as in calculus books, but also truncated power expansion truncated at given power. I think that this could be something different from Taylor polynomial, so the name of the command is misleading. How is it in Mathematica and Maple? What should be in Sage?

@robert-marik
Copy link
Mannequin Author

robert-marik mannequin commented Jan 5, 2010

New patch, replaces all previous patches. Notation is more Sage like.

@robert-marik
Copy link
Mannequin Author

robert-marik mannequin commented Jan 5, 2010

comment:9

Attachment: trac-7472.patch.gz

@kcrisman
Copy link
Member

comment:10

I assume the idea of different degrees for different variables was lost? That really doesn't matter to me, though.

What about this one, from the documentation?

sage: x,y=var('x y'); taylor(x*y^3,(x,1),(y,-1),4)  
(y + 1)^3*(x - 1) + (y + 1)^3 - 3*(y + 1)^2*(x - 1) - 3*(y + 1)^2 + 3*(y + 1)*(x - 1) - x + 3*y + 3 

Why doesn't it end this way?

-(x-1)+3*(y+1) -1

Maybe this is documented in Maxima? It does seem odd, though, if I'm understanding what a multivariable Taylor polynomial is supposed to look like.

But overall this looks fine, assuming the Maxima computations are correct. I am waiting for 4.3.alpha2 to build to see if there needs to be a rebase, but surely it would be trivial if so.

@robert-marik
Copy link
Mannequin Author

robert-marik mannequin commented Jan 13, 2010

comment:11

Replying to @kcrisman:

I assume the idea of different degrees for different variables was lost? That really doesn't matter to me, though.

Yes, different degrees for different variables seem odd to me (from the point of view of pure caculcus) and I do not know, if there is a demand to keep this functionality.

What about this one, from the documentation?

sage: x,y=var('x y'); taylor(x*y^3,(x,1),(y,-1),4)  
(y + 1)^3*(x - 1) + (y + 1)^3 - 3*(y + 1)^2*(x - 1) - 3*(y + 1)^2 + 3*(y + 1)*(x - 1) - x + 3*y + 3 

Why doesn't it end this way?

-(x-1)+3*(y+1) -1

Maybe this is documented in Maxima? It does seem odd, though, if I'm understanding what a multivariable Taylor polynomial is supposed to look like.

Very good question :). Maxima in fact returns

-(x-1)+3*(y+1) -1

and Sage changes it somehow into

-x+3y+.... 

I do not know why, perhaps I should ask on sage-devel. The same problem is also in current Sage. The linear Taylor polynomial hal always slope intercept form f'(a)x+q, but should be (and Maxima returns) point slope form f'(a)(x-a)+f(a)

----------------------------------------------------------------------
| Sage Version 4.3, Release Date: 2009-12-24                         |
| Type notebook() for the GUI, and license() for information.        |
----------------------------------------------------------------------
sage: maxima("taylor(x^3,x,2,1)")
8+12*(x-2)
sage: maxima("taylor(x^3,x,2,1)").sage()
12*x - 16
sage: taylor(x^3,x,2,1)
12*x - 16
sage:

But overall this looks fine, assuming the Maxima computations are correct. I am waiting for 4.3.alpha2 to build to see if there needs to be a rebase, but surely it would be trivial if so.

@robert-marik
Copy link
Mannequin Author

robert-marik mannequin commented Jan 13, 2010

comment:12

Replying to @robert-marik:

I do not know why, perhaps I should ask on sage-devel.

The question at sage-devel.

@kcrisman
Copy link
Member

comment:13

I have made some trivial changes. The new thing is a bug in some ways, but shouldn't keep us from merging this valuable functionality.

@kcrisman
Copy link
Member

Apply only this.

@rlmill
Copy link
Mannequin

rlmill mannequin commented Jan 18, 2010

Merged: sage-4.3.1.rc1

@rlmill
Copy link
Mannequin

rlmill mannequin commented Jan 18, 2010

comment:14

Attachment: trac-7472-review.patch.gz

@rlmill rlmill mannequin removed the s: positive review label Jan 18, 2010
@rlmill rlmill mannequin closed this as completed Jan 18, 2010
@fchapoton
Copy link
Contributor

Changed author from Robert Marik to Robert Mařík

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

3 participants