[Date Index]
[Thread Index]
[Author Index]
RE: problems with the definition of a function
*To*: mathgroup at smc.vnet.net
*Subject*: [mg36653] RE: [mg36651] problems with the definition of a function
*From*: "Wolf, Hartmut" <Hartmut.Wolf at t-systems.com>
*Date*: Wed, 18 Sep 2002 02:09:28 -0400 (EDT)
*Sender*: owner-wri-mathgroup at wolfram.com
>-----Original Message-----
>From: bagarell at unipa.it [mailto:bagarell at unipa.it]
To: mathgroup at smc.vnet.net
>Sent: Monday, September 16, 2002 6:34 AM
>Subject: [mg36653] [mg36651] problems with the definition of a function
>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
It's difficult to guess what you wanted to attain and what your problems
were. Perhaps this example might help you:
In[11]:= f[x_, _] /; Mod[x, 2Pi] == 0 := x/(2Pi)
In[12]:= f[x_, y_] := x + y
In[13]:= epsilon = $MachineEpsilon
Out[13]= 2.220446049250313*^-16
In[14]:=
f[6Pi(1 + epsilon Sin[#]), #] & /@ Range[0, 4Pi, Pi 10^-1]
Out[14]=
{3, 3., 19.4779, 19.792, 20.1062, 20.4204, 20.7345, 21.0487, 21.3628, 3., 3,
\
22.3053, 22.6195, 22.9336, 23.2478, 23.5619, 23.8761, 24.1903, 24.5044, \
24.8186, 3, 3., 25.7611, 26.0752, 26.3894, 26.7035, 27.0177, 27.3319,
27.646, \
3., 3, 28.5885, 28.9027, 29.2168, 29.531, 29.8451, 30.1593, 30.4734,
30.7876, \
31.1018, 3}
Look close at the values returned (compare with
epsilon Sin[Range[0, 4Pi, Pi 10^-1]]),
also to recognize the dangers of such a definition.
--
Hartmut
Prev by Date:
**Re: Postponing loading of Package**
Next by Date:
**RE: problems with the definition of a function**
Previous by thread:
**RE: problems with the definition of a function**
Next by thread:
**RE: problems with the definition of a function**
| |