Double-integration and logs
I am running into various odd problems while trying to compute a double integral. My code is as follows:
x, y = var('x y')
##### Two different ways of generating random polynomials F(x,y) to test double-integration ########
#F = ZZ['x','y'].random_element(4, 1000)
F = randint(-1000, 1000)*x**4*y**4 + randint(-1000, 1000)*x**3*y + randint(-1000, 1000)*x**2*y**3 +randint(-1000, 1000)*x + randint(-1000, 1000)*y**2
G = randint(0, 1000)*x**4*y + randint(0, 1000)*x**3 + randint(0, 1000)*x**2*y**2 +randint(0, 1000)*x + randint(0, 1000)*y**4
###### Defining the function we want to integrate over dx dy ##########
f = log(F)
####### Double integration #####
g= integrate(f, x, 1, 2)
print 'after integration dx:', g
assume(y>0)
print n(g.integral(y, 1, 2))
Problems: 1) If I use the random polynomial F generated by .random_element, the integration generates the following error : TypeError: integral() takes exactly one argument (3 given). However, if I use the other one I manually generate, then it integrates okay. If I copy from the terminal the .random_element() polynomial and explicitly write it in my code, then it will also work. Why not directly from the .random_element() function then ?
2) If I set f = F or even f = FG, then the double integral works fine. However, as soon as I introduce the *log function, the calculation never terminates (if I work with an example in the terminal with a log function, then it does integrate properly).
Any idea what might cause these weird bugs ? Thanks!
Let us try to get a random
F
...And now we take the logarithm...
Best, please fix for us some polynomial
F
making sense till the end of the computations, so that we have a common question with a (mathematically) unique answer. Moreover, there is no problem with:Thank you. I tried copying your example and I run into the error :
ValueError: Computation failed since Maxima requested additional constraints; using the 'assume' command before evaluation may help (example of legal syntax is 'assume(y^2-2y+2>0)', see
assume?
for more details) Is y^2-2y+2 positive or negative?This is an example for which the double integration of log(F) never ends: F = -2x^4 - x^2y^2 - 2xy^3 + x^3 + 5x^2y + 5xy^2 + 5y^3 + 2y^2 - 3*x + y - 21
Sorry, yes, in the session with the computation of the integral there was an assume for each of the variables. The comments do not provide to much room for a post:
This makes no problems.
The never ending story is related to a function which is hard to integrate. Note that the logarithm is taken over a function with negative values on a subdomain of $[0,1]^2$. For instance:
Which is then the meaning of $\log f$ ?
Even if we know to get a branch of the logarithm and consider a corresponding complex valued function $\log f:[1,2]^2\to\mathbb C$, the first integral (w.r.t. the variable $x$) explicitly asks for an exact value (and the interpreter does not look further to see that we need only a numerical value). This value is "hard to compute" in general.