FW: Solving Nonlinear Equations
- To: mathgroup at smc.vnet.net
- Subject: [mg80548] FW: [mg80515] Solving Nonlinear Equations
- From: "Biyana, D. (Dugmore)" <DugmoreB at Nedbank.co.za>
- Date: Sun, 26 Aug 2007 02:56:31 -0400 (EDT)
Let me fill the missing gaps on my question: m1= Sum[w[[i]]S[[i]]Exp[(r-delta[[i]]),{i,Length[S]}]; m2= Sum[w[[i]]w[[j]]S[[i]]S[[j]]Exp[(2r-delta[[i]]-delta[[j]]+rho[[i,j]]sig[[i]] sig[j]])T,{i,Length[S]},{j,Length[S]}]; m3= Sum[w[[i]]w[[j]]w[[k]]S[[i]]S[[j]]S[[k]]Exp[(3r-delta[[i]]-d[[j]]-delta[[k]] +rho[[i,j]]sig[[i]]sig[j]]+rho[[i,k]]sig[[i]]sig[k]]+rho[[j,k]]sig[[j]]sig[k ]])T,{i,Length[S]},{j,Length[S]},{k,Length[S]}]; m4= Sum[w[[i]]w[[j]]w[[k]]w[[l]]S[[i]]S[[j]]S[[k]]S[[l]]Exp[(4r-delta[[i]]-d[[j] ]-delta[[k]]-delta[[l]]+rho[[i,j]]sig[[i]]sig[j]]+rho[[i,k]]sig[[i]]sig[k]]+ rho[[j,k]]sig[[j]]sig[k]]+rho[[i,l]]sig[[i]]sig[l]]+rho[[j,l]]sig[[j]]sig[l] ]+rho[[k,l]]sig[[k]]sig[l]])T,{i,Length[S]},{j,Length[S]},{k,Length[S]},{l,L ength[S]}]; With r=0.063;T=1;S=Table[1,{i,7}];w={0.1,0.15,0.15,0.1,0.05,0.2,0.25};delta={0.01 69,0.0136,0.0239,0.0362,0.0192,0.0081,0.0166};sig={0.1155,0.1453,0.2068,0.14 62,0.1799,0.1559,0.1568};rho={{1,0.35,0.1,0.27,0.04,0.17,0.71},{0.35,1.,0.39 ,0.27,0.5,-0.08,0.15},{0.1,0.39,1.,0.53,0.7,-0.23,0.9},{0.27,0.27,0.53,1.,0. 46,-0.22,0.32},{0.04,0.5,0.7,0.46,1.,-0.29,0.13},{0.17,-0.08,-0.23,-0.22,-0. 29,1.,-0.03},{0.71,0.15,0.09,0.32,0.13,-0.03,1.}}; FindRoot[{m1==c-d*Exp[1/(2*b^2)]*Sinh[a/b], > m2==c^2+(c^2/2)(Exp[2/b^2]Cosh[2a/b]-1)-2c*d*Exp[1/(2b^2)]*Sinh[a/b], > m3==c^3-3*c^3*d*Exp[1/(2b^2)]*Sinh[a/b],+3*c(d^2/2))*(Exp[2/b^2]Cosh[2a/b]-1 > )+(d^3/4)(3*Exp[1/(2b^2)]Sinh[a/b]-Exp[9/(2b^2)]Sinh[3a/b]), > m4==c^4-4(c^3)d*Exp[1/(2b^2)]*Sinh[a/b]+3(c*d)^2))*(Exp[2/b^2]Cosh[2a/b]-1)+ > (d^3/4)+c*d^3(3*Exp[1/(2b^2)]Sinh[a/b]-Exp[9/(2b^2)]Sinh[3a/b])+(d^4/8)(Exp[ > 8/(b^2)]*Cosh > [4a/b]-4*Exp[2/(b^2)]Cosh[2a/b]),{{a,-1.},{b,1.},{c,1.},{d,0.05}}] gives {a->12.1929,b->9.05339,c->0.33727,d->0.393214}. I know that these are coorrect roots because the results of the underlying problem tally with what I expect. I must emphasise that the initial values of a, b, c, and d were a product of trial and error. However, when I change inputs to T=5;r=0;S={100,100,100,100};w={0.25,0.25,0.25,0.25};delta={0,0,0,0};sig={0.4 ,0.4,0.4, 0.4};rho={{1.0,0.5,0.5,0.5},{0.5,1.0,0.5,0.5},{0.5,0.5,1.0,0.5},{0.5,0.5,0.5 ,1.0}} I just can't seem be "lucky" to hit the jackpot initial values. My main point is how do I get input initial values without relying on trial and error, or what is the alternative approach? P.S. (I'm aware about the potential confusion that C, and D are likely to cause on the system as global variables, I apologise for not using the actual variables used) Regards MD Biyana -----Original Message----- From: DrMajorBob [mailto:drmajorbob at bigfoot.com] Sent: 24 August 2007 09:46 AM To: Biyana, D. (Dugmore); mathgroup at smc.vnet.net Subject: [mg80548] Re: [mg80515] Solving Nonlinear Equations That's not a legal syntax (mismatched brackets, etc.), and if it were, you didn't give the initial values or the values of m1, m2, m3, and m4, so... what can we do? In addition, C and D are system-defined symbols. FindRoot probably uses D to take derivatives, so you're just asking for trouble with variable names like that. I never, never, EVER start one of my own variables with a capital; that makes it obvious whose symbol it is. Bobby On Fri, 24 Aug 2007 00:56:16 -0500, Biyana, D. (Dugmore) <DugmoreB at Nedbank.co.za> wrote: > > I'm using Mathematica V6.0.1 and I have a system of 4 nonlinear equations > which I'm trying to solve using FindRoot: > FindRoot[{m1==C-D*Exp[1/(2*B^2)]*Sinh[A/B], > m2==C^2+(D^2/2)(Exp[2/B^2]Cosh[2A/B]-1)-2C*D*Exp[1/(2B^2)]*Sinh[A/B], > m3==C^3-3*C^3*D*Exp[1/(2B^2)]*Sinh[A/B],+3*C(D^2/2))*(Exp[2/B^2]Cosh[2A/B]-1 > )+(D^3/4)(3*Exp[1/(2B^2)]Sinh[A/B]-Exp[9/(2B^2)]Sinh[3A/B]), > m4==C^4-4(C^3)D*Exp[1/(2B^2)]*Sinh[A/B]+3(C*D)^2))*(Exp[2/B^2]Cosh[2A/B]-1)+ > (D^3/4)+C*D^3(3*Exp[1/(2B^2)]Sinh[A/B]-Exp[9/(2B^2)]Sinh[3A/B])+(D^4/8)(Exp[ > 8/(B^2)]*Cosh > [4A/B]-4*Exp[2/(B^2)]Cosh[2A/B]),{{A,initA},{B,initB},{C,initC},{D,initD}}] > I get the message " FindRoot::cvmit : Failed to converge to the requested > accuracy..." which I suspect is a result of initial values of A, B,C, > and D. > What trick can one use to get accepatble initial values? > MD Biyana > > ******************** > Nedbank Limited Reg No 1951/000009/06. The following link displays the > names of the Nedbank Board of Directors and Company Secretary. > [ http://www.nedbank.co.za/terms/DirectorsNedbank.htm ] > This email is confidential and is intended for the addressee only. The > following link will take you to Nedbank's legal notice. > [ http://www.nedbank.co.za/terms/EmailDisclaimer.htm ] > ******************** > > > -- DrMajorBob at bigfoot.com ******************** Nedbank Limited Reg No 1951/000009/06. The following link displays the names of the Nedbank Board of Directors and Company Secretary. [ http://www.nedbank.co.za/terms/DirectorsNedbank.htm ] This email is confidential and is intended for the addressee only. The following link will take you to Nedbank's legal notice. [ http://www.nedbank.co.za/terms/EmailDisclaimer.htm ] ********************