67 views

Skip to first unread message

Feb 3, 2012, 5:10:07 PM2/3/12

to sage-devel

Hello,

It is a known bug? Or maybe not considered a bug at all? Quick search

does not show anything related...

sage: f(x) = x

sage: f

x |--> x

sage: integral(f, x)

x |--> 1/2*x^2

sage: integral(f, x, 0, 1)

x |--> 1/2

The last line shows 1/2 as a function of x, but it is not a function

anymore, it is a number. It gets worse with multivariate functions:

sage: f(x, y) = x + y

sage: f

(x, y) |--> x + y

sage: integral(f, x, 0, 1)

(x, y) |--> y + 1/2

sage: _(3)

y + 1/2

I think that here integral definitely should return a function of y

only and if I evaluate it at 3 I get 3.5.

Best regards,

Andrey

It is a known bug? Or maybe not considered a bug at all? Quick search

does not show anything related...

sage: f(x) = x

sage: f

x |--> x

sage: integral(f, x)

x |--> 1/2*x^2

sage: integral(f, x, 0, 1)

x |--> 1/2

The last line shows 1/2 as a function of x, but it is not a function

anymore, it is a number. It gets worse with multivariate functions:

sage: f(x, y) = x + y

sage: f

(x, y) |--> x + y

sage: integral(f, x, 0, 1)

(x, y) |--> y + 1/2

sage: _(3)

y + 1/2

I think that here integral definitely should return a function of y

only and if I evaluate it at 3 I get 3.5.

Best regards,

Andrey

Feb 3, 2012, 6:04:32 PM2/3/12

to sage-devel

On Feb 3, 5:10 pm, Andrey Novoseltsev <novos...@gmail.com> wrote:

> Hello,

>

> It is a known bug? Or maybe not considered a bug at all? Quick search

> does not show anything related...

>

> sage: f(x) = x

> sage: f

> x |--> x

> sage: integral(f, x)

> x |--> 1/2*x^2

> sage: integral(f, x, 0, 1)

> x |--> 1/2

>

> The last line shows 1/2 as a function of x, but it is not a function

> anymore,

in terms of the logic of callable versus not-callable symbolic

expressions).

>

> sage: f(x, y) = x + y

> sage: f

> (x, y) |--> x + y

> sage: integral(f, x, 0, 1)

> (x, y) |--> y + 1/2

> sage: _(3)

> y + 1/2

>

> I think that here integral definitely should return a function of y

> only and if I evaluate it at 3 I get 3.5.

error, folks?

sage: h(x,y) = x+y

sage: h(3)

y + 3

??? I thought the whole *point* of the h(x,y) notation was to specify

the order - but then you'd figure it would also specify the number of

entries. I guess this is a shorthand, perhaps, but then I don't know

how to get just h(,3) (which is naturally an error), which you'd want

by symmetry. I guess h(x,3) works, but then we should (perhaps?)

require h(3,y) as well?

- kcrisman

Feb 4, 2012, 6:31:59 AM2/4/12

to sage-...@googlegroups.com

I believe this is more or less consistent behavior throughout Sage. For example:

sage: derivative(x, x)

1

sage: type(derivative(x, x))

<type 'sage.symbolic.expression.Expression'>

1

sage: type(derivative(x, x))

<type 'sage.symbolic.expression.Expression'>

Feb 4, 2012, 6:36:40 AM2/4/12

to sage-...@googlegroups.com

On Saturday, February 4, 2012 7:04:32 AM UTC+8, kcrisman wrote:

This might be a different problem. Shouldn't this give a syntax

error, folks?

sage: h(x,y) = x+y

sage: h(3)

y + 3

??? I thought the whole *point* of the h(x,y) notation was to specify

the order - but then you'd figure it would also specify the number of

entries. I guess this is a shorthand, perhaps, but then I don't know

how to get just h(,3) (which is naturally an error), which you'd want

by symmetry. I guess h(x,3) works, but then we should (perhaps?)

require h(3,y) as well?

- kcrisman

I think h(3) should give syntax error. It doesn't make sense mathematically, and otherwise, it is ambiguous.

Feb 4, 2012, 10:43:44 AM2/4/12

to sage-devel

on x. If it happens to be a constant or some expression with

parameters not depending on x explicitly - it is a coincidence. Same

for indefinite integrals.

But in definite integrals the variable of integration is a dummy one

and does not exist out of the integral!

Feb 4, 2012, 12:24:00 PM2/4/12

to sage-...@googlegroups.com

On Saturday, February 4, 2012 11:43:44 PM UTC+8, Andrey Novoseltsev wrote:

But in definite integrals the variable of integration is a dummy one

and does not exist out of the integral!

Feb 4, 2012, 1:21:57 PM2/4/12

to sage-...@googlegroups.com

On 2/4/12 11:24 AM, Keshav Kini wrote:

> On Saturday, February 4, 2012 11:43:44 PM UTC+8, Andrey Novoseltsev wrote:

>

> But in definite integrals the variable of integration is a dummy one

> and does not exist out of the integral!

>

>

> +1. This behavior makes no sense to me.

> On Saturday, February 4, 2012 11:43:44 PM UTC+8, Andrey Novoseltsev wrote:

>

> But in definite integrals the variable of integration is a dummy one

> and does not exist out of the integral!

>

>

> +1. This behavior makes no sense to me.

So what happens in a case like this?

sage: f(x,y,z)=sin(x*y*z)

sage: integrate(f,(y,0,3))

Does the result become a function

(x,z) |--> whatever?

I can see it making sense, but I can also see it causing problems.

Thanks,

Jason

Feb 4, 2012, 1:26:04 PM2/4/12

to sage-devel

variables which are named and have a particular order. If one of them

is gone, the rest keeps both their names and the same ordering.

Feb 4, 2012, 1:30:12 PM2/4/12

to sage-...@googlegroups.com

I was thinking of confusion for the user, because the user has to be

more careful about how they call the function because the arguments

change. Now, this can be alleviated by the user using keyword

arguments, or paying attention and being aware of integration removing a

variable. Again, I don't think this is insurmountable, and arguably

it's desirable to make the user think about how the function domain is

changing, but I feel obligated to bring up the issue as a point against

changing things in a backwards-incompatible way.

Thanks,

Jason

Feb 4, 2012, 1:50:08 PM2/4/12

to sage-devel

On Feb 4, 11:30 am, Jason Grout <jason-s...@creativetrax.com> wrote:

> I was thinking of confusion for the user, because the user has to be

> more careful about how they call the function because the arguments

> change. Now, this can be alleviated by the user using keyword

> arguments, or paying attention and being aware of integration removing a

> variable. Again, I don't think this is insurmountable, and arguably

> it's desirable to make the user think about how the function domain is

> changing, but I feel obligated to bring up the issue as a point against

> changing things in a backwards-incompatible way.

>

> Thanks,

>

> Jason

I think it is much more confusing to supply an extra argument (whose
> I was thinking of confusion for the user, because the user has to be

> more careful about how they call the function because the arguments

> change. Now, this can be alleviated by the user using keyword

> arguments, or paying attention and being aware of integration removing a

> variable. Again, I don't think this is insurmountable, and arguably

> it's desirable to make the user think about how the function domain is

> changing, but I feel obligated to bring up the issue as a point against

> changing things in a backwards-incompatible way.

>

> Thanks,

>

> Jason

value does not matter at all!) then to think about change in the

domain. From a mathematical viewpoint it seems unambiguous to me that

the current behaviour is wrong and should be changed, and so far there

were no implementation reasons for keeping it. If dropping a variable

and allowing unnamed evaluation is confusing, it may not be allowed as

well, but I personally think that it is quite desirable.

I hit it while preparing for my multivariate calculus class where I

teach students that taking a function f(x,y) over some region R and

integrating it in y from g(x) to h(x) gives the area of the cross-

section A(x). If we integrate it in x from u(y) to v(y), we get a

perpendicular cross-section B(y). If we now integrate one more time,

we get a number V - the volume under the graph. Sage output suggest

that we are still getting functions of (x,y) - still over R or what is

its new domain?.. Why would any user try to evaluate, say, V(2,1) and

what would be the expected result? Would this user expect V(3,42)

return the same value? If yes, how about just using V with no

arguments? If no - the user does not seem to understand what is going

on. Raising an error for an attempt to evaluate V(2,1) can be a very

useful cue in this case.

So - I propose opening a ticket to fix this.

Thank you,

Andrey

Feb 4, 2012, 1:53:21 PM2/4/12

to sage-...@googlegroups.com

I think you have a pretty convincing argument for changing this. +1 to

opening the ticket and changing it.

Jason

Feb 4, 2012, 2:04:13 PM2/4/12

to sage-devel

Reply all

Reply to author

Forward

0 new messages

Search

Clear search

Close search

Google apps

Main menu