From: ynzhang on


Dear Sir/Madam,

I am a beginner of Mathematica.
I just wrote a Notebook(nb) in Mathematica to in order to obtain the
Gauss-Hermite weights as follows:

n = 5;
Do[w[n][k] = Exp[z0[n][k]^2] Sqrt[Pi] 2^(n - 1) n! /
(n HermiteH[n - 1, z0[n][k]])^2, {k, n}];
I press shift & Enter to Evalutate. The results come out with only

In[1]:= Do[w[n][k] = Exp[z0[n][k]^2] Sqrt[Pi] 2^(n - 1) n! /
(n HermiteH[n - 1, z0[n][k]])^2, {k, n}];

without Out[1].So I dont know if w comes out or not at last . If so,
there should be a row or column vector shown in Out[1].


Thank you very much! I am looking forward to hearing from you soon!

Regards,
Yanni

From: Patrick Scheibe on
Hi,

a Do Loop never returns anything as long as you don't use return. You
can find this information in the "MORE INFORMATION" section of the help
of Do.

However, the assignment of w[n][k] is done. Just check what ?w gives.

If you want to "see" the values of your assignment explicitely, you
could just use a Table:

n = 5;
Table[w[n][k] =
Exp[z0[n][k]^2] Sqrt[
Pi] 2^(n - 1) n!/(n HermiteH[n - 1, z0[n][k]])^2, {k, n}]

Hope this helps,

Cheers
Patrick

On Fri, 2010-07-16 at 05:15 -0400, ynzhang(a)mech.uwa.edu.au wrote:
>
> Dear Sir/Madam,
>
> I am a beginner of Mathematica.
> I just wrote a Notebook(nb) in Mathematica to in order to obtain the
> Gauss-Hermite weights as follows:
>
> n = 5;
> Do[w[n][k] = Exp[z0[n][k]^2] Sqrt[Pi] 2^(n - 1) n! /
> (n HermiteH[n - 1, z0[n][k]])^2, {k, n}];
> I press shift & Enter to Evalutate. The results come out with only
>
> In[1]:= Do[w[n][k] = Exp[z0[n][k]^2] Sqrt[Pi] 2^(n - 1) n! /
> (n HermiteH[n - 1, z0[n][k]])^2, {k, n}];
>
> without Out[1].So I dont know if w comes out or not at last . If so,
> there should be a row or column vector shown in Out[1].
>
>
> Thank you very much! I am looking forward to hearing from you soon!
>
> Regards,
> Yanni
>


From: Murray Eisenberg on
What is z0[n][k] ??

On 7/16/2010 5:15 AM, ynzhang(a)mech.uwa.edu.au wrote:
> n = 5;
> Do[w[n][k] = Exp[z0[n][k]^2] Sqrt[Pi] 2^(n - 1) n! /
> (n HermiteH[n - 1, z0[n][k]])^2, {k, n}];

--
Murray Eisenberg murray(a)math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower phone 413 549-1020 (H)
University of Massachusetts 413 545-2859 (W)
710 North Pleasant Street fax 413 545-1801
Amherst, MA 01003-9305

From: Bill Rowe on
On 7/16/10 at 5:15 AM, ynzhang(a)mech.uwa.edu.au wrote:

>I am a beginner of Mathematica. I just wrote a Notebook(nb) in
>Mathematica to in order to obtain the Gauss-Hermite weights as
>follows:

>n = 5; Do[w[n][k] = Exp[z0[n][k]^2] Sqrt[Pi] 2^(n - 1) n! / (n
>HermiteH[n - 1, z0[n][k]])^2, {k, n}]; I press shift & Enter to
>Evalutate. The results come out with only

>In[1]:= Do[w[n][k] = Exp[z0[n][k]^2] Sqrt[Pi] 2^(n - 1) n! / (n
>HermiteH[n - 1, z0[n][k]])^2, {k, n}];

>without Out[1].So I dont know if w comes out or not at last . If so,
>there should be a row or column vector shown in Out[1].

There are several issues here. First, the semicolon you've used
causes what you've written to be a compound expression
equivalent to expr;Null. When evaluating a compound expression,
Mathematica returns only the output from the last portion which
would be Null in this case. That is when you end your statement
with a semicolon, no matter what the earlier portion of the code
would return nothing will be returned to the output.

Next, Do has no return value. So, in this case omitting the
semicolon will not cause an output to appear.

Using Table instead of Do will create an output. That is:

n = 5;
Table[Exp[z0[n][k]^2] Sqrt[
Pi] 2^(n - 1) n!/(n HermiteH[n - 1, z0[n][k]])^2, {k, n}]

But while this will produce an output, it may not be what you
want. I suspect you may have intended the notation z0[n] to be
the nth element of z0. If so, that is not how Mathematica
evaluates this notation. Notation in the form of name[expr] is
evaluated by Mathematica as a function with name name evaluated
at whatever is returned by expr. At times it can be convenient
to think of name[n] as being the nth element of name. But it is
important to realize Mathematica treats this differently than an array.

=46or example, consider

In[1]:= Do[w[k] = 2 k, {k, 5}]

In[2]:= w[2]

Out[2]= 4

Demonstrating w[2] has the expected value. But note

In[3]:= w^2

Out[3]= w^2

Here, w^2 is returned unevaluated since I've not provided an
argument to the function w. Now, consider

In[4]:= z = Table[2 k, {k, 5}];
z[[2]]

Out[5]= 4

Demonstrating the second element of z has the expected value. And

In[6]:= z^2

Out[6]= {4,16,36,64,100}

Here, each element of z is squared since most built-in functions
thread over lists. And this last output is usually what one wants

=46inally, Mathematica has no concept of row or column vectors.
You can produce either a 1 x n or n x 1 matrix if you like. For
example, {Range[5]} will create a 1 x 5 matrix and
List/@Range[5] will create a 5 x 1 matrix.