People, please let me understand this! Let me give you my example so that you can help me recognizing where is my mistake
I've this function: G_igr_d ( <class 'sage.calculus.calculus.SymbolicArithmetic'> ) (2*Iin*rCb/Lf + 2*Vb/Lf)*(s*rCf*(1/(Cf*rCf + Cf*Rs) + s)/((rCf + Rs)*(s*((1/(Cf*rCf + Cf*Rs) + s)*(2*rCf*rQ/(Lf*rCf + Lf*Rs) + 2*Rs*rQ/(Lf*rCf + Lf*Rs) + rCf*rLf/(Lf*rCf + Lf*Rs) + Rs*rLf/(Lf*rCf + Lf*Rs) + 2*Iin*rCb*rCf/(Lf*rCf + Lf*Rs) + Rs*rCf/(Lf*rCf + Lf*Rs) + Rs*2*Iin*rCb/(Lf*rCf + Lf*Rs) + s) + Rs^2/((Cf*rCf + Cf*Rs)*(Lf*rCf + Lf*Rs))) - (2*Duty/Cb - 1/Cb)*(1/Lf - 2*Duty/Lf)*(1/(Cf*rCf + Cf*Rs) + s))) + Rs*s/((rCf + Rs)*(Cf*rCf + Cf*Rs)*(s*((1/(Cf*rCf + Cf*Rs) + s)*(2*rCf*rQ/(Lf*rCf + Lf*Rs) + 2*Rs*rQ/(Lf*rCf + Lf*Rs) + rCf*rLf/(Lf*rCf + Lf*Rs) + Rs*rLf/(Lf*rCf + Lf*Rs) + 2*Iin*rCb*rCf/(Lf*rCf + Lf*Rs) + Rs*rCf/(Lf*rCf + Lf*Rs) + Rs*2*Iin*rCb/(Lf*rCf + Lf*Rs) + s) + Rs^2/((Cf*rCf + Cf*Rs)*(Lf*rCf + Lf*Rs))) - (2*Duty/Cb - 1/Cb)*(1/Lf - 2*Duty/Lf)*(1/(Cf*rCf + Cf*Rs) + s)))) - 2*ILf*((2*Duty/Lf - 1/Lf)*rCf*(1/(Cf*rCf + Cf*Rs) + s)/((rCf + Rs)*(s*((1/(Cf*rCf + Cf*Rs) + s)*(2*rCf*rQ/(Lf*rCf + Lf*Rs) + 2*Rs*rQ/(Lf*rCf + Lf*Rs) + rCf*rLf/(Lf*rCf + Lf*Rs) + Rs*rLf/(Lf*rCf + Lf*Rs) + 2*Iin*rCb*rCf/(Lf*rCf + Lf*Rs) + Rs*rCf/(Lf*rCf + Lf*Rs) + Rs*2*Iin*rCb/(Lf*rCf + Lf*Rs) + s) + Rs^2/((Cf*rCf + Cf*Rs)*(Lf*rCf + Lf*Rs))) - (2*Duty/Cb - 1/Cb)*(1/Lf - 2*Duty/Lf)*(1/(Cf*rCf + Cf*Rs) + s))) - (1/Lf - 2*Duty/Lf)*Rs/((rCf + Rs)*(Cf*rCf + Cf*Rs)*(s*((1/ (Cf*rCf + Cf*Rs) + s)*(2*rCf*rQ/(Lf*rCf + Lf*Rs) + 2*Rs*rQ/(Lf*rCf + Lf*Rs) + rCf*rLf/(Lf*rCf + Lf*Rs) + Rs*rLf/(Lf*rCf + Lf*Rs) + 2*Iin*rCb*rCf/(Lf*rCf + Lf*Rs) + Rs*rCf/(Lf*rCf + Lf*Rs) + Rs*2*Iin*rCb/(Lf*rCf + Lf*Rs) + s) + Rs^2/((Cf*rCf + Cf*Rs)*(Lf*rCf + Lf*Rs))) - (2*Duty/Cb - 1/Cb)*(1/Lf - 2*Duty/Lf)*(1/(Cf*rCf + Cf*Rs) + s))))/Cb and params = [ rCf == 1*m_, Cf == 4.7*u_, rCb == 10*m_, Cb == 22*u_, rLf == 1*m_, Lf == 1.65*m_, rQ == 10*m_, Iin == 300/400, Rs == 0.2, Vrms == 220, Vgr_pk == 220*sqrt(2), ] paramsd = { "rCf" : 1*m_, "Cf" :4.7*u_, "rCb" :10*m_, "Cb" :22*u_, "rLf" :1*m_, "Lf" :1.65*m_, "rQ" :10*m_, "Iin" :300/400, "Rs" :0.2, "Vrms" :220, "Vgr_pk" :220*sqrt(2), } NOTE: the m_, u_, etc. are just the multipliers previously defined in a .sage file (m_ = 1e-3, u_ = 1e-6, etc.) They are exactly the same subset If I do time dizSub = G_igr_d.subs(paramsd) CPU time: 14.40 s, Wall time: 31.44 s time G_id = subList(G_igr_d,params) CPU time: 1.17 s, Wall time: 5.59 s Why is it so? Please note that this has been done with SAGE : 'SAGE Version 3.1.2, Release Date: 2008-09-19' I've tried out this at home (but with simpler expressions) with the latest SAGE, and the subs with the dictionary actually was faster. Thank you Maurizio On Feb 21, 4:48 pm, Robert Bradshaw <rober...@math.washington.edu> wrote: > On Feb 21, 2009, at 3:30 AM, Maurizio wrote: > > > > > That was the way I used to do it when I discovered the solution_dict > > param. > > > So, I started using the dictionaries to do substitution even in > > complex expressions... The result was to wait so much time! > > > On the contrary, I found that the subs(expr, x=<value>) was SOOOO much > > faster (are the dictionaries so slow to deal with?). > > > So, I implemented a subList function, where I can pass an expression, > > and a list of substitution, in the very same way that the solve() > > function returns the results. > > > So, now I put all my subsets of numerical values in list like this: > > set = [x == 10, y == 20, z == 30, ...] > > and do the substitution like this: > > result = subList(expr, set) > > > Within the function, I just iterate the subs(expr, x = <value>) on the > > number of list elements. > > > This seems to me much faster than using dictionaries, especially for > > complex expressions. > > If this is the case, this is clearly a bug. > > - Robert --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---