-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
8-fold integral by using quadpy #340
Comments
Alright, so there are basically two approaches:
You can check out any scheme of |
Thank you for your rapid response! I should have said that I am very far from being an Informatiker. I mean I realised that I need to use smth like quadpy.cn in order to evaluate that integral, but the problem I experience is that I do not really understand how my mathematica example can be translated into the quadpy language... I would very much appreciate if you could provide that translation as I have little knowledge about this issue. |
Well, then maybe you need more explanations. What does the function look like in mathematica? Do you need the exact result of the integral or a floating-point approximation? |
Let me then be more concrete. I already played with nquad from scipy by the evaluation of a 6-fold integral with the integrand 1 by running this It is quite okay to me if I have a floating-point approximation. |
What does your function look like? Most importantly: How smooth is it? |
The problem is not in that function, rather I don't understand how to implement |
I'm just trying to find out if quadpy will do any good for you. We can work it out and you'll get some value, but it might not be accurate. It depends on the smoothness of your function. |
I first want to test with this simple example, because what I get up to now with either nested quad or nquad is very unsatisfactory even with that trivial integrand. You know I have a job running in a computer cluster already for ca. 5 days which must return the evaluation of 1 over a 8D cube with the length 1. I can of course compute this without any program. You see that smth is, therefore, deeply wrong with nested quad and nquad in this case. If quadpy can compute this 8D integral with the integrand 1 during a small fraction of a second, then I will insert my integrand, i.e. f(x1,x2,x3,x4,y1,y2,y3,y4), which I actually need to evaluate. This complex function is quite good, but bulky. |
So what about the main example in the readme? https://github.com/nschloe/quadpy/#n-cube-cn |
That's the thing I don't understand from this example how to implement a 8D integral. For instance, I have x and y variables, but there is only "x[0]" in that example. How can this x[0] be related to my variables? |
If you're in 8D, you have |
Ah, I see now! I was thinking that x[0] is not one-dimensional in that example.. You have there also this "quadpy.cn.ncube_points([0.0, 1.0], [0.1, 0.9], [-1.0, 1.0], [-1.0, -0.5])". How should it be in my case? |
I think
|
Thanks a lot! I will try this when I have quadpy installed. [The quadpy package should have been installed over this night on the computer cluster, but don't have it yet..] |
You can always
on any machine and play around with it. |
I have played by now several hours with quadpy which seems to be quite nice. However, I now have this issue sage: import numpy Can you please tell why I have this problem? Apparently, one needs to help numpy here by defining a new sqrt function [for real x]: |
You're trying the take the sqrt of a negative number, hence the error. |
That was ja clear. The problem is apparently overcome if one instead uses numpy.sqrt(x[0]+I*0). I have now another issue: I get an error message if I use mpmath in the definition of my f(x) which I then try to integrate over a 8D cube using quadpy. |
Seems to be a problem in your function, not quadpy. |
Also, it's impossible for me to say anything if all the information I have is "it doens't work". You need to provide a minimal example that displays the issue (MWE). |
Here is the example:
How can this be resolved? |
I don't know why some lines are larger and bold.. |
But if I use numpy, then it works:
|
Please use triple backticks when posting code on GitHub (https://github.github.com/gfm/#fenced-code-blocks). I've edited your posts accordingly. |
To debug, just |
I am not sure that I understand what you mean under "...print some values to see...".
However, the problem is not in this function, rather one has to use numpy in order to take integrals |
If your plan is to use mpmath to get "more precision", then I must disappoint you. Unless your function is a polynomial of low degree, the error in the result does not come from too few digits but from the general approximation error. In principle, quadpy may work with mpmath, but I can't see why one should do that. |
it is because if I use mpmath the above values of f(x[0],..,x[7]) are computed really fast, but if I use numpy, then the evaluation lasts ca. 5 sec. This is even worth than Mathematica in which I was able to reduce the evaluation time to ca. 1 sec. But how could I use mpmath within quadpy? |
I don't know. |
okay, thanks. Do you know how to get rid of this error message:
|
This looks like a wrong definition of the function. I'd be happy to help you further, please contact me privately for rates ([email protected]). |
Closing for lack of feedback. Feel free to reopen at any time! |
Hi Nico,
I accidentally found your project under the name quadpy, as I have been trying to
evaluate an eight-fold integral in sagemath using scipy. However, even for a simple
test integrand, i.e. 1, the computation is very-very slow, while Mathematica does it
over a tiny fraction of a second.
I decided to post this issue, because I don’t understand how to use quadpy
for the 8-fold integral with a scalar integrand, such that each integration variable
runs over a fixed interval, I mean I have smth like this in the Mathematica-language:
NIntegrate[ f[x1,x2,x3,x4,y1,y2,y3,y4] , {x1,-1,1}, {x2,-1,1}, {x3,-1,1}, {x4,-1,1}, {y1,-1,1}, {y2,-1,1}, {y3,-1,1}, {y4,-1,1}]
where f is a complex function.
Could you please explain how this integration can be realized by using quadpy?
The text was updated successfully, but these errors were encountered: