[Date Index]
[Thread Index]
[Author Index]
Re: Forgets Variables?
*To*: mathgroup at smc.vnet.net
*Subject*: [mg97237] Re: Forgets Variables?
*From*: Ktota <NuKtoBi at gmail.com>
*Date*: Mon, 9 Mar 2009 01:02:58 -0500 (EST)
*References*: <200903070738.CAA16926@smc.vnet.net> <gp0830$l48$1@smc.vnet.net>
Thank you for your help Raffy and Bob, i'll try your suggestions and
report here again. This model evolved over time.. i think i will have
also to spend to optimize it as Bob suggests.. his suggestions are
very nice... i'm busy learning Mathematica it seems to be a very
helpfull tool ;).
Kind Regards,
Ktota
On 8 Mrz., 10:53, DrMajorBob <btre... at austin.rr.com> wrote:
> I can't get the first statement to execute (in the time I'm willing to =
> wait). If you gave us the values of maxX, eqTime, v, lifetime27SA, et
> cetera, we'd waste a lot less time guessing what your problem might be.
>
> If you want help, ALWAYS start us off where you are. Don't make us
> flounder around where you've already been. Because, of course, why should=
> we?
>
> That said, I'd start by simplifying until the code is understandable, at =
> which point the error will reveal itself. For instance, this:
>
> If[v*(tsum - lifetime35S - eqTime) < 4000,
> v*(tsum - lifetime35S - eqTime), 4000]
>
> is equivalent to the simpler (and faster)
>
> Min[v*(tsum - lifetime35S - eqTime), 4000]
>
> Similarly, this expression:
>
> If[v*(tsum - eqTime) < 4000, Max[v*(tsum - eqTime), 0], 4000]
>
> is equivalent to
>
> Max[0, Min[v*(tsum - eqTime), 4000]]
>
> Next, it's easy to see that
>
> If[v*(tsum2 - eqTime) < 4000,
> Sum[Max[v*(tsum - eqTime), 0], {tsum, tsum2 - lifetime27SANTC + 1,
> tsum2}],
> Sum[Max[0, Min[v*(tsum - eqTime), 4000]], {tsum,
> tsum2 - lifetime27SANTC + 1, tsum2}]]
>
> is equivalent to
>
> Clear[q]
> q[ts_] := v*(ts - eqTime);
> If[q@tsum2 < 4000,
> Sum[Max[q@tsum, 0], {tsum, tsum2 - lifetime27SANTC + 1, tsum2}],
> Sum[Max[0, Min[q@tsum, 4000]], {tsum, tsum2 - lifetime27SANTC + 1,
> tsum2}]]
>
> and that's equivalent to (since the Sums have the same limits):
>
> Clear[q]
> q[ts_] := v*(ts - eqTime);
> Sum[If[q@tsum2 < 4000, Max[q@tsum, 0],
> Max[0, Min[q@tsum, 4000]]], {tsum, tsum2 - lifetime27SANTC + 1,
> tsum2}]
>
> Similarly, the first If statement:
>
> If[v*(tsum2 - lifetime35S - eqTime) < 4000,
> Sum[Max[v*(tsum - lifetime35S - eqTime), 0], {tsum,
> tsum2 - lifetime27SA + 1, tsum2}],
> Sum[Min[v*(tsum - lifetime35S - eqTime), 4000], {tsum,
> tsum2 - lifetime27SA + 1, tsum2}]]
>
> is equivalent to
>
> Clear[q]
> q[ts_] := v*(ts - lifetime35S - eqTime);
> Sum[If[q@tsum2 < 4000, Max[q@tsum, 0], Min[q@tsum, 4000]], {tsum,
> tsum2 - lifetime27SA + 1, tsum2}]
>
> Combining both tricks into one reduces the original expression to:
>
> Clear[q]
> q[life_][ts_] := v (ts - life - eqTime)
> callNormValue =
> 60/maxX Sum[
> Sum[If[q[lifetime35S]@tsum2 < 4000, Max[q[lifetime35S]@tsum, 0=
],
> Min[q[lifetime35S]@tsum, 4000]], {tsum,
> tsum2 - lifetime27SA + 1, tsum2}]*(1 - P) +
> Sum[If[q[0]@tsum2 < 4000, Max[q[0]@tsum, 0],
> Max[0, Min[q[0]@tsum, 4000]]], {tsum,
> tsum2 - lifetime27SANTC + 1, tsum2}]*P, {tsum2, 60, t2=
, 60}];
>
> That still won't evaluate without values for all the parameters, but
> you're the only one that knows those, or even knows what ranges they migh=
t
> lie in.
>
> One trick you MIGHT pull, however, is this:
>
> Clear[q]
> q[life_][ts_] := v (ts - life - eqTime)
> callNormValue =
> 60/maxX sum[
> sum[If[q[lifetime35S]@tsum2 < 4000, Max[q[lifetime35S]@tsum, 0=
],
> Min[q[lifetime35S]@tsum, 4000]], {tsum,
> tsum2 - lifetime27SA + 1, tsum2}]*(1 - P) +
> sum[If[q[0]@tsum2 < 4000, Max[q[0]@tsum, 0],
> Max[0, Min[q[0]@tsum, 4000]]], {tsum,
> tsum2 - lifetime27SANTC + 1, tsum2}]*P, {tsum2, 60, t2=
, 60}];
>
> (Now the statement executes.)
>
> callNormValue /. {lifetime35S -> 17, P -> 0.7, t2 -> maxX, sum -> Sum}
>
> (The other parameters still need values, but those could be added to the =
> rule list.)
>
> Bobby
>
>
>
>
>
> On Sat, 07 Mar 2009 01:38:46 -0600, Ktota <NuKt... at gmail.com> wrote:
> > Hi there,
>
> > i have the following procedure:
>
> > callNormValue = (Sum[
> > If[v*(tsum2 - lifetime35S - eqTime) < 4000,
> > Sum[Max[v*(tsum - lifetime35S - eqTime), 0], {tsum,
> > tsum2 - lifetime27SA + 1, tsum2, 1}],
> > Sum[If[v*(tsum - lifetime35S - eqTime) < 4000,
> > v*(tsum - lifetime35S - eqTime), 4000], {tsum,
> > tsum2 - lifetime27SA + 1, tsum2, 1}]]*(1 - P) +
> > If[v*(tsum2 - eqTime) < 4000,
> > Sum[Max[v*(tsum - eqTime), 0], {tsum,
> > tsum2 - lifetime27SANTC + 1, tsum2, 1}],
> > Sum[If[v*(tsum - eqTime) < 4000, Max[v*(tsum - eqTime),=
0],
> > 4000], {tsum, tsum2 - lifetime27SANTC + 1, tsum2, 1=
}]]*
> > P, {tsum2, 60, t2, 60}])/(maxX/60);
>
> > i call it with:
> > callNormValue /. {lifetime35S -> 17, P -> 0.7, t2 -> maxX}
>
> > it gives me a proper result, but as soon i change t2 to maxX in the
> > first expression (where i do the sums) it doesn't evaluate the the
> > procedure anymore (maxX has a global value already set). I have
> > actually quite a lot of trouble to hand over values to this
> > procedure.. and i have no idea why it doesn't work.
>
> > (for except lifetime35S,P and t2 all the variables have a set value)
>
> > thank you,
>
> > Ktota
>
> --
> DrMajor... at bigfoot.com
Prev by Date:
**Re: Mathematica 7.0.1.0 and some General Comments**
Next by Date:
**Re: Maximum in a list**
Previous by thread:
**Re: Forgets Variables?**
Next by thread:
**Re: Forgets Variables?**
| |