I have a problem in using SymPy and QuadGK packages as follows:
In a double integral, the inner integration has lower limit is x where x is the variable of the outer integral. Here is my code
using SymPy
@syms y
f(z) = integrate(2*z*cos(y+z)/(1+y^2),(y,z,10))^2
t1 = integrate(f,0,1)
t1.evalf() # failed
# I also tried with QuadGK
using QuadGK
t2 = quadgk(f,0,1) # also failed
How could I obtain numerical value of this double integral.
Sorry for my late reply. The function here is just an example. In my own problem, the function f(z) is more complicated that I am not sure to have analytical form of t1. Anyway, I would like to have both analytical and numerical value of this example problem. Thank you @Irnv
Sorry for my late reply. I would like to have the answer both symbolically and numerically. In case there is no symbolic solution, I would like to have it numerically. Thank you @stevengj
In this case (likely for more complicated integrands), you shouldn’t use Symbolics at all. Either use nested calls to QuadGK or use a multi-dimensional integration package like HCubature.
By “failed”, I meant that no analytical nor numerical solution is found. But from suggestion of @stevengj, I could have numerical value of this double integral by using nested quadgk.