Mathematica 9 is now available
Student Support Forum
Student Support Forum: 'function defined in package does't work' topicStudent Support Forum > General > Archives > "function defined in package does't work"

Next Comment >Help | Reply To Topic
Author Comment/Response
06/17/07 1:53pm

I have a problem with some function that is defined in a package. When copied (Copy, Paste) and defined in the Mathematica notebook this function wors good, but when in package it doest evaluate.

The Package:


MyFunction::usage="A usage will apear later"


MyFunction[{xx_, yy_, zz_}, {l_, m_, o_}, {a_, b_, c_}, tt_] :=
Block[{ff, fff, x0, f0, F0, F1, G1, reszta, wolny, przy1, wolnyRed,
przy1Red, t = tt, A1, B1, C1, ax, ay, az},
ff[ax_, ay_, az_] = ax^3;
x0[t_] := a*Exp[-l*t] + Exp[-m*t](b*Cos[o*t] + c*Sin[o*t]);
fff[t_] = ff[x0[t], D[x0[t], t], D[D[x0[t], t], t]];
f0Expand[t_] = Expand[ff[x0[t], D[x0[t], t], D[D[x0[t], t], t]]];
wolny[t_] = f0Expand[t] /. Sin[x_] -> 0;
przy1[t_] = Coefficient[f0Expand[t],Sin[o*t]]*Sin[t*o];
wolnyRed[t_] = TrigReduce[wolny[t]];
przy1Red[t_] = TrigReduce[przy1[t]];
f0[t_] =
f0Expand[t] - (wolny[t] + przy1[t]) + (wolnyRed[t] + przy1Red[t]);
F0[t_] =
Simplify[f0[t]*Exp[l*t] /. {Cos[(n_)*t] :> 0, Sin[(n_)*t] :> 0}];
F1[t_] = Simplify[Coefficient[f0[t], Cos[t*o]]*Exp[m*t] /. Sin[n_] -> 0];
G1[t_] = Simplify[Coefficient[f0[t], Sin[t*o]]*Exp[m*t] /. Cos[n_] -> 0];
{fff[t],f0Expand[t],wolny[t],przy1[t],f0[t], F0[t], F1[t], G1[t],Sin[o*t]}]



Evaluations made by this function are a part of some bigger evaluations, this function was made only to check what happens beetween f[x_, y_, z_] = x^3; and receiveing F0, F1, G1. The result is {ff[t], f0Expand[t], wolny[t], przy1[t], f0[t], F0[t], F1[t], G1[t]} to check the formula of each function.

When evaluated in the package function przy1[t]=0 , G1[t]=0 and F1[t]=0

But when the function is declared in the notebook these functions aren't equal 0

They are correct when function declared in notebook. I have no idea what may cause this difference.

NOTE: Functions should be evaluated with the symbols, not numbers
i.e. if MyFunction[{x,y,z},{l,m,o},{a,b,c},t] then G1[t]=3/4 b^2 c E^{-2 l t} +3 a^2 c E^-2 m t

URL: ,

Subject (listing for 'function defined in package does't work')
Author Date Posted
function defined in package does't work Lucy 06/17/07 1:53pm
Re: function defined in package does't work yehuda ben-s... 06/18/07 11:14am
Re: Re: function defined in package does't work Lucy 06/21/07 07:39am
Re: function defined in package does't work Lucy 06/18/07 11:16am
Next Comment >Help | Reply To Topic