Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

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

Search the Archive

Re: Manipulating list of functions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg96835] Re: Manipulating list of functions
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Thu, 26 Feb 2009 07:51:55 -0500 (EST)
  • Organization: Uni Leipzig
  • References: <go31hn$fa1$1@smc.vnet.net>
  • Reply-to: kuska at informatik.uni-leipzig.de

Hi,

Manipulate[
  Block[{buyprice = 100, initialinvestment, nbrshares, profit,
    totalofholding, funcList},
   initialinvestment[x_] := 100000;
   nbrshares[buyprice_] := initialinvestment[buyprice]/buyprice;
   profit[buyprice_] := (finalprice - buyprice)*nbrshares[buyprice];

   totalofholding[_] := profit + initialinvestment;
   funcList = #[x] & /@ {nbrshares, initialinvestment, profit,
      totalofholding};
   Plot[Evaluate[funcList], {x, 4, 7}, Axes -> False, Frame -> True,
    PlotRange -> {0, 650000}]], {finalprice, 16, 24, 1}]

??

or what ever the dependences initialinvestment[] are and
why you call profit[] as a function, and profit as a symbol
is still strange.

Regards
   Jens


Syd Geraghty wrote:
> Hi all,
> 
> we recently had a thread regarding manipulating a list of functions  
> which worked fine:-
> 
> Manipulate[Block[{funcA, funcB, funcC, funcList},
>    funcA[z_] := Sin[z + a];
>    funcB[z_] := Cos[z + b];
>    funcC[z_] := funcA[z] + funcB[z];
>    funcList = #[x] & /@ {funcA, funcB, funcC};
>    Plot[Evaluate[funcList], {x, 1, 10}, Axes -> False, Frame ->  
> True]], {a, 0,
>    Pi}, {b, 0, Pi}]
> 
> I have tried what I thought would be a trivial a variant of this for  
> very simple functions:
> 
> Manipulate[
>   Block[{initialinvestment, nbrshares, profit, totalofholding,  
> funcList},
>    initialinvestment := 100000;
>    nbrshares[buyprice_] := initialinvestment/buyprice;
>    profit[buyprice_] := (finalprice - buyprice)*nbrshares;
>    totalofholding := profit + initialinvestment;
>    funcList := #[x] & /@ {nbrshares, initialinvestment, profit,  
> totalofholding};
>    Plot[Evaluate[funcList], {x, 4, 7}, Axes -> False, Frame -> True,
>     PlotRange -> {0, 650000}]], {finalprice, 16, 24, 1}]
> 
> However I only get the nbrshares plotted, after several attempts I  
> cannot get the desired output and would appreciate advice as to why  
> the simpler function specifications lead to failure.
> 
> It appears that unless the functions all contain explicit references  
> such as to "z" in the first working example then they are omitted.
> 
> 
> Thanks in advance ... Syd
> 
> Syd Geraghty B.Sc, M.Sc.
> 
> sydgeraghty at mac.com
> 
> Mathematica 7.0.0 for Mac OS X x86 (64 - bit) (21st November, 2008)
> MacOS X V 10.5.6
> MacBook Pro 2.33 GHz Intel Core 2 Duo  2GB RAM
> 
> 
> 
> 


  • Prev by Date: Re: Difference Fit vs. Correlation
  • Next by Date: Re: Counting Categories
  • Previous by thread: Re: Manipulating list of functions
  • Next by thread: Re: Re: Manipulating list of functions