Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #6505 > unrolled thread
| Started by | "J. Jesús Rico Melgoza" <jerico@umich.mx> |
|---|---|
| First post | 2011-11-18 11:26 +0000 |
| Last post | 2011-11-23 12:09 +0000 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
NIntegrate to compute LegendreP approximations to functions "J. Jesús Rico Melgoza" <jerico@umich.mx> - 2011-11-18 11:26 +0000
Re: NIntegrate to compute LegendreP approximations to functions "Kevin J. McCann" <Kevin.McCann@umbc.edu> - 2011-11-23 12:09 +0000
| From | "J. Jesús Rico Melgoza" <jerico@umich.mx> |
|---|---|
| Date | 2011-11-18 11:26 +0000 |
| Subject | NIntegrate to compute LegendreP approximations to functions |
| Message-ID | <ja5fd6$6dl$1@smc.vnet.net> |
Hello
I am approximating general scalar functions via orthogonal series. I am
using LegendreP polynomials.
As an example, I have approximated a Sign function. The coefficients
have been calculated as follows:
n = 20;
u = Sign[t];
N[Table[(2 k + 1)/2 Integrate[u LegendreP[k, t], {t, -1, 1}], {k, 0,
n}]]
Everything works well but I would like to speed up computations since
for large values of n, Integrate takes long computations times. I need
to speed up the process since in general I will be approximating
multi-variable functions. I have tried NIntegrate but I get multiple
messages such as
NIntegrate::slwcon : "Numerical integration converging too slowly;
suspect \
one of the following: singularity, value of the integration is 0, highly
\
oscillatory integrand, or WorkingPrecision too small. =91=99=98ButtonBox["
",
Appearance->{Automatic, None},
BaseStyle->"Link",
ButtonData:>"paclet:ref/message/NIntegrate/slwcon",
ButtonNote->"NIntegrate::slwcon"]"
NIntegrate is a very complete function in Mathematica, so much that it
has been rather difficult to find an adequate combination of a method
and a strategy of integration that would improve the timing of
Integrate.
Could anyone give me some advice?
Jesus Rico-Melgoza
[toc] | [next] | [standalone]
| From | "Kevin J. McCann" <Kevin.McCann@umbc.edu> |
|---|---|
| Date | 2011-11-23 12:09 +0000 |
| Message-ID | <jainov$emd$1@smc.vnet.net> |
| In reply to | #6505 |
A slightly different approach to the solution is based on the fact that
the coefficients in the expansion are such that they provide the
least-squares fit to the data. This will usually not give you the exact
answer, but one that is often close. I use it with data that is
irregularly spaced in polar angle and azimuth when I fit to spherical
harmonics.
Here is an example:
f[t_] := \!\(
\*UnderoverscriptBox[\(\[Sum]\), \(n = 0\), \(100\)]\(a[n] LegendreP[
n, t]\)\)
tbl = Table[{t, Sign[t]}, {t, -1, 1, .001}];
ListPlot[tbl, Joined -> True]
sol = FindMinimum[Total[(#[[2]] - f[#[[1]]])^2 & /@ tbl],
Table[{a[n], 0.5}, {n, 0, 100}]] // Chop
Table[{a[n], a[n] /. sol[[2]]}, {n, 1, 100}] // TableForm
Cheers,
Kevin
On 11/18/2011 6:26 AM, "J. Jes=FAs Rico Melgoza" wrote:
> Hello
> I am approximating general scalar functions via orthogonal series. I am
> using LegendreP polynomials.
> As an example, I have approximated a Sign function. The coefficients
> have been calculated as follows:
>
> n = 20;
> u = Sign[t];
> N[Table[(2 k + 1)/2 Integrate[u LegendreP[k, t], {t, -1, 1}], {k, 0,
> n}]]
>
> Everything works well but I would like to speed up computations since
> for large values of n, Integrate takes long computations times. I need
> to speed up the process since in general I will be approximating
> multi-variable functions. I have tried NIntegrate but I get multiple
> messages such as
>
> NIntegrate::slwcon : "Numerical integration converging too slowly;
> suspect \
> one of the following: singularity, value of the integration is 0, highl=
y
> \
> oscillatory integrand, or WorkingPrecision too small. =91=99=98Bu=
ttonBox["
> ",
> Appearance->{Automatic, None},
> BaseStyle->"Link",
> ButtonData:>"paclet:ref/message/NIntegrate/slwcon",
> ButtonNote->"NIntegrate::slwcon"]"
>
> NIntegrate is a very complete function in Mathematica, so much that it
> has been rather difficult to find an adequate combination of a method
> and a strategy of integration that would improve the timing of
> Integrate.
>
> Could anyone give me some advice?
>
> Jesus Rico-Melgoza
>
>
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web