Re: Define a function
- To: mathgroup at smc.vnet.net
- Subject: [mg34626] Re: Define a function
- From: "Tilemachos" <tasosarv at otenet.gr>
- Date: Thu, 30 May 2002 02:55:07 -0400 (EDT)
- References: <acshar$ke2$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Needs["Graphics`Master`"] a = 5 b = 25 f[x_] := Which[x < 10, 0, 10 <= x <= 20, x, x > 02, x/2] listf = {} For[x = a, x <= b, x += .051, {AppendTo[listf, N[f[x]]], AppendTo[listf, N[g[x]]], AppendTo[listf, N[h[x]]]}] c = Floor[Min[listf]] d = Ceiling[Max[listf]] Plot[f[x], {x, a, b}, DefaultFont -> {"HellasArial", 10}, AspectRatio -> Automatic, PlotRange -> All, PlotStyle -> {{Thickness[.004], RGBColor[1.000, 0.000, 0.000]}, {Thickness[.004], RGBColor[0.000, 1.000, 0.000]}, {Thickness[.004], RGBColor[0.545, 0.588, 0.447]}}, Ticks -> {Table[i, {i, a, b, 1}], Table[j, {j, c, d, 1}]}, GridLines -> {Range[a, b, 1], Range[c, d, 1]}, AxesLabel -> {"X", "Y"}, AxesStyle -> {Thickness[.005], RGBColor[0.000, 0.000, 1.000]}] ****tilemachos**** Ï "Michael Popp" <popp.michael at gmx.at> Ýãñáøå óôï ìÞíõìá news:acshar$ke2$1 at smc.vnet.net... > Hello > > I want to define a function in Mathematica. But just f[x_]:=... does not > work, because I have to define different functions for different ranges of > the variable x. > For example: > > x < 10: f(x) = 0 > 10 < x < 20: f(x) = x > 20 < x: f(x) = x/2 > > How to do this? > > Thanks, greetings > Michael > > > >