Re: does the following code shut down anyone else's kernel? - why?
- To: mathgroup at smc.vnet.net
- Subject: [mg69742] Re: does the following code shut down anyone else's kernel? - why?
- From: dimmechan at yahoo.com
- Date: Fri, 22 Sep 2006 01:04:10 -0400 (EDT)
- References: <eetvtn$b46$1@smc.vnet.net>
As Jens-Peer Kuska told you in another post of you, the problem is you numbers of different precision. The input form of the rep[1] is {H -> 25.`2.3979400086720393*cm, L -> 250.`3.397940008672038*cm, A -> 25.`2.3979400086720393*cm^2, SectionModulus -> 750.`3.8750612633917*cm^4, YoungsModulus -> 70.`1.8450980400142571*Giga*Pascal} If you use exact numbers everything works fine. Apply[(MakeBoxes[#1, _] = #2) & , {{SectionModulus, "I"}, {YoungsModulus, "E"}, {Meter, "m"}, {Newton, "N"}}, {1}]; $Assumptions = (#1 > 0 & ) /@ {Newton, X, Meter, YoungsModulus, SectionModulus}; $UnitList = {{X, Meter}, {F, Newton}, {P, Newton}}; deUnitizeVariablesRep = Apply[#1 -> Times[##1] & , $UnitList, {1}]; unitizeVariablesRep = Apply[#1 -> Divide[##1] & , $UnitList, {1}]; dropSIUnitsRep = {Meter -> 1, Newton -> 1}; numbersToMachinePrecisionRep = x_Real :> SetPrecision[x, MachinePrecision]; cm = Centi*Meter; F[a_] = Subscript[F, a]; rep[1] = {H -> (1/2)*cm, L -> (5/10)*cm, A -> (8/20)*cm^2, SectionModulus -> (4/3)*cm^4, YoungsModulus -> 10*Giga*Pascal}; rep[2] = {Centi -> 1/100, Giga -> 10^9, Pascal -> Newton/Meter^2}; eqn[1] = F[1] == A*YoungsModulus*(1 - Sqrt[1 + (X^2 - 2*H*X)/L^2]); eqn[2] = F[cr] == (Pi^2*YoungsModulus*SectionModulus)/L^2; eqn[3] = F == Min[eqn[1][[2]], eqn[2][[2]]]; eqn[4] = P == ((H - X)*F)/Sqrt[L^2 + X^2 - 2*H*X]; blah[1][X_] = FullSimplify[PiecewiseExpand[eqn[4][[2]] /. Rule @@ eqn[3] /. rep[1] /. rep[2] /. deUnitizeVariablesRep]] 400000*N*(-1 + 200*X + Sign[1 - 200*X]) If you have inexact numbers I believe you should use Rationalize first. Dimitris Anagnostou Î?/Î? Chris Chiasson ÎγÏ?αÏ?ε: > (MakeBoxes[#1,_]=#2)&@@@{{SectionModulus,"I"},{YoungsModulus,"E"},{Meter, > "m"},{Newton,"N"}}; > > $Assumptions=#>0&/@{Newton,X,Meter,YoungsModulus,SectionModulus}; > > $UnitList={{X,Meter},{F,Newton},{P,Newton}}; > > deUnitizeVariablesRep=#\[Rule]Times[##]&@@@$UnitList; > > unitizeVariablesRep=#\[Rule]Divide[##]&@@@$UnitList; > > dropSIUnitsRep={Meter\[Rule]1,Newton\[Rule]1}; > > numbersToMachinePrecisionRep= > x_Real\[RuleDelayed]SetPrecision[x,MachinePrecision]; > > cm=Centi*Meter; > > Format[F[a_]]=Subscript[F,a]; > > rep[1]={H\[Rule]25.0``1 cm,L\[Rule]250.0``1 cm,A\[Rule]25.0``1 cm^2, > SectionModulus\[Rule]750.0``1 cm^4, > YoungsModulus\[Rule]70``0 Giga Pascal}; > > rep[2]={Centi\[Rule]1/100,Giga\[Rule]10^9,Pascal\[Rule]Newton/Meter^2}; > > eqn[1]=F[1]\[Equal]A YoungsModulus (1-Sqrt[1+(X^2-2 H X)/L^2]); > > eqn[2]=F[cr]\[Equal]Pi^2*YoungsModulus*SectionModulus/L^2; > > eqn[3]=F\[Equal]Min[eqn[1][[2]],eqn[2][[2]]]; > > eqn[4]=P\[Equal](H-X)*F/Sqrt[L^2+X^2-2*H*X]; > > blah[1][X_]= > eqn[4][[2]]/.Rule@@eqn[3]/.rep[1]/.rep[2]/.deUnitizeVariablesRep// > PiecewiseExpand//FullSimplify > > > (very quick) result of last command: > > No more memory available. > Mathematica kernel has shut down. > Try quitting other applications and then retry. > > > -- > http://chris.chiasson.name/