14 replaced http://mathematica.stackexchange.com/ with https://mathematica.stackexchange.com/
source | link

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
    Bounty Ended with Mr.Wizard's answer chosen by xyz
13 deleted 1 character in body
source | link

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
12 added 2 characters in body; edited tags
source | link
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
    Bounty Started worth 100 reputation by xyz
11 added 1270 characters in body
source | link
10 deleted 10 characters in body
source | link
9 edited body
source | link
8 added 155 characters in body
source | link
7 added 155 characters in body
source | link
6 edited body
source | link
5 added 222 characters in body
source | link
4 added 166 characters in body
source | link
3 deleted 1 character in body
source | link
2 added 12 characters in body
source | link
1
source | link