MathGroup Archive 1999

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

Search the Archive

Re: Problem with conditional definitions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg19529] Re: Problem with conditional definitions
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Sun, 29 Aug 1999 17:21:26 -0400
  • Organization: Universitaet Leipzig
  • References: <7q9dr3$npc@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi Kevin,

when you give a numeric argument to f'[] Mathematica try to
calculate the derivative numerical (because you give not a
value for f'[x]). The numerical algorirthm require the the function
has continuos derivatives and this is not the case in your example.

You should set the derivatives of you f[] explicit to avoid the problem.

Hope that helps
  Jens

"Kevin J. McCann" wrote:
> 
> I have recently uncovered a problem with conditional definitions of
> functions.  The following is a simple example
> 
> Remove[f]
> 
> f[x_ /; x <= 0] := x^2
> f[x_ /; 0 < x < 1] := x^3
> f[x_ /; x >= 1] := x^4
> {f[1.], f'[1.],f''[1.]}
> {1.,3.54208,18.8746}
> Clearly incorrect. Or
> {f[1.1],f'[1.1],f''[1.1]}
> 
>              {1.4641, 5.28974, 8.77428}
> Correct: {1.4641, 5.324,  14.52}
> So it is not that the function was evaluated at a boundary.
> Also, if I use exact arguments:
> {f[1],f'[1],f''[1]} 
> {1,f'[1],f''[1]}
> 
> None of the function definitions lead to the answers I got. Did I miss
> something?


  • Prev by Date: Re: Stochastic Differentail equations
  • Next by Date: Asking you how to...
  • Previous by thread: Re: Problem with conditional definitions
  • Next by thread: Re: Problem with conditional definitions