Services & Resources / Wolfram Forums / MathGroup Archive

MathGroup Archive 2007

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

Search the Archive

RE: Beginner, plot with multiple rules depending on parameters

  • To: mathgroup at
  • Subject: [mg83788] RE: [mg83739] Beginner, plot with multiple rules depending on parameters
  • From: "Jaccard Florian" <Florian.Jaccard at>
  • Date: Fri, 30 Nov 2007 05:27:31 -0500 (EST)
  • References: <>


I'm afraid I don't really understand the end of your message...
But I can say that from 5.2 on, it is easier to do what you want using 
the Piecewise function. If I remember well, it doesn't exist in the 
version 5.0.

If you want your function to be easily derivated, Laplace transformed
and so on, I think the best way to define your function with 5.0 is not 
using "/;" , but using UnitStep.

Like this :

f[x_, a_, b_, f1_, f2_] := UnitStep[a - x]*f1 + UnitStep[b - x, x - 

Example :

Plot[f[x, 1, 3, x^2, Sin[x]], {x, 0, 5}]

Hope it helps!



-----Message d'origine-----
De=A0: Francesco Mosconi [mailto:mosconi at]
Envoy=E9=A0: jeudi, 29. novembre 2007 12:32
=C0=A0: mathgroup at
Objet=A0: [mg83739] Beginner, plot with multiple rules depending on 

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 
if x < a => F[x] = f1
if a < x < b => F[x] = f2
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.

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;
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]


Here I just want to check that the functions of f evaluate correcly when =

all the standard parameters are substituted.


Now I would like to do the same for F, evaluating it for particular
values of f and s


I define the function z[f,s] as minus the derivative of F with respect =
to f


And I would like to plot it for different values of  f and s.


------------------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


  • Prev by Date: Re: optimization routine using conjugate gradient (or other) method?
  • Previous by thread: Beginner, plot with multiple rules depending on parameters
  • Next by thread: Manipulate with very computationally large problems