On Monday, May 21, 2012 11:08:02 PM UTC+8, Santanu wrote: > > When I use the following code it returns 0. > > var('x y') > def f1(x,y): > if(x+y < 5): > return x+y > else: > return 0 > > integral(integral(f1(x,y), x, 0,1), y, 0, 1) > > > > whereas > > > integral(integral(x+y, x, 0,1), y, 0, 1) > > returns 1. > > Can any one point out the reason for this discrepancy and how to solve it?
I suspect it happens because the inner integral is evaluated first, with a *symbolic variable* y. Then, the condition c+y < 5 always fails for any value c that is input as x to f1(x,y). So, the inner integral always evaluates to 0, and then the outer integral too evaluates to 0. Unfortunately, I don't know any workarounds to this. -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org