On May 12, 2009, at 8:01 AM, Josephine Ame wrote: > Hi > > I am trying to solve for numerical values but get symbolic answers. > What am I doing wrong? > > My code: > > var('L,E,g') > w=2*pi.n() > u=1/12 > c_0 = 0.1 > j = 20 > de = 0.25 > al = list() > AR=range (2,20,1) > AR.reverse() > print AR > z=(g+u)^2 + j^2*w^2 -c_0*exp(-g*L)*(cos(j*w*L)*(g+u)-j*w*sin > (j*w*L))/c_0*exp(-g*L)*(cos(j*w*L)* (g+u)-j*w*sin(j*w*L)) > for k in AR: > P=c_0*exp(-g*L)*(cos(k*w*L)*(g+u)-k*w*sin(k*w*L))/((g+u)^2+ > k^2*w^2) > Z = 1/P - 1 - (e^2/4)/z > z = Z > for E in range (0.00,2.00,de): > for L in range (0,5,1): > b=((g+u)-c_0*exp^(-g*L))/c_0*exp^(-g*L) > solve([b==E^2/2*z],g) > al.append(g) > > The result: > > [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2] > [g == 1/60] > [g == (6 - 5*exp^g)/(60*exp^g)] > [g == (6 - 5*exp^(2*g))/(60*exp^(2*g))] > [g == (6 - 5*exp^(3*g))/(60*exp^(3*g))]
Use the "find root" command: sage: solve(sin(x) - x == .1) [x == (10*sin(x) - 1)/10] sage: find_root(sin(x) - x == .1, -1, 1) -0.85375015664086573 Type find_root? for help - Robert --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---