0
$\begingroup$

I have a few nonlinear differential equations and some variables that I need them to be eliminated when I am calculating differential equations based on other 3 variables, but I can just get an answer for 2 variables. Can somebody please notify me about my mistake? what am I doing wrong? Here are my equations and elims:

equations := {C1c1*Iin1[t] == ToutBeta1 + FIoutBeta1''[t]*C1c6, 
  TinBeta2 == 
   C2c3*FIinBeta2''[t] + C2c1*(FIinBeta2[t] - thetaB2[t]) + 
    C2c6*(FIinBeta2'[t] - thetaB2'[t]), 
  C2c4*thetaB2''[t] + C2c1*(thetaB2[t] - FIinBeta2[t]) + 
    C2c6*(thetaB2'[t] - FIinBeta2'[t]) + Ff2*C2c2/(2*pi) == 0, 
  C2c5*YoutY2''[t] == Ff2 - FoutY2, 
  thetaB2[t] == (2*pi/C2c2)*YoutY2[t], 
  thetaB2'[t] == (2*pi/C2c2)*YoutY2'[t], 
  thetaB2''[t] == (2*pi/C2c2)*YoutY2''[t], 
  C3c1*Iin3[t] == ToutGamma3 + FIoutGamma3''[t]*C3c6, 
  FoutY3 + C3c3*YoutY3''[t] == FinY3, YoutY3''[t] == YinY3''[t], 
  TinGamma4 - C4c1*Sin[FIinGamma4[t]]*FoutY4 - 
    C4c1*Cos[FIinGamma4[t]]*FoutX4 - 
    1/2*C4c1*Sin[FIinGamma4[t]]*C4c4*YinY4''[t] == 
   C4c3*FIinGamma4''[t], 
  YinY4[t] == YoutY4[t] - C4c1*Cos[FIinGamma4[t]], 
  YinY4'[t] == YoutY4'[t] + C4c1*FinGamma'[t]*Sin[FIinGamma4[t]], 
  YinY4''[t] == 
   YoutY4''[t] + C4c1*FIinGamma4''[t]*Sin[FIinGamma4[t]] + 
    C4c1*((FIinGamma4'[t])^2)*Cos[FIinGamma4[t]], 
  FIinGamma4[t] == ArcSin[YoutX4[t]/C4c1], 
  FIinGamma4'[
    t] == (YoutX4'[t])/(C4c1*(1 - ((YoutX4[t])^2)/C4c1^2)^(1/2)), 
  FIinGamma4''[t] == 
   YoutX4''[t]/(C4c1*(1 - ((YoutX4[t])^2)/(C4c1^2))^(1/2)) + (YoutX4[
        t]*(YoutX4'[t])^2)/(C4c1^3*(1 - ((YoutX4[t])^2)/(C4c1^2))^(3/
          2)), FoutX4 + C4c4*(YoutX4''[t] + YinX4''[t])/2 == FinX4, 
  FoutY4 + C4c4*(YoutY4''[t] + YinY4''[t])/2 == FinY4, 
  C5c4*YinX5''[t] == FinX5 - FoutX5, YinX5''[t] == YoutX5''[t], 
  C5c5*YinY5''[t] == FinY5 - FoutY5, YinY5''[t] == YoutY5''[t], 
  ToutBeta1 == TinBeta2, FIoutBeta1[t] == FIinBeta2[t], 
  FIoutBeta1'[t] == FIinBeta2'[t], FIoutBeta1''[t] == FIinBeta2''[t], 
  FoutY2 == FinY3, YoutY2[t] == YinY3[t], YoutY2'[t] == YinY3'[t], 
  YoutY2''[t] == YinY3''[t], ToutGamma3 == TinGamma4, FoutX3 == FinX4,
   FoutY3 == FinY4, FIoutGamma3[t] == FIinGamma4[t], 
  FIoutAlpha3'[t] == FIinAlpha4'[t], FIoutBeta3'[t] == FIinBeta4'[t], 
  FIoutGamma3'[t] == FIinGamma4'[t], 
  FIoutGamma3''[t] == FIinGamma4''[t], YoutX3[t] == YinX4[t], 
  YoutY3[t] == YinY4[t], YoutX3'[t] == YinX4'[t], 
  YoutY3'[t] == YinY4'[t], YoutX3''[t] == YinX4''[t], FoutX4 == FinX5,
   FoutY4 == FinY5, YoutX4[t] == YinX5[t], YoutY4[t] == YinY5[t], 
  YoutX4'[t] == YinX5'[t], YoutY4'[t] == YinY5'[t], 
  YoutX4''[t] == YinX5''[t], YoutY4''[t] == YinY5''[t], FoutX5 == 0, 
  FoutY5 == 0}

my elims:

elims := {ToutBeta1, TinBeta2, FIinBeta2[t], YoutY2[t], FoutY2,
FIinBeta2'[t], FIinBeta2''[t], YoutY2'[t], YoutY2''[t], ToutGamma3,
YinX3[t], YinY3[t], YoutY3[t], FinX3, FinY3, FoutX3, FoutY3, 
YinX3'[t], YinY3'[t], YinX3''[t], YinY3''[t], YoutX3'[t],
YoutY3'[t], YoutX3''[t], YoutY3''[t], TinGamma4, YinX4[t], YinY4[t],
FinX4, FinY4, FoutX4, FoutY4, YinX4'[t], YinY4'[t], YinX4''[t],
YinY4''[t], YinX5[t], YinY5[t], YoutX5[t], YoutY5[t], FinX5, FinY5,
FoutX5, FoutY5, YinX5'[t], YinY5'[t], YinX5''[t], YinY5''[t], 
YoutX5'[t], YoutY5'[t], YoutX5''[t], YoutY5''[t], Ff2, thetaB2[t],
thetaB2'[t], thetaB2''[t], FIoutGamma3[t], FIoutGamma3'[t],
FIoutGamma3''[t]}

and I use: dynamic := {FIoutBeta1''[t], YoutX4''[t], YoutY4''[t]}

with: Equal @@@ Flatten[First@Solve[(Eliminate[equations, elims] // FullSimplify), dynamic]] I can just get answer for YoutX4 and YoutY4, I can't get an answer for FIoutBeta1!

$\endgroup$
7
  • 3
    $\begingroup$ The system of equations obtained after Eliminate[equations, elims], does not have FIoutBeta1[t]. That is the reason why it doesn't return any solution for FIoutBeta1[t]. $\endgroup$ Feb 13, 2017 at 11:59
  • 1
    $\begingroup$ @AnjanKumar but I am not eliminating FIoutBeta1, so why it is disappeared? $\endgroup$
    – F R
    Feb 13, 2017 at 12:03
  • $\begingroup$ @Feyre Thanks but that's not the problem, since when I am removing it again there is no answer! although that is a constraint and I cannot remove it. $\endgroup$
    – F R
    Feb 13, 2017 at 12:22
  • 2
    $\begingroup$ I'm voting to close this question as off-topic because it's too localized and unlikely to help future vistors. $\endgroup$
    – xzczd
    Feb 13, 2017 at 12:23
  • $\begingroup$ @xzczd if you have any solution for it, first suggest it and then vote! $\endgroup$
    – F R
    Feb 13, 2017 at 12:26

2 Answers 2

2
$\begingroup$

OK, let me offer a free debugging service to contend this question is off topic in a more effective way. First, consider a simpler problem:

Why doesn't

Solve[Eliminate[{a == e, b == 1}, a], {b, e}]

give answer for e?

The answer is obvious: if a is eliminated from the equation set, e will disappear, too. e isn't independent with a. If such a question is posted in this site, I'm sure it'll be considered as a simple mistake.

OP has essentially asked the same question.

Let's eliminate the variables in elims one by one:

midlst = elims;
i = 0;
dat = FoldList[(midlst = DeleteCases[midlst, #2]; 
     Equal @@@ Flatten@Solve[#, Flatten@{dynamic, midlst}, {#2}]) &, equations, elims];

I've made use of the hidden syntax of Solve because it's more efficient. Then, check when FIoutBeta1''[t] disappears:

! FreeQ[#, FIoutBeta1''[t]] & /@ dat
(* …, True, False, False, False, False} *)

Fifth to last equation set in dat is suspicious. Which of them involve FIoutBeta1''[t]? 3rd of them:

! FreeQ[#, FIoutBeta1''[t]] & /@ dat[[-5]]
(* {False, False, True, False, False, False} *)

Which of them involve the variable to be eliminated next? 3rd of them!:

! FreeQ[#, elims[[-4]]] & /@ dat[[-5]]
(* {False, False, True, False, False, False} *)

Then FIoutBeta1''[t] disappears together with elims[[-4]], just as what happened at beginning of this answer. (Notice if the order of elims differs, the variable tied with FIoutBeta1''[t] will probably different, too. ) FIoutBeta1''[t] is not independent with one or more variables in elims.

That's the reason for my voting to close as off-topic, haven't yet decided the specific reason, "simple mistake", "too localized", "asking for free debugging service", probably one of them.

$\endgroup$
7
  • $\begingroup$ obviously you did not get that these equations are dynamic equations of a model based system, so eliminating each of the variables which are linked to FIoutBeta1 won't cause a problem, that's what you do when you solve differential equations manually! @xzczd also, the simple example you mentioned is irrelevant to this question! since in my case 'e' is a connective variable between two or three equations. $\endgroup$
    – F R
    Feb 13, 2017 at 14:45
  • $\begingroup$ @FaribaRahimi What I do with my code is exactly what one does when eliminating the variable from the equation set manually. Notice in your case FIoutBeta1''[t] and elims are not simply "linked" or "connected", they are dependent! You're essentially claiming "Solve[Eliminate[{b + a - 1 == e, 2 e + b == 1 + 2 a}, a], {b, e}] should give answer for e, because in this case e is a connective variable between two equations." $\endgroup$
    – xzczd
    Feb 13, 2017 at 15:03
  • $\begingroup$ I am afraid that again you are mistaken, the similarity of your simple case to my equations would be to eliminate 'e' and find a result for 'a' or 'b' as an example. @xzczd $\endgroup$
    – F R
    Feb 13, 2017 at 15:10
  • $\begingroup$ "the similarity of your simple case to my equations would be to eliminate 'e' and find a result for 'a' or 'b' as an example." Are you sure? Have you tried it yourself? Solve[Eliminate[{b + a - 1 == e, 2 e + b == 1 + 2 a}, e], {a}] @FaribaRahimi $\endgroup$
    – xzczd
    Feb 13, 2017 at 15:25
  • 1
    $\begingroup$ @FaribaRahimi First of all, it is quite hard to read the system of equations/odes because of the weird Youk2 and others...Besides, The issue is with the system. Eliminate does what it suppose to do. $\endgroup$
    – zhk
    Feb 13, 2017 at 15:34
-1
$\begingroup$

I investigated my own code deeply. Apparently, there is a problem with Elimination command that cannot eliminate some variables which are directly related to nonlinear equations or inside nonlinear equations. In my equations I am eliminating thetaB2[t] which is equal to (2*pi/C2c2)*YoutY2[t], and YoutY2[t]==YinY3[t], YinY3[t]==YoutY4[t] and finally, YinY4[t] == YoutY4[t] - C4c1*Cos[FIinGamma4[t]] and FIinGamma4[t] == ArcSin[YoutX4[t]/C4c1]. Eliminate works mainly with polynomial equations and may be able to handle simple transcendental functions. Apparently, Eliminate ignores everything it can not handle. So whenever I am removing thetaB2[t] I get an answer for FIoutBeta1''[t] too, but it's not the desired answer which I am after.

enter image description here

$\endgroup$
3
  • $\begingroup$ -1. Mathematica does have bugs and limitations, but doubting about its capability should always be the last thing to do. The current situation is (1) Eliminate and Solve are both frequently used i.e. heavily tested function, and have been proved to be robust. (2) So long nobody seems to observe similar problem in this site. (Just search "[bugs] [equation-solving]" here. ) (3) Your equation set is a mess involving 54 equation and you give no evidence that FIoutBeta1''[t] is independent with variables inside elims. Apparently, your words are lame. $\endgroup$
    – xzczd
    Feb 14, 2017 at 8:57
  • $\begingroup$ try to be polite if you do not have enough information, just search and read a little bit about Elimination, it is obviously mentioned about limitations of it! @xzczd and try to test this example with removing thetaB, then you might understand the problem of it! In case that you don't have any new information to it, just ignore this question and skip it, instead of arguing the wrong things! $\endgroup$
    – F R
    Feb 14, 2017 at 13:02
  • $\begingroup$ With all due respect, if there's anybody being impolite in this post, it's you. I know Eliminate and Solve have their limitations, what I'm argued with my answer and comments is, your problem isn't caused by those limitations, while so long you give no effective disproof. You're essentially saying "there's nothing wrong with my system, it's a flaw of Eliminate" without giving any credible evidence over and over. (A equation system formed by 54 equations with no explanation for how you deduce it won't convince anybody. ) $\endgroup$
    – xzczd
    Feb 14, 2017 at 13:17

Not the answer you're looking for? Browse other questions tagged or ask your own question.