Re: display of function
- To: mathgroup at smc.vnet.net
- Subject: [mg58524] Re: [mg58506] display of function
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Tue, 5 Jul 2005 06:34:16 -0400 (EDT)
- Reply-to: hanlonr at cox.net
- Sender: owner-wri-mathgroup at wolfram.com
p = {p1,p2,p3};
y={y1, y2, y3};
Use the dot product
p.y
p1*y1 + p2*y2 + p3*y3
p = {.3,.4,.3};
y={10000, 20000, 30000};
p.y
20000.
For your function to work, you would need to use Part rather than Subscript
and define n (i.e., provide a numerical value for the index upper limit).
u[y_]:=Sum[p[[i]]*y[[i]],{i,1,Length[y]}];
u[y]
20000.
Bob Hanlon
>
> From: "Bosch, Darrell" <bosch at vt.edu>
To: mathgroup at smc.vnet.net
> Date: 2005/07/05 Tue AM 01:57:45 EDT
> Subject: [mg58524] [mg58506] display of function
>
>
> 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}
>
>
>