Re: Problems with Module
- To: mathgroup at smc.vnet.net
- Subject: [mg112075] Re: Problems with Module
- From: "Sjoerd C. de Vries" <sjoerd.c.devries at gmail.com>
- Date: Sun, 29 Aug 2010 02:49:47 -0400 (EDT)
- References: <i57rns$1h4$1@smc.vnet.net>
This slight modification of your code seems to work (even though it
shouldn't according to John).
f[t_] := 4 Sin[t]; g[t_] := 2 Cos[t]; a = 0; b = 2 \[Pi];
DerVectConst[f_, g_, a_, b_] :=
Module[{r, vel, acel, unitario, derivadadeu, du},
r[t_] = {f[t], g[t]};
vel[t_] = r'[t];
acel[t_] = r''[t];
unitario[t_] = acel[t] // Normalize;
du[t_] = acel'[t] // Normalize;
Manipulate[f1 = Graphics[{Thick, Blue, Arrow[{r[t], r[t] +
du[t]}]}];
f2 = Graphics[{Thick, Green, Arrow[{r[t], r[t] + unitario[t]}]}];
g1 = ParametricPlot[r[t], {t, a, b}, AspectRatio -> Automatic,
PlotStyle -> {Thick, Red}];
txt = Graphics[{Text[
Style["\!\(\*OverscriptBox[\"u\", \"^\"]\)", 18,
Bold], (r[t] + 1.1 unitario[t])],
Text[Style[
"\!\(\*SuperscriptBox[OverscriptBox[\"u\", \"^\"], \"\[Prime]\
\"]\)", 18, Bold], (r[t] + 1.1 du[t])]}];
punto = Graphics[{PointSize[.02], Point[r[t]]}];
Show[g1, f1, f2, txt, punto, PlotRange -> All], {t, a, b}]]
DerVectConst[f, g, a, b]
Cheers -- Sjoerd
On Aug 27, 10:07 am, Docente Sergio Miguel Terrazas Porras
<sterr... at uacj.mx> wrote:
> Hi!
>
> The following is a slight modification of a code that works fine. But =
this
> one does not work.
> However, if I empty the list of local variables in Module, Then it wor=
ks!
> Could some of you enlighten me?
>
> f[t_]:=4 Sin[t];g[t_]:=2 Cos[t];a=0;b=2\[Pi];
> DerVectConst[f,g,a,b]
>
> DerVectConst[f_,g_,a_,b_]:=Module[{r,vel,acel,unitario,derivadadeu,d=
u},
> $Assumptions=t\[Element]Reals;
>
> r[t_]={f[t],g[t]};
> vel[t_]=(r^\[Prime])[t];
> acel[t_]=(r^\[DoublePrime])[t];
> unitario[t_]=acel[t]/Norm[acel[t]];
> derivadadeu[t_]=(unitario^\[Prime])[t];
> du[t_]=derivadadeu[t]//FullSimplify;
>
> Manipulate[
>
> f1=Graphics[{Thick,Blue,Arrow[{r[t],r[t]+du[t]}]}];
> f2=Graphics[{Thick,Green,Arrow[{r[t],r[t]+unitario[t]}]}];
> g1=ParametricPlot[r[t],{t,a,b},AspectRatio->Automatic,PlotStyle->{Th=
ick, Red}];
> txt=Graphics[{Text[Style["\!\(\*OverscriptBox[\"u\",
> \"^\"]\)",18,Bold],(r[t]+1.1unitario[t])],Text[Style["\!\(\*Overscript=
Box[\"u\",
> \"^\"]\)^\[Prime]",18,Bold],(r[t]+1.1du[t])]}];
> punto=Graphics[{PointSize[.02],Point[r[t]]}];
> Show[g1,f1,f2,txt,punto,PlotRange->All]
> ,{t,a,b}]
> ]