MathGroup Archive 2004

[Date Index] [Thread Index] [Author Index]

Search the Archive

what's wrong about my package?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg45391] what's wrong about my package?
  • From: "ANDY" <wangzhengyao at hotmail.com>
  • Date: Tue, 6 Jan 2004 04:16:47 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

hello,
i want to build a package about computer aided Geometirc design for me!

____________________________________
......
Begin["`Private`"]
Bernstein[i_, n_, v_] := Binomial[n, i]*(1 - v)^(n - i)*v^i

BezierCurve[pts : {{_, _} ..} | {{_, _, _} ..}, v_] :=
    Module[{n = Length[pts] - 1},
      Simplify[
        Table[Bernstein[i, n, v], {i, 0, n}].pts]
      ];

BernsteinPolynomial[fx_, x_,n_] :=Module[{},Sum[Replace[fx,
x ->i/n]*Bernstein[i, n, t], {i, 0, n}]];

End[]
EndPackage[]
___________________________________

 i want use BernsteinPolynomial to compute the Bernstein Polynomial of the
function fx (f(x)),but when i use it in mathematica,there are something
wrong:


In[28]:=
\!\(BernsteinPolynomial[x\^2 + x, x, 8]\)

Out[28]=
\!\(\((1 - CAGD`Private`t)\)\^8\ \((x + x\^2)\) + 8\ \((1 -
CAGD`Private`t)\)\
\^7\ CAGD`Private`t\ \((x + x\^2)\) + 28\ \((1 - CAGD`Private`t)\)\^6\ \
CAGD`Private`t\^2\ \((x + x\^2)\) + 56\ \((1 - CAGD`Private`t)\)\^5\ \
CAGD`Private`t\^3\ \((x + x\^2)\) + 70\ \((1 - CAGD`Private`t)\)\^4\ \
CAGD`Private`t\^4\ \((x + x\^2)\) + 56\ \((1 - CAGD`Private`t)\)\^3\ \
CAGD`Private`t\^5\ \((x + x\^2)\) + 28\ \((1 - CAGD`Private`t)\)\^2\ \
CAGD`Private`t\^6\ \((x + x\^2)\) + 8\ \((1 - CAGD`Private`t)\)\ \
CAGD`Private`t\^7\ \((x + x\^2)\) + CAGD`Private`t\^8\ \((x + x\^2)\)\)


Why?
how to correct it??
thank you?


Andy
2004.1.5





  • Prev by Date: Re: Transpose matrix does not work when MatrixForm is used, why?
  • Next by Date: Using loops inside NMaximize
  • Previous by thread: Re: Transpose matrix does not work when MatrixForm is used, why?
  • Next by thread: RE: what's wrong about my package?