Beginner, plot with multiple rules depending on parameters

*To*: mathgroup at smc.vnet.net*Subject*: [mg83739] Beginner, plot with multiple rules depending on parameters*From*: Francesco Mosconi <mosconi at pd.infn.it>*Date*: Thu, 29 Nov 2007 06:31:49 -0500 (EST)

Hello, I am a beginner user, and I am using Mathematica 5.0 on Windows XP. I would like to plot a function which is composed by three rules of the form: if x < a => F[x] = f1 if a < x < b => F[x] = f2 etc. The thing is slightly complicated by the fact that the function rules and the points of junction depend on several parameters and I don't know how to evaluate them correcly. I wrote the following code: ------------------Mathematica Code-------------------------------- (* First I clear all the variables, define the standard parameter substitution, define some constants. Then I define the functions of g[f],cs[f],ss[f] and sp[f]. Finally I give the rules for the function F[f,s], which is formed by three parts, depending on the value of s. *) ClearAll;Clear[F];Clear[z]; stdpar = {A->50,CC->95,P->40}; kBT = 4.1; c=kBT CC (2 Pi/3.6)^2; p=kBT P (2 Pi/3.6)^2; fc=kBT/A; g[f_]:=f-Sqrt[f*fc] cs[f_]:=c*(1-CC/(4 A)*Sqrt[fc/f]) ss[f_]:=FullSimplify[1/cs[f]*Sqrt[2 p g[f]/(1-p/cs[f])]]; sp[f_]=FullSimplify[1/p*Sqrt[2 p g[f]/(1-p/cs[f])]]; F[f_,s_]:=-g[f]+1/2 cs[f] s^2 /;s < s[f] F[f_,s_]:=FullSimplify[-g[f]/(1-p/cs[f])+Sqrt[2 p g[f]/(1- p/cs[f])]*s]/;ss[f]<s < sp[f] F[f_,s_] := 1/2 p s^2 /; s > sp[f] ?F (* Here I just want to check that the functions of f evaluate correcly when all the standard parameters are substituted. *) g[1]/.stdpar cs[1]/.stdpar ss[1]/.stdpar sp[1]/.stdpar (* Now I would like to do the same for F, evaluating it for particular values of f and s *) F[1,0.1]/.stdpar (* I define the function z[f,s] as minus the derivative of F with respect to f *) z[f_,s_]=FullSimplify[-D[F[f,s],f]] (* And I would like to plot it for different values of f and s. *) Plot[Evaluate[Table[z[f,s],{ f,0.02,1,0.1}]/.stdpar],{s,0,0.1},PlotRange\[Rule]{-1,1}] ------------------Mathematica Code-------------------------------- I must have got sumething wrong because the function F[f,s] does not evaluate to a number even when the /.stdpar rule is applied. Can anyone suggest a solution? Thank you very much Francesco

**Follow-Ups**:**RE: Beginner, plot with multiple rules depending on parameters***From:*"Jaccard Florian" <Florian.Jaccard@he-arc.ch>