|
View:
New views
20 Messages
—
Rating Filter:
Alert me
|
|
|
Numerical IntegrationI'm a beginner on using the Octave. I've a problem with numerical integration of such a function:
\int_0^1 dt \frac{1}{t^{3/2}}\exp[-iR(t)]\frac{1}{(1+R^2(t))^2} where R(t)=\int_0^t dx e^{-x^2}\sin(at+b) (tex code) I've no idea how to integrate this. Every help will be usefull. Thanks for help |
|
|
Re: Numerical IntegrationOn Sat, Dec 6, 2008 at 6:26 PM, Marcin Ślęczka <marcin.sleczka@...> wrote:
> > I'm a beginner on using the Octave. I've a problem with numerical integration > of such a function: > \int_0^1 dt \frac{1}{t^{3/2}}\exp[-iR(t)]\frac{1}{(1+R^2(t))^2} where > R(t)=\int_0^t dx e^{-x^2}\sin(at+b) (tex code) > I've no idea how to integrate this. Every help will be usefull. > Thanks for help Hi You can integrate univariate function with 'quad' command. You need to define function under integral (e.g. by programming it in separate m-file), see 'help quad' for details. Looking at your function, R(t) seems to be a multiply of error function which is available directly in Octave (see 'help erf'), so you don't have to compute the second integral. Regards Ivan Sutoris _______________________________________________ Help-octave mailing list Help-octave@... https://www-old.cae.wisc.edu/mailman/listinfo/help-octave |
|
|
Re: Numerical IntegrationHi Marcin,
ah ah ah ..... good problem ! :D .... The problem is in the integration of R(t)=\int_0^t dx e^{-x^2}\sin(at+b) , becouse you said "How can integrate a integral function ?" Bha !? I think .... that you can solve the problem of variable extrem whith the Characteristic function in fact the integral: R(t)=\int_0^t dx e^{-x^2}\sin(at+b) = \int_0^{+\infty} e^{-x^2}\sin(at +b) \cdot \chi_{[0,x]}(x) dx at this point i don't know if this integral can be approximate easly whit the tipical integration code. Try and tell how can you find a better method. Cheers Stefano Mandelli On sab, 2008-12-06 at 09:26 -0800, Marcin Ślęczka wrote: > I'm a beginner on using the Octave. I've a problem with numerical integration > of such a function: > \int_0^1 dt \frac{1}{t^{3/2}}\exp[-iR(t)]\frac{1}{(1+R^2(t))^2} where > R(t)=\int_0^t dx e^{-x^2}\sin(at+b) (tex code) > I've no idea how to integrate this. Every help will be usefull. > Thanks for help _______________________________________________ Help-octave mailing list Help-octave@... https://www-old.cae.wisc.edu/mailman/listinfo/help-octave |
|
|
Re: Numerical IntegrationThanks a lot.
What if the second functiont won't be an error function? |
|
|
Re: Numerical IntegrationOn Sat, Dec 6, 2008 at 8:42 PM, Marcin Ślęczka <marcin.sleczka@...> wrote:
> > Thanks a lot. > > What if the second functiont won't be an error function? I thought you could just call quad recursively, but apparently that is not possible (it results in error). However, there is example for 2D integration in Octave manual using quadl, which allows recursion: http://www.gnu.org/software/octave/doc/interpreter/Functions-of-Multiple-Variables.html#Functions-of-Multiple-Variables Regards Ivan Sutoris _______________________________________________ Help-octave mailing list Help-octave@... https://www-old.cae.wisc.edu/mailman/listinfo/help-octave |
|
|
Re: Numerical Integrationsøn, 07 12 2008 kl. 11:26 +0100, skrev Ivan Sutoris:
> On Sat, Dec 6, 2008 at 8:42 PM, Marcin Ślęczka <marcin.sleczka@...> wrote: > > > > Thanks a lot. > > > > What if the second functiont won't be an error function? > > I thought you could just call quad recursively, but apparently that is > not possible (it results in error). However, there is example for 2D > integration in Octave manual using quadl, which allows recursion: > http://www.gnu.org/software/octave/doc/interpreter/Functions-of-Multiple-Variables.html#Functions-of-Multiple-Variables > Yeah, 'quad' uses 'QUADPACK' which is a Fortran library for numerical integration. Apparently you cannot call Fortran routines recursively, so 'quad' inherits this limitation. I guess it would make sense to rewrite this code in C++ if anybody feel like helping out :-) Søren _______________________________________________ Help-octave mailing list Help-octave@... https://www-old.cae.wisc.edu/mailman/listinfo/help-octave |
|
|
Re: Numerical IntegrationOn Sun, Dec 7, 2008 at 11:50 AM, Søren Hauberg <soren@...> wrote:
> søn, 07 12 2008 kl. 11:26 +0100, skrev Ivan Sutoris: >> On Sat, Dec 6, 2008 at 8:42 PM, Marcin Ślęczka <marcin.sleczka@...> wrote: >> > >> > Thanks a lot. >> > >> > What if the second functiont won't be an error function? >> >> I thought you could just call quad recursively, but apparently that is >> not possible (it results in error). However, there is example for 2D >> integration in Octave manual using quadl, which allows recursion: >> http://www.gnu.org/software/octave/doc/interpreter/Functions-of-Multiple-Variables.html#Functions-of-Multiple-Variables >> > > Yeah, 'quad' uses 'QUADPACK' which is a Fortran library for numerical > integration. Apparently you cannot call Fortran routines recursively, so > 'quad' inherits this limitation. I guess it would make sense to rewrite > this code in C++ if anybody feel like helping out :-) > With more modern Fortran compilers, recursion is no problem (just declaring the procedure RECURSIVE). A lot of problems with the Fortran sources could go away if we resigned on compatibility with the ancient f2c and g77. The principal obstacle to doing so is that for building with MSVC on Windows, no suitable Fortran 90 compiler is freely available. It doesn't seem acceptable to require users that want to build themselves with MSVC to also purchase Intel Visual Fortran or similar product (we could get money together to buy our regular Windows builders a license, so that binaries would still be available). IMHO, there are at least 2 advantages to Fortran over C++: 1. Speed of array access due to aliasing problems of pointers. In C, most of these can be solved using restricted pointers in C99, but in C++ there are no restricted pointers so far. 2. Compiling Fortran in very fast compared to compiling C++. On any system I tried, libcruft is usually compiled in a flash. > Søren > > _______________________________________________ > Help-octave mailing list > Help-octave@... > https://www-old.cae.wisc.edu/mailman/listinfo/help-octave > -- RNDr. Jaroslav Hajek computing expert Aeronautical Research and Test Institute (VZLU) Prague, Czech Republic url: www.highegg.matfyz.cz _______________________________________________ Help-octave mailing list Help-octave@... https://www-old.cae.wisc.edu/mailman/listinfo/help-octave |
|
|
Re: Numerical Integrationsøn, 07 12 2008 kl. 12:38 +0100, skrev Jaroslav Hajek:
> With more modern Fortran compilers, recursion is no problem (just > declaring the procedure RECURSIVE). A lot of problems with the Fortran > sources could go away if we resigned on compatibility with the ancient > f2c and g77. Could we just check if it is possible to make a procedure RECURSIVE during compilation? If it is possible, we could let 'quad' work recursively, and if not we could fall back to the current situation. Or perhaps it would be a bad thing if some code worked on some platforms but not on others? > The principal obstacle to doing so is that for building with MSVC on > Windows, no suitable Fortran 90 compiler is freely available. It > doesn't seem acceptable to require users that want to build themselves > with MSVC to also purchase Intel Visual Fortran or similar product (we > could get money together to buy our regular Windows builders a > license, so that binaries would still be available). Perhaps Intel could be persuaded to donate a few licenses to their compilers? What about mingw -- does that come with a fortran compiler? Søren _______________________________________________ Help-octave mailing list Help-octave@... https://www-old.cae.wisc.edu/mailman/listinfo/help-octave |
|
|
Re: Numerical IntegrationOn Sun, Dec 7, 2008 at 1:21 PM, Søren Hauberg <soren@...> wrote:
> søn, 07 12 2008 kl. 12:38 +0100, skrev Jaroslav Hajek: >> With more modern Fortran compilers, recursion is no problem (just >> declaring the procedure RECURSIVE). A lot of problems with the Fortran >> sources could go away if we resigned on compatibility with the ancient >> f2c and g77. > > Could we just check if it is possible to make a procedure RECURSIVE > during compilation? That's a good suggestion. A problem with this is that there is no standard preprocessor for Fortran, so we would need to preprocess the sources externally from a Makefile, using sed or some other tool. But in principle, it's doable. > If it is possible, we could let 'quad' work > recursively, and if not we could fall back to the current situation. Or > perhaps it would be a bad thing if some code worked on some platforms > but not on others? > >> The principal obstacle to doing so is that for building with MSVC on >> Windows, no suitable Fortran 90 compiler is freely available. It >> doesn't seem acceptable to require users that want to build themselves >> with MSVC to also purchase Intel Visual Fortran or similar product (we >> could get money together to buy our regular Windows builders a >> license, so that binaries would still be available). > > Perhaps Intel could be persuaded to donate a few licenses to their > compilers? What about mingw -- does that come with a fortran compiler? > I bet it could, especially if that meant that people wanting to build Octave on Windows using Visual Studio would have increased interest in purchasing Visual Fortran. However, those people would find a new obstacle in the process with no free alternative, and that could mean a loss of users for Octave. As for mingw, I suggested that to Michael Goffioul some time ago, but he explained that the problem is that the runtime libraries are incompatible in some way - I don't remember the details. I'm not sure how many people actually do build Octave with MSVC - my impression is that Windows users are far more accustomed to downloading binaries. I think you can still get MSVC++ free for personal use. The only MSVC-compatible windows Fortran compiler I know that can also be obtained for free is Salford Fortran 95: <http://www.silverfrost.com/32/ftn95/ftn95_personal_edition.asp> This would actually be an excellent choice (provided that you can live with the start-up banner displaying in the personal edition, and I'm not even sure it pops up from a shared library), but I think that the license is more restrictive than those of Visual Studiou Express, perhaps disallowing selling the binaries. But I may be wrong. If anyone would find the time to investigate this (perhaps ask Salford directly), that would be great. > Søren > > -- RNDr. Jaroslav Hajek computing expert Aeronautical Research and Test Institute (VZLU) Prague, Czech Republic url: www.highegg.matfyz.cz _______________________________________________ Help-octave mailing list Help-octave@... https://www-old.cae.wisc.edu/mailman/listinfo/help-octave |
|
|
Re: Numerical Integration>IMHO, there are at least 2 advantages to Fortran over C++:
>1. Speed of array access due to aliasing problems of pointers. In C, >most of these can be solved using restricted pointers in C99, but in >C++ there are no restricted pointers so far. >2. Compiling Fortran in very fast compared to compiling C++. On any >system I tried, libcruft is usually compiled in a flash. While trying to understand what Jaroslav wrote, and doing a research on "restricted pointers", I found out that the gcc manual contains this: |6.2 Restricting Pointer Aliasing | |As with the C front end, G++ understands the C99 feature of restricted |pointers, specified with the __restrict__, or __restrict type qualifier. I don't know yet what's the meaning of the above, but while I am studying I though that this may be of interest to you :) -- Francesco Potortì (ricercatore) Voice: +39 050 315 3058 (op.2111) ISTI - Area della ricerca CNR Fax: +39 050 315 2040 via G. Moruzzi 1, I-56124 Pisa Email: Potorti@... (entrance 20, 1st floor, room C71) Web: http://fly.isti.cnr.it/ _______________________________________________ Help-octave mailing list Help-octave@... https://www-old.cae.wisc.edu/mailman/listinfo/help-octave |
|
|
Re: Numerical IntegrationOn Sun, Dec 7, 2008 at 4:07 PM, Francesco Potortì <Potorti@...> wrote:
>>IMHO, there are at least 2 advantages to Fortran over C++: >>1. Speed of array access due to aliasing problems of pointers. In C, >>most of these can be solved using restricted pointers in C99, but in >>C++ there are no restricted pointers so far. >>2. Compiling Fortran in very fast compared to compiling C++. On any >>system I tried, libcruft is usually compiled in a flash. > > While trying to understand what Jaroslav wrote, and doing a research on > "restricted pointers", I found out that the gcc manual contains this: > > |6.2 Restricting Pointer Aliasing > | > |As with the C front end, G++ understands the C99 feature of restricted > |pointers, specified with the __restrict__, or __restrict type qualifier. > > I don't know yet what's the meaning of the above, but while I am > studying I though that this may be of interest to you :) > OK, I know about this. I was already thinking whether we can possibly detect (by autoconf) support of restrict, __restrict__ or __restrict and use it within some C++ functions. The principal problem is that when using restrict, the compiler is allowed to assume certain conditions and it is the programmer's responsibility to ensure they're satisfied. > -- > Francesco Potort ì (ricercatore) Voice: +39 050 315 3058 (op.2111) > ISTI - Area della ricerca CNR Fax: +39 050 315 2040 > via G. Moruzzi 1, I-56124 Pisa Email: Potorti@... > (entrance 20, 1st floor, room C71) Web: http://fly.isti.cnr.it/ > -- RNDr. Jaroslav Hajek computing expert Aeronautical Research and Test Institute (VZLU) Prague, Czech Republic url: www.highegg.matfyz.cz _______________________________________________ Help-octave mailing list Help-octave@... https://www-old.cae.wisc.edu/mailman/listinfo/help-octave |
|
|
Re: Numerical IntegrationOn 07/dic/08, at 12:54, Jaroslav Hajek wrote: > I bet it could, especially if that meant that people wanting to build > Octave on Windows using Visual Studio would have increased interest in > purchasing Visual Fortran. > However, those people would find a new obstacle in the process with no > free alternative, and that could mean a loss of users for Octave. IANAL but I think this might also be in contrast with the GPL v3 license... c. _______________________________________________ Help-octave mailing list Help-octave@... https://www-old.cae.wisc.edu/mailman/listinfo/help-octave |
|
|
Re: Numerical IntegrationOn Dec 7, 2008, at 6:38 AM, Jaroslav Hajek wrote: > With more modern Fortran compilers, recursion is no problem (just > declaring the procedure RECURSIVE). A lot of problems with the Fortran > sources could go away if we resigned on compatibility with the ancient > f2c and g77. > The principal obstacle to doing so is that for building with MSVC on > Windows, no suitable Fortran 90 compiler is freely available. This may qualify as OT, but I'm curious ... Is there a free version of MSVC available? ... Is MSVC able to use f2c and/or g77, but not g95, gfortran ? Ben _______________________________________________ Help-octave mailing list Help-octave@... https://www-old.cae.wisc.edu/mailman/listinfo/help-octave |
|
|
Re: Numerical IntegrationOn Sun, Dec 07, 2008 at 11:50:32AM +0100, S?ren Hauberg wrote:
> Yeah, 'quad' uses 'QUADPACK' which is a Fortran library for numerical > integration. Apparently you cannot call Fortran routines recursively, so > 'quad' inherits this limitation. I guess it would make sense to rewrite > this code in C++ if anybody feel like helping out :-) Check the quadgk function which is an m-file, recursive and fast than quad as it vectorizes the calls to the integrand.. D. _______________________________________________ Help-octave mailing list Help-octave@... https://www-old.cae.wisc.edu/mailman/listinfo/help-octave |
|
|
Re: Numerical Integration2008/12/7 Ben Abbott <bpabbott@...>:
> Is there a free version of MSVC available? There are gratis but not free versions available. - Jordi G. H. _______________________________________________ Help-octave mailing list Help-octave@... https://www-old.cae.wisc.edu/mailman/listinfo/help-octave |
|
|
Re: Numerical IntegrationOn 7-Dec-2008, Søren Hauberg wrote:
| Perhaps Intel could be persuaded to donate a few licenses to their | compilers? What about mingw -- does that come with a fortran compiler? Yes, GCC includes gcc, g++, and gfortran. As this is GNU Octave that we are working on and using, we should be promoting the use those compilers anyway, not proprietary software. jwe _______________________________________________ Help-octave mailing list Help-octave@... https://www-old.cae.wisc.edu/mailman/listinfo/help-octave |
|
|
Re: Numerical IntegrationOn Wed, Dec 10, 2008 at 8:28 PM, John W. Eaton <jwe@...> wrote:
> On 7-Dec-2008, Søren Hauberg wrote: > > | Perhaps Intel could be persuaded to donate a few licenses to their > | compilers? What about mingw -- does that come with a fortran compiler? > > Yes, GCC includes gcc, g++, and gfortran. As this is GNU Octave that > we are working on and using, we should be promoting the use those > compilers anyway, not proprietary software. > Definitely. But actually, I guess it would be sort of promoting, especially if we provided a notice like this: "Due to a lack of MSVC-compatible free Fortran compiler for Windows, in order to build Octave from sources with MSVC, you need a compatible proprietary Fortran compiler. To avoid that, consider using a free operating system like GNU, that comes with a free Fortran compiler". Still, it doesn't solve the main problem. > jwe > -- RNDr. Jaroslav Hajek computing expert Aeronautical Research and Test Institute (VZLU) Prague, Czech Republic url: www.highegg.matfyz.cz _______________________________________________ Help-octave mailing list Help-octave@... https://www-old.cae.wisc.edu/mailman/listinfo/help-octave |
|
|
Re: Numerical IntegrationOn 11-Dec-2008, Jaroslav Hajek wrote:
| Definitely. But actually, I guess it would be sort of promoting, | especially if we provided a notice like this: | "Due to a lack of MSVC-compatible free Fortran compiler for Windows, | in order to build Octave from sources with MSVC, you need a compatible | proprietary Fortran compiler. To avoid that, You could also insert here that using MinGW with GCC would work. | consider using a free | operating system like GNU, that comes with a free Fortran compiler". | Still, it doesn't solve the main problem. Sorry, what is the main problem? jwe _______________________________________________ Help-octave mailing list Help-octave@... https://www-old.cae.wisc.edu/mailman/listinfo/help-octave |
|
|
Re: Numerical IntegrationOn Thu, Dec 11, 2008 at 3:16 PM, John W. Eaton <jwe@...> wrote:
> On 11-Dec-2008, Jaroslav Hajek wrote: > > | Definitely. But actually, I guess it would be sort of promoting, > | especially if we provided a notice like this: > | "Due to a lack of MSVC-compatible free Fortran compiler for Windows, > | in order to build Octave from sources with MSVC, you need a compatible > | proprietary Fortran compiler. To avoid that, > > You could also insert here that using MinGW with GCC would work. > > | consider using a free > | operating system like GNU, that comes with a free Fortran compiler". > > | Still, it doesn't solve the main problem. > > Sorry, what is the main problem? > The main problem is that Michael Goffioul is stuck with f2c because there is no free MSVC-compatible Fortran compiler. Some compilers are available gratis but don't allow distributing the resulting binaries the way we do for Octave. If we put money together, we could buy him a license for a proprietary compiler; still, other users wanting to build on Windows/MSVC will need to get licenses of their own. I guess it's just too much trouble that outweighs the benefits of requiring a Fortran 90 compiler for Octave. > jwe > > -- RNDr. Jaroslav Hajek computing expert Aeronautical Research and Test Institute (VZLU) Prague, Czech Republic url: www.highegg.matfyz.cz _______________________________________________ Help-octave mailing list Help-octave@... https://www-old.cae.wisc.edu/mailman/listinfo/help-octave |
|
|
Re: Numerical IntegrationOK I ask you once again.What if R(t) won't be an error function? I have to calculate such a function and I don't know how to do it. Every help will be usefull.
|
| Free embeddable forum powered by Nabble | Forum Help |