Re: Table of Values
- To: mathgroup at smc.vnet.net
- Subject: [mg109561] Re: Table of Values
- From: Bill Rowe <readnews at sbcglobal.net>
- Date: Wed, 5 May 2010 06:06:24 -0400 (EDT)
On 5/4/10 at 6:30 AM, nkormanik at gmail.com (Nicholas Kormanik) wrote: >The Mathematica mini-program below has been useful for solving for >x, given the other inputs. It is analogous to a single-shot rifle: >x =. >tradecomission := 9.99 >feepercontract := .75 >pricepercontract := .73 >numbercontracts := x >totalcost := 8484 Since all of the above are constants, it really would be better to use Set rather than SetDelayed. That is doing: tradecomission = 9.99; feepercontract = .75; pricepercontract = .73; totalcost = 8484; Note, I omitted numbercontracts:=x since this isn't needed. In fact, Solve isn't needed since you've already done the work Solve would do, i.e., In[32]:= Floor[(totalcost - tradecomission)/(pricepercontract*100 + feepercontract)] Out[32]= 114 Here, I've used the Floor function since your table suggest you only want the integer portion of the solution. To create your table use Table. That is: TableForm[ Table[{pricepercontract, Floor[(totalcost - tradecomission)/(pricepercontract*100 + feepercontract)]}, {pricepercontract, .73, .84, .01}], TableHeadings -> {None, {"Price/Contract", "No Contracts"}}] will create a nicely formatted table. The function Table does the actual computations. The function TableForm simply formats the output in a nice fashion.