Re: Defining derivatives
- To: mathgroup at smc.vnet.net
- Subject: [mg84491] Re: [mg84484] Defining derivatives
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Sat, 29 Dec 2007 19:58:10 -0500 (EST)
- Reply-to: hanlonr at cox.net
Clear[QuarticSpline]; QuarticSpline[x_] := Module[{r}, r = Sqrt[x^2]; Piecewise[{{1 + r^2 (-6 + r (8 - 3 r)), r <= 1}}]]; QuarticSpline'[x] // FullSimplify Piecewise[ {{-12*(x^3 - 2*Abs[x]*x + x), Sqrt[x^2] <= 1}}] Plot[{QuarticSpline[x], QuarticSpline'[x]}, {x, -1.1, 1.1}] Bob Hanlon ---- KF <fresl at grad.hr> wrote: > (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 > > >