Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

monte_carlo_integral using already defined variable

hello, i have some function that i already defined, and i want to do monte carlo integral on in:

a,b,c = var('a,b,c')
c = 1
f = c*a*b
monte_carlo_integral(lambda a,b: f, [0,0], [3,3], 1000)

but i get many errors like "unable to simplify to float approximation". i understand that when using the lambda its different a,b than my previous a,b. and that this works:

a,b,c = var('a,b,c')
c = 1
monte_carlo_integral(lambda a,b: c*a*b, [0,0], [3,3], 1000)

but i have many calculations on f before doing the integral, so is there any way to make it work?