       Re: Defining derivatives

• To: mathgroup at smc.vnet.net
• Subject: [mg84499] Re: Defining derivatives
• From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
• Date: Sat, 29 Dec 2007 20:02:23 -0500 (EST)
• References: <fl4uhv\$9jb\$1@smc.vnet.net>

```Hi,

if x is symbolic, Abs[x]>1.0 can't not evaluated and
you should define:

QuarticSpline[x_?NumericQ] := Module[{r}, r = Abs[x];
If[r > 1.0,
0.0,
1 + r^2 (-6 + r (8 - 3 r))
]
]

QuarticSplineD1[x_?NumericQ] := Module[{r}, r = Abs[x];
If[r > 1.0,
0.0,
Sign[x]*r (-12 + (24 r - 12))
]
]

Derivative[QuarticSpline][x_] := QuarticSplineD1[x]

Regards
Jens

KF 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
>
>
>

```

• Prev by Date: Re: Defining derivatives
• Next by Date: Re: help with mathematica 5.2-Vector
• Previous by thread: Re: Defining derivatives
• Next by thread: PiecewiseExpand problem.