Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: display of function

  • To: mathgroup at
  • Subject: [mg58516] Re: display of function
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at>
  • Date: Tue, 5 Jul 2005 04:52:24 -0400 (EDT)
  • Organization: The Open University, Milton Keynes, England
  • References: <dad7oo$t91$>
  • Sender: owner-wri-mathgroup at

Bosch, Darrell wrote:
> Dear Math Group:
>             The first equation below shows a function for u(y) which is
> the sum of the products of pi times yi.  In the following steps, I
> assign values of p and y.   How can I get Mathematica to display the
> numerical value of u for the given p and y values?  When I insert the
> u[y] command, I just get a repeat of the equation I have entered.
> Thanks for your suggestions.  This group is a great help.  Darrell
> u[y_] := Sum[Subscript[p, i]*Subscript[y, i],
>    {i, 1, n}]
> p = {.3,.4,.3}
> y={10000, 20000, 30000}
Hi Darrell,

Assuming that I have correctly understood what you tried to do, you 
could use either one of the following approaches:

p = {0.3, 0.4, 0.3}
y = {10000, 20000, 30000}

{0.3, 0.4, 0.3}

{10000, 20000, 30000}

We take the product of the corresponding elements in each list


{3000., 8000., 9000.}

Finally, we take the sum of these products

Plus @@ %


This series of operations is indeed the dot product of p and y
p . y


If you need to use some other functions in place of *Plus* and *Times*, 
have a look at the *Inner* product.

Best regards,

  • Prev by Date: Re: Function to handle array with variable _number_ of dimensions?
  • Next by Date: Re: How to simulate random samples from crooked coin toss?
  • Previous by thread: Re: display of function
  • Next by thread: Re: display of function