Re: display of function
- To: mathgroup at smc.vnet.net
- Subject: [mg58531] Re: [mg58506] display of function
- From: "Carl K. Woll" <carl at woll2woll.com>
- Date: Wed, 6 Jul 2005 03:11:15 -0400 (EDT)
- References: <200507050557.BAA29432@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Darrell Bosch 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} > > Darrell, As others have mentioned, for this case the simplest approach is to use Dot: u[y_] := p.y Again, as others have mentioned, using Part instead of Subscript in your method would work. I just want to point out that it's possible to use subscripts in the way you intended: u[y_] := Sum[ p * y ,{i,1,n}] [[i]] [[i]] The above is not working Mathematica code, you need to use 2D boxform input, i.e., input the subscripts using Ctrl-_. In other words, when Mathematica parses 2D boxform input where the subscript is a part specfication, then Part is automatically used instead of Subscript. You can make things even prettier by using \[LeftDoubleBracket] and \[RightDoubleBracket] instead of [[ and ]]. Carl Woll Wolfram Research
- References:
- display of function
- From: "Bosch, Darrell" <bosch@vt.edu>
- display of function