MathGroup Archive 2002

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

Search the Archive

RE: Define a function

  • To: mathgroup at smc.vnet.net
  • Subject: [mg34581] RE: [mg34556] Define a function
  • From: Juan Egea Garcia <jeg at um.es>
  • Date: Wed, 29 May 2002 02:44:27 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Michael, it is very simple using "If" sentences in this way

f[x_] := If[x < 10, 0, If[x > 20, x/2, x]]

=======================================
Juan Egea Garcia
Departamento de Matemática Aplicada
Universidad de Murcia
España

+34 968654243
+34 968367144

-----Mensaje original-----
De: Michael Popp [mailto:popp.michael at gmx.at]
Enviado el: lunes, 27 de mayo de 2002 7:17
Para: mathgroup at smc.vnet.net
Asunto: [mg34556] Define a function


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






  • Prev by Date: RE: basic operations in matrices
  • Next by Date: RE: help with mathematica problem
  • Previous by thread: Re: Define a function
  • Next by thread: Re: Define a function