Re: solving equations
- To: mathgroup at smc.vnet.net
- Subject: [mg105914] Re: solving equations
- From: Bill Rowe <readnews at sbcglobal.net>
- Date: Fri, 25 Dec 2009 00:34:25 -0500 (EST)
On 12/24/09 at 8:58 PM, arbiadr at gmail.com (Maria Davis) wrote: >My file a.txt contains these equations: >x == Csource.receiverRole.RT >Csource.receiverRole.RT == Csource.sendRole.RT + Csource.TT >Csource.sendRole.RT == A.inputPort.RT >A.inputPort.RT == A.outputPort.RT + A.PT >A.ouputPort.RT == C.receiverRole.RT >C.receiverRole.RT == C.sendRole.RT + C.TT >C.sendRole.RT == B.inputPort.RT >B.inputPort.RT == B.outputPort.RT + B.PT >B.ouputPort.RT == Csink.receiverRole.RT >Csink.receiverRole.RT == Csink.sendRole.RT + Csink.TT >Csink.sendRole.RT == DataSink.inputPort.RT >DataSink.inputPort.RT == 0 >Csource.TT == 0 >Csink.TT == 0 >C.TT == 0.5 >A.PT == 2 >B.PT == 1.5 >For solving these equations for x , I tried to omit the caracter >'.', because, as certain have adviced, Mathematica interprets the >dot as a product. I replaced the dot by a letter 'a' (for trial) >using a code given by dr DanW: >dots = ReadList["a.txt", Record, RecordSeparators -> {}] >nodots = StringReplace[dots[[1]], StringExpression >[pre:LetterCharacter, ".", post:LetterCharacter] :> StringJoin[pre, >"a", post]] >Solve[ReadList[StringToStream[nodots], Expression], {x}] >I have verified that for example a varible name: >Csource.receiverRole.RT has changed to CsourceareceiverRoleaRT. But >the resolution of the system returns a wrong value: {{x -> >CsourceasendRoleaRT}} But it is not wrong. Your very first equation states x is equal to this value. In fact, you have several equations that do nothing other than rename a variable. Why? Also all of the equations are only simple additions and you have defined several of the terms to be zero. What is it you want to do? Why needlessly enter what are effectively redundant equations? Why introduce x in the first place if what you want to do is solve for Csource.receiverRole.RT? If I omit the dots to make this valid Mathematica syntax and omit the first equation and do In[1]:= Solve[{CsourcereceiverRoleRT == CsourcesendRoleRT + CsourceTT= , CsourcesendRoleRT == AinputPortRT, AinputPortRT == AoutputPortRT + APT, AouputPortRT == CreceiverRoleRT, CreceiverRoleRT == CsendRoleRT + CTT, CsendRoleRT == BinputPortR= T, BinputPortRT == BoutputPortRT + BPT, BouputPortRT == CsinkreceiverRoleRT, CsinkreceiverRoleRT == CsinksendRoleRT + CsinkTT, CsinksendRoleRT == DataSinkinputPortRT, DataSinkinputPortRT == 0, CsourceTT == 0, CsinkTT == 0, CTT == 0.5, APT == 2, BPT == 1.5}, CsourcereceiverRoleRT] Out[1]= {{CsourcereceiverRoleRT->AinputPortRT}} But I suspect this isn't the result you want. >Do you know if Mathematica has constraints on the length of the >variable name (it must not exeed a certain value)? As far as I know there is no limit to the length of variable names and I very much doubt this is the problem. Basically, it looks like you have a lot of redundancy in you set of equations and don't care for the way Mathematica is reducing the set of equations.