MathGroup Archive 2002

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

Search the Archive

RE: problems with the definition of a function

  • To: mathgroup at smc.vnet.net
  • Subject: [mg36657] RE: [mg36651] problems with the definition of a function
  • From: "David Park" <djmp at earthlink.net>
  • Date: Wed, 18 Sep 2002 02:09:34 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Fabio,

f[x_ /; IntegerQ[Rationalize[x/(2Pi)]], y] := g[x]
f[x_, y_] := h[x, y]

f[# Pi, y] & /@ Range[10]
{h[Pi, y], g[2*Pi], h[3*Pi, y], g[4*Pi], h[5*Pi, y],
  g[6*Pi], h[7*Pi, y], g[8*Pi], h[9*Pi, y], g[10*Pi]}

f[2.0Pi, y]
g[6.28319]

f[3.5, y]
h[3.5, y]

f[4.01Pi, 5]
h[12.5978, 5]

You can use a second argument in Rationalize to control how small a
rationalization error is allowed and there is always the question about what
domain around 2nPi you want to include in the first definition.


David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/



From: fabio bagarello [mailto:bagarell at unipa.it]
To: mathgroup at smc.vnet.net

Hi there!!
I have quite an easy and annoying problem with mathematica:
I need to define a function f(x,y) which takes some values for
x=0,2pi,4pi (indepently of y) and has a different expression for all
the other values of y. This is easily done for one-dimensional
functions but I am in serious troubles for my two-dimensional problem:
any suggestion?
Thanks a lot,
Fabio




  • Prev by Date: RE: problems with the definition of a function
  • Next by Date: Re: Postponing loading of Package
  • Previous by thread: RE: problems with the definition of a function
  • Next by thread: Re: problems with the definition of a function