Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'Problem solving huge NIntegral: may be syntax i...' topicStudent Support Forum > General > Archives > "Problem solving huge NIntegral: may be syntax i..."

Next Comment >Help | Reply To Topic
Author Comment/Response
Shravan
01/11/12 6:23pm

This issue is not as daunting as the post appears to be. I think its a syntax issue, not sure though.

g1[u_, k_, n_,
z_] := (Sinc[(y[[k]][[n + 1]] - y[[k]][[n + 1]])*
u*(Cos[z]/(2*Pi*63))])*(Cos[(y[[k]][[n + 1]] + y[[k]][[n + 1]])*
u*(Cos[z]/(2*63))])

g2[u_, k_, n_,
z_] := (Sinc[(y[[k]][[63 - n + 1]] - y[[k]][[63 - n]])*
u*(Cos[z]/(2*Pi*63))])*(Cos[(y[[k]][[63 - n + 1]] +
y[[k]][[63 - n]])*u*(Cos[z]/(2*63))])

f1[u_, k_, n_] := NIntegrate[g1[u, k, n, z], {z, 0, Pi/2}]

f2[u_, k_, n_] := NIntegrate[g2[u, k, n, z], {z, 0, Pi/2}]

z := NIntegrate[(Product[(Sum[(f1[u, k, n] + f2[u, k, n])*(2/Pi), {n, 1,
62}])*(1/(2*63)), {k, 2, 3}]), {u, 0, 1}]

I am having trouble executing the above commands in mathematica. I get the following error.

"NIntegrate::inumr: "The integrand 1.\ Cos[0.016385\ u\ Cos[z]] has evaluated to non-numerical values for all sampling points in the region with boundaries {{0,1.5708}}""

I changed the NIntegral z to the following z' and it works like a charm and I get the result.

z' := NIntegrate[(Product[(Sum[(f1[1, 2, 1] + f2[1, 2, 1])*(2/Pi), {n, 1,
62}])*(1/(2*63)), {k, 2, 3}]), {u, 0, 1}]

Just replaced u,k,n with constants 1,2,1 in function f1 and f2.

May I know how to execute the function z. I think it has to do with syntax.
I spent lot of time on this but I was unable to figure out how to solve it. Any body if you can, please help me with this.

In functions g1 and g2, y is a 2D list as shown below.

{{0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.}, {0.516129, 1.03226,
0.516129, 0.516129, 0.516129, 0.516129, 0.483871, 0.451613,
0.451613, 0.451613, 0.451613, 0.419355, 0.387097, 0.354839,
0.354839, 0.354839, 0.322581, 0.322581, 0.290323, 0.290323,
0.322581, 0.258065, 0.193548, 0.129032, 0.0967742, 0.0967742,
0.0645161, 0.0322581, 0.0322581, 0.0967742, 0.0967742, 0., 0.,
0., -0.0967742, -0.0967742, -0.0322581, -0.0322581, -0.0645161, \
-0.0967742, -0.0967742, -0.129032, -0.193548, -0.258065, -0.322581, \
-0.290323, -0.290323, -0.322581, -0.322581, -0.354839, -0.354839, \
-0.354839, -0.387097, -0.419355, -0.451613, -0.451613, -0.451613, \
-0.451613, -0.483871, -0.516129, -0.516129, -0.516129, -0.516129}, \
{0.516129, 0.516129, 0.516129, 0.516129, 0.516129, 0.483871, 0.419355,
0.387097, 0.387097, 0.387097, 0.354839, 0.354839, 0.354839,
0.322581, 0.322581, 0.290323, 0.258065, 0.16129, 0.129032, 0.16129,
0.129032, 0.0645161, 0.0645161, 0.16129, 0.129032, 0.0322581,
0.0322581, 0., -0.0645161, -0.0645161, -0.0322581, 0.,
0., -0.0322581, -0.0645161, -0.129032, -0.193548, -0.225806, \
-0.290323, -0.258065, -0.225806, -0.258065, -0.258065, -0.322581, \
-0.354839, -0.322581, -0.354839, -0.387097, -0.419355, -0.451613, \
-0.451613, -0.419355, -0.419355, -0.483871, -0.516129, -0.516129, \
-0.516129, -1., -0.483871, -0.516129, -0.516129, -0.516129, \
-0.516129}, {0.516129, 0.516129, 1.03226, 0.516129, 0.516129,
0.516129, 0.516129, 0.483871, 0.451613, 0.451613, 0.451613,
0.451613, 0.419355, 0.387097, 0.354839, 0.354839, 0.354839,
0.322581, 0.322581, 0.290323, 0.290323, 0.322581, 0.258065,
0.193548, 0.129032, 0.0967742, 0.0967742, 0.0645161, 0.0322581,
0.0322581, 0.0967742, 0.0967742, 0., 0.,
0., -0.0967742, -0.0967742, -0.0322581, -0.0322581, -0.0645161, \
-0.0967742, -0.0967742, -0.129032, -0.193548, -0.258065, -0.322581, \
-0.290323, -0.290323, -0.322581, -0.322581, -0.354839, -0.354839, \
-0.354839, -0.387097, -0.419355, -0.451613, -0.451613, -0.451613, \
-0.451613, -0.483871, -0.516129, -0.516129, -0.516129}, {0.516129,
0.516129, 0.516129, 0.516129, 0.516129, 0.483871, 0.451613,
0.419355, 0.387097, 0.387097, 0.354839, 0.322581, 0.258065,
0.225806, 0.193548, 0.16129, 0.16129, 0.16129, 0.225806, 0.225806,
0.16129, 0.129032, 0.0645161, 0.0322581, 0.0322581, 0.0322581,
0.0645161, 0.0322581, 0.,
0., -0.0967742, -0.16129, -0.129032, -0.16129, -0.16129, -0.193548, \
-0.258065, -0.225806, -0.258065, -0.290323, -0.225806, -0.225806, \
-0.258065, -0.322581, -0.419355, -0.419355, -0.354839, -0.354839, \
-0.419355, -0.483871, -0.516129, -0.483871, -0.903226, -0.387097, \
-0.483871, -0.516129, -0.516129, -0.483871, -0.451613, -0.483871, \
-0.516129, -0.516129, -0.516129}, {0.516129, 0.516129, 0.516129,
0.516129, 0.516129, 0.516129, 0.483871, 0.419355, 0.387097,
0.387097, 0.387097, 0.354839, 0.354839, 0.354839, 0.322581,
0.322581, 0.290323, 0.258065, 0.16129, 0.129032, 0.16129, 0.129032,
0.0645161, 0.0645161, 0.16129, 0.129032, 0.0322581, 0.0322581,
0., -0.0645161, -0.0645161, -0.0322581, 0.,
0., -0.0322581, -0.0645161, -0.129032, -0.193548, -0.225806, \
-0.290323, -0.258065, -0.225806, -0.258065, -0.258065, -0.322581, \
-0.354839, -0.322581, -0.354839, -0.387097, -0.419355, -0.451613, \
-0.451613, -0.419355, -0.419355, -0.483871, -0.516129, -0.516129, \
-0.516129, -1., -0.483871, -0.516129, -0.516129, -0.516129}, \
{0.516129, 0.516129, 0.516129, 0.516129, 0.516129, 0.483871, 0.419355,
0.354839, 0.322581, 0.322581, 0.290323, 0.290323, 0.322581,
0.322581, 0.290323, 0.258065, 0.225806, 0.16129, 0.129032, 0.129032,
0.0967742, 0.0645161, 0., -0.0322581,
0., -0.0645161, -0.0645161, -0.0645161, -0.0967742, -0.0967742, \
-0.129032, -0.16129, -0.129032, -0.0967742, -0.193548, -0.290323, \
-0.290323, -0.258065, -0.580645, -0.0645161, -0.258065, -0.290323, \
-0.322581, -0.258065, -0.225806, -0.322581, -0.387097, -0.419355, \
-0.354839, -0.322581, -0.354839, -0.387097, -0.451613, -0.419355, \
-0.419355, -0.451613, -0.451613, -0.483871, -0.483871, -0.483871, \
-0.516129, -0.516129, -0.516129}, {0.516129, 0.516129, 0.516129,
1.03226, 0.516129, 0.516129, 0.516129, 0.516129, 0.483871, 0.451613,
0.451613, 0.451613, 0.451613, 0.419355, 0.387097, 0.354839,
0.354839, 0.354839, 0.322581, 0.322581, 0.290323, 0.290323,
0.322581, 0.258065, 0.193548, 0.129032, 0.0967742, 0.0967742,
0.0645161, 0.0322581, 0.0322581, 0.0967742, 0.0967742, 0., 0.,
0., -0.0967742, -0.0967742, -0.0322581, -0.0322581, -0.0645161, \
-0.0967742, -0.0967742, -0.129032, -0.193548, -0.258065, -0.322581, \
-0.290323, -0.290323, -0.322581, -0.322581, -0.354839, -0.354839, \
-0.354839, -0.387097, -0.419355, -0.451613, -0.451613, -0.451613, \
-0.451613, -0.483871, -0.516129, -0.516129}, {0.516129, 0.516129,
0.516129, 0.516129, 0.516129, 0.483871, 0.451613, 0.451613,
0.419355, 0.387097, 0.354839, 0.322581, 0.290323, 0.258065,
0.225806, 0.16129, 0.16129, 0.129032, 0.0967742, 0.129032,
0.0967742, 0.0967742, 0.0645161, 0.0322581, 0.0322581,
0., -0.0645161, -0.0645161, -0.0322581, -0.129032, -0.225806, \
-0.225806, -0.16129, -0.419355,
0.0967742, -0.16129, -0.258065, -0.290323, -0.193548, -0.129032, \
-0.193548, -0.225806, -0.225806, -0.193548, -0.225806, -0.290323, \
-0.322581, -0.354839, -0.322581, -0.354839, -0.419355, -0.419355, \
-0.387097, -0.354839, -0.387097, -0.483871, -0.516129, -0.483871, \
-0.451613, -0.451613, -0.483871, -0.516129, -0.516129}, {0.516129,
0.516129, 0.516129, 0.516129, 0.516129, 0.516129, 0.483871,
0.451613, 0.419355, 0.387097, 0.387097, 0.354839, 0.322581,
0.258065, 0.225806, 0.193548, 0.16129, 0.16129, 0.16129, 0.225806,
0.225806, 0.16129, 0.129032, 0.0645161, 0.0322581, 0.0322581,
0.0322581, 0.0645161, 0.0322581, 0.,
0., -0.0967742, -0.16129, -0.129032, -0.16129, -0.16129, -0.193548, \
-0.258065, -0.225806, -0.258065, -0.290323, -0.225806, -0.225806, \
-0.258065, -0.322581, -0.419355, -0.419355, -0.354839, -0.354839, \
-0.419355, -0.483871, -0.516129, -0.483871, -0.903226, -0.387097, \
-0.483871, -0.516129, -0.516129, -0.483871, -0.451613, -0.483871, \
-0.516129, -0.516129}}

URL: ,

Subject (listing for 'Problem solving huge NIntegral: may be syntax i...')
Author Date Posted
Problem solving huge NIntegral: may be syntax i... Shravan 01/11/12 6:23pm
Re: Problem solving huge NIntegral: may be synt... Bill Simpson 01/18/12 10:10pm
Next Comment >Help | Reply To Topic