Re: Odd little Bessel function quirk
- To: mathgroup at smc.vnet.net
- Subject: [mg79049] Re: Odd little Bessel function quirk
- From: Peter Pein <petsie at dordos.net>
- Date: Tue, 17 Jul 2007 03:18:51 -0400 (EDT)
- References: <f7f3ah$ofh$1@smc.vnet.net>
AES schrieb: > [Indented lines are Output cells; others are Input cells] > > > f[r_] := If[r ¾ 1, BesselJ[0, \ r], BesselK[0, r]] > > f[r] > > If[r ¾ 1, BesselJ[0, r], BesselK[0, r]] > > D[f[r], r] > > If[r ¾ 1, 1/2 (BesselJ[-1, r] - BesselJ[1, r]), > 1/2 (-BesselK[-1, r] - BesselK[1, r])] > > D[f[r], r] /. r ¾ 1 -> True > > -BesselJ[1, r] > > D[f[r], r] /. r ¾ 1 -> False > > -BesselK[1, r] > > > Nothing erroneous here (so far as I know) -- but how come the results of > the (superfluous) 4th and 5th Input lines are simplified, but the 3rd > one is not? [When I'm struggling with Bessel functions, I can use all > the simplification I can get!] > Hello AES, If has the attribute HoldRest set. So Mathematica has just to evaluate the branch according to the outcome of the condition. In "If[r "'yen' probably <=" 1, then-part, else-part]" r has got no value and Mathematica can't decide which part to evaluate. In input-line four and five you tell Mathematica enough about r to decide the condition (in fact you replace the condition by True). Now Mathematica knows which part to evaluate and does so. Sorry for my clumsy english :-( Peter