Defining derivatives
- To: mathgroup at smc.vnet.net
- Subject: [mg84484] Defining derivatives
- From: KF <fresl at grad.hr>
- Date: Sat, 29 Dec 2007 02:55:22 -0500 (EST)
(I am sorry if this or similar question was already answered. I did archive search, but didn't find anything.) I have a function: QuarticSpline[x_] := Module[ { r }, r = Abs[x]; If [r > 1.0, 0.0, 1 + r r (-6 + r (8 - 3 r)) ] ] It's first derivative should be (at least for my purposes :o) : QuarticSplineD1 [x_] := Module[ { r }, r = Abs [x]; If [r > 1.0, 0.0, Sign[x] * r (-12 + (24 r - 12)) ] ] but D[QuarticSpline[x], x] returns If[Abs[x] > 1., 0, 0] Now, Mathematica Tutorial, in chapter Defining Derivatives, says "You can define the derivative in Mathematica of a function f of one argument simply by an assignment like f'[x_]=fp[x]." But if I try to write QuarticSpline'[x_] = QuarticSplineD1[x] I got Set::write: "Tag Function in (If[Abs[#1]>1.,0,0]&)[x_] is Protected." Is it possible to define QuarticSpline' to "return" QuarticSplineD1 ? Regards, K. Fresl