14 replaced http://mathematica.stackexchange.com/ with https://mathematica.stackexchange.com/ edited Apr 13 '17 at 12:55 Today, I answered a question of mine that asked two month ago. Please see herehere Now I would like to add the argument checking in this function. Then I used a method that Mr.Wizard answeredMr.Wizard answered In addition, Mr.Wizard given me a hint that ultilizing the Message as a side-effect in the commentcomment Now I have a reference herehere Additional, The Toad has a commentcomment as below: Today, I answered a question of mine that asked two month ago. Please see here Now I would like to add the argument checking in this function. Then I used a method that Mr.Wizard answered In addition, Mr.Wizard given me a hint that ultilizing the Message as a side-effect in the comment Now I have a reference here Additional, The Toad has a comment as below: Today, I answered a question of mine that asked two month ago. Please see here Now I would like to add the argument checking in this function. Then I used a method that Mr.Wizard answered In addition, Mr.Wizard given me a hint that ultilizing the Message as a side-effect in the comment Now I have a reference here Additional, The Toad has a comment as below: Notice removed Canonical answer required by xyz occurred Jul 29 '15 at 1:59 Bounty Ended with Mr.Wizard's answer chosen by xyz occurred Jul 29 '15 at 1:59 13 deleted 1 character in body edited Jul 25 '15 at 15:30 xyz 27033 gold badges2727 silver badges100100 bronze badges Thanks for Mr.Wizard's reversionrevision that adding HoldForm in checkArgs to remove the recursion. Thanks for Mr.Wizard's reversion that adding HoldForm in checkArgs to remove the recursion. Thanks for Mr.Wizard's revision that adding HoldForm in checkArgs to remove the recursion. Tweeted twitter.com/#!/StackMma/status/624630677351333888 occurred Jul 24 '15 at 17:22 12 added 2 characters in body; edited tags edited Jul 24 '15 at 14:39 xyz 27033 gold badges2727 silver badges100100 bronze badges Bernstein::invidx = "The index 1 should be a non-negtivenegative machine-sized integer betwwen 2 and 3."; SetAttributes[Bernstein, {Listable, NHoldAll, NumericFunction}] (*special cases*) Bernstein[n_, i_, u_]?checkArgs /; i < 0 || i > n := 0 Bernstein[0, 0, u_]?checkArgs := 1 Bernstein[n_, i_, u_?NumericQ]?checkArgs := Binomial[n, i] u^i (1 - u)^(n - i) (*expansion of the basis of Bernstein*) Bernstein /: PiecewiseExpand[Bernstein[n_, i_, u_]] := Piecewise[ {{Binomial[n, i] u^i (1 - u)^(n - i), 0 <= u <= 1}, {0, u > 1 || u < 0}}] (*the derivatives of the basis of Bernstein*) Bernstein /: Derivative[0, 0, k_Integer?Positive][Bernstein] := Function[{n, i, u}, D[ n (Bernstein[n - 1, i - 1, u] - Bernstein[n - 1, i, u]), {u, k - 1}] ]  Thanks for Mr.Wizard's reversion that adding HoldForm in chechArgcheckArgs to remove the recursion. Bernstein::invidx = "The index 1 should be a non-negtive machine-sized integer betwwen 2 and 3."; SetAttributes[Bernstein, {Listable, NHoldAll, NumericFunction}] (*special cases*) Bernstein[n_, i_, u_]?checkArgs /; i < 0 || i > n := 0 Bernstein[0, 0, u_]?checkArgs := 1 Bernstein[n_, i_, u_?NumericQ]?checkArgs := Binomial[n, i] u^i (1 - u)^(n - i) (*expansion of the basis of Bernstein*) Bernstein /: PiecewiseExpand[Bernstein[n_, i_, u_]] := Piecewise[ {{Binomial[n, i] u^i (1 - u)^(n - i), 0 <= u <= 1}, {0, u > 1 || u < 0}}] (*the derivatives of the basis of Bernstein*) Bernstein /: Derivative[0, 0, k_Integer?Positive][Bernstein] := Function[{n, i, u}, D[ n (Bernstein[n - 1, i - 1, u] - Bernstein[n - 1, i, u]), {u, k - 1}] ]  Thanks for Mr.Wizard's reversion that adding HoldForm in chechArg to remove the recursion. Bernstein::invidx = "The index 1 should be a non-negative machine-sized integer betwwen 2 and 3."; SetAttributes[Bernstein, {Listable, NHoldAll, NumericFunction}] (*special cases*) Bernstein[n_, i_, u_]?checkArgs /; i < 0 || i > n := 0 Bernstein[0, 0, u_]?checkArgs := 1 Bernstein[n_, i_, u_?NumericQ]?checkArgs := Binomial[n, i] u^i (1 - u)^(n - i) (*expansion of the basis of Bernstein*) Bernstein /: PiecewiseExpand[Bernstein[n_, i_, u_]] := Piecewise[ {{Binomial[n, i] u^i (1 - u)^(n - i), 0 <= u <= 1}, {0, u > 1 || u < 0}}] (*the derivatives of the basis of Bernstein*) Bernstein /: Derivative[0, 0, k_Integer?Positive][Bernstein] := Function[{n, i, u}, D[ n (Bernstein[n - 1, i - 1, u] - Bernstein[n - 1, i, u]), {u, k - 1}] ]  Thanks for Mr.Wizard's reversion that adding HoldForm in checkArgs to remove the recursion. Notice added Canonical answer required by xyz occurred Jul 24 '15 at 14:36 Bounty Started worth 100 reputation by xyz occurred Jul 24 '15 at 14:36 11 added 1270 characters in body edited Jul 24 '15 at 14:30 xyz 27033 gold badges2727 silver badges100100 bronze badges 10 deleted 10 characters in body edited Jul 23 '15 at 14:03 xyz 27033 gold badges2727 silver badges100100 bronze badges 9 edited body edited Jul 23 '15 at 13:23 xyz 27033 gold badges2727 silver badges100100 bronze badges 8 added 155 characters in body edited Jul 23 '15 at 12:33 xyz 27033 gold badges2727 silver badges100100 bronze badges 7 added 155 characters in body edited Jul 23 '15 at 12:24 xyz 27033 gold badges2727 silver badges100100 bronze badges 6 edited body edited Jul 23 '15 at 12:13 xyz 27033 gold badges2727 silver badges100100 bronze badges 5 added 222 characters in body edited Jul 23 '15 at 11:56 xyz 27033 gold badges2727 silver badges100100 bronze badges 4 added 166 characters in body edited Jul 23 '15 at 11:17 xyz 27033 gold badges2727 silver badges100100 bronze badges 3 deleted 1 character in body edited Jul 22 '15 at 14:47 xyz 27033 gold badges2727 silver badges100100 bronze badges 2 added 12 characters in body edited Jul 22 '15 at 14:42 xyz 27033 gold badges2727 silver badges100100 bronze badges 1 asked Jul 22 '15 at 14:36 xyz 27033 gold badges2727 silver badges100100 bronze badges