3
$\begingroup$

As another example of Eliminating some variables in a list of differential equations and solve them for specific defined variables, I consider to have some nonlinear equations plus some linear equations.

Solve[Eliminate[{a[t] == b1 + c*x1''[t], b2 == e*(x2[t] - y[t])
+ f*(x2'[t] - y'[t]) + d*x2''[t], g*y''[t] + e*(y[t] - x2[t])
+ f*(y'[t] - x2'[t]) + m*L == 0,
n*z''[t] == m - R, a1[t] == b3 + c1*alfa1''[t],
b4 - d1*L1*Sin[alfa2[t]] - n2*x3''[t]*L1*Sin[alfa2[t]] == r1*alfa2''[t],
d1 == M1*x4''[t], b1 == b2, y[t] == z[t]/L, 
y'[t] == z'[t]/L, y''[t] == z''[t]/L, x2[t] == x1[t],
x2'[t] == x1'[t], x2''[t] == x1''[t], alfa1[t] == alfa2[t], 
alfa1'[t] == alfa2'[t], alfa1''[t] == alfa2''[t], x3[t] == z[t], 
x3'[t] == z'[t], x3''[t] == z''[t],
x4[t] == x3[t] - L*Cos[alfa2[t]], x4'[t] == x3'[t] + L1*alfa2'[t]*Sin[alfa2[t]], x4''[t] == x3''[t] + L1*alfa2''[t]*Sin [alfa2[t]] + 
 L1*(alfa2'[t])^2*Cos[alfa2[t]],
b3 == b4}, {b1, b2, x2[t], x2'[t], x2''[t], y[t],
y'[t], y''[t], m, x3[t], d1, b3, b4, x3'[t],
x3''[t], alfa2[t], alfa2'[t], alfa2''[t], x4[t], x4'[t], 
x4''[t]}], {x1''[t], z''[t], alfa1''[t]}]

Mathematica complains when I am including the nonlinear part

Eliminate::ifun: Inverse functions are being used by Eliminate, so some
solutions may not be found; use Reduce for complete solution information. >>
Solve::svars: Equations may not give solutions for all "solve" variables. >>

and it just give an answer of

{{x1''[t] -> -((-L a[t] + e L x1[t] - e z[t] + f L x1'[t] -
  f z'[t])/((c + d) L)), z''[t] -> -((L^2 R - e L x1[t] + e z[t] -
f L x1'[t] +f z'[t])/(g + L^2 n))}}

and there is no answer for alfa1''[t], I am wondering is that because of using Sin[] and Cos[]? Is it possible for Mathematica to recognize Sin^(-1) as ArcSin in complicated equations?

$\endgroup$

1 Answer 1

5
$\begingroup$

Eliminate seems to be able to handle some simple equations with transcendental functions, like Sin, but sometimes it will not work with them, as you can see in the following minimal examples

Eliminate[{y == z, x + Sin[y] == 5}, y]
Eliminate[{x + Cos[y]*Sin[y] == 5, y == z}, y]

enter image description here

For your specific case, I am going to leave the elimination of alfa2 out (I commented it out in the following code)

el = Eliminate[
    {
     a[t] == b1 + c*x1''[t]
     , b2 == e*(x2[t] - y[t]) + f*(x2'[t] - y'[t]) + d*x2''[t]
     , g*y''[t] + e*(y[t] - x2[t]) + f*(y'[t] - x2'[t]) + m*L == 0
     , n*z''[t] == m - R
     , a1[t] == b3 + c1*alfa1''[t]
     , b4 - d1*L1*Sin[alfa2[t]] - n2*x3''[t]*L1*Sin[alfa2[t]] == 
      r1*alfa2''[t]
     , d1 == M1*x4''[t]
     , b1 == b2
     , y[t] == z[t]/L
     , y'[t] == z'[t]/L
     , y''[t] == z''[t]/L
     , x2[t] == x1[t]
     , x2'[t] == x1'[t]
     , x2''[t] == x1''[t]
     , alfa1[t] == alfa2[t]
     , alfa1'[t] == alfa2'[t]
     , alfa1''[t] == alfa2''[t], x3[t] == z[t]
     , x3'[t] == z'[t]
     , x3''[t] == z''[t]
     , x4[t] == x3[t] - L*Cos[alfa2[t]]
     , x4'[t] == x3'[t] + L1*alfa2'[t]*Sin[alfa2[t]]
     , x4''[t] == 
      x3''[t] + L1*alfa2''[t]*Sin[alfa2[t]] + 
       L1*(alfa2'[t])^2*Cos[alfa2[t]]
     , b3 == b4
     }
    , {
     b1
     , b2
     , x2[t], x2'[t], x2''[t]
     , y[t], y'[t], y''[t]
     , m
     , x3[t]
     , d1, b3, b4
     , x3'[t], x3''[t]
     (*,alfa2[t],alfa2'[t],alfa2''[t]*)
     , x4[t], x4'[t], x4''[t]
     }
    ] // FullSimplify;
Do[Print[{i, el[[i]]}], {i, Length@el}]

enter image description here

The second equation is your non-linear equation with the transcendental functions. Mathematica is not able to handle them, as far as I have tried only with Eliminate[el[[2 ;; 3]], alfa2[t]]. But what you can do in your specific example is replace alfa2 with alfa1

elnew = el /. alfa2 -> alfa1;
Do[Print[{i, elnew[[i]]}], {i, Length@elnew}]

enter image description here

and solve for the variables you are interested in

sol = First@Solve[elnew, {x1''[t], z''[t], alfa1''[t]}]

enter image description here

EDIT

In the documentation, it is written that Eliminate works mainly with polynomial equations and may be able to handle simple transcendental functions

enter image description here

enter image description here

but as you could see in my second example at the beginning of this answer, it might fail for more complex equations. You can try to turn on the option InverseFunctions (see options of Eliminate) but this will not help you in your specific case. You have a product of Sin and Cos in your non-linear part. Consider the following code

eqs1 = {
   a1[t] == Sin[y[t]]*Cos[y[t]]
   , y[t] == z[t]
   };
eqs2 = {
   a[t] == x'[t]
   , a1[t] == Sin[y[t]]*Cos[y[t]]
   , y[t] == z[t]
   };
Eliminate[eqs1, y[t]]
Eliminate[eqs2, y[t]]
Eliminate[eqs2, y[t], InverseFunctions -> True]
Eliminate[eqs2, y[t], InverseFunctions -> False]

enter image description here

In the first output you can see that Eliminate is not able to handle the complex equations eqs1 since it can not eliminate y[t]. In the second output you can notice that Eliminate actually ignores everything it can not handle, but gives you a warning. In the third output I told it to use inverse functions but as it is not able to handle it, it still seems to ignore it. In the fourth output, it gives you nothing.

So bottom line from my side, it seems like Eliminate will ignore everything it can not handle by prefering polynomial expressions.

Note: I don't think this is a bug, but a property of Eliminate by working on polynomial expressions. If something is not expressable as a polynomial, then it just can not be done. I don't know how difficult it is to expand the functionalities of Eliminate to more complex functions, but that is something you would have to ask a mathematician and people from Wolfram.

$\endgroup$
7
  • $\begingroup$ Thanks, the problem is that I cannot break down the code to few lines, and solve linear and nonlinear equations separately, I am sending all equations from matlab to mathematica, so I should be able to eliminate and solve all equations in one line coding. @Mauricio Lobos $\endgroup$
    – F R
    Commented Nov 18, 2016 at 12:56
  • $\begingroup$ yea, ok I guess one line coding would be this way: First@Solve[(Eliminate[equation, elims] // FullSimplify) /. alfa2 -> alfa1, {x1''[t], z''[t], alfa1''[t]}] $\endgroup$
    – F R
    Commented Nov 18, 2016 at 13:27
  • $\begingroup$ but, it would be nice to know the reason of not getting result by including alfa2 and its derivatives as elimination @Mauricio Lobos $\endgroup$
    – F R
    Commented Nov 18, 2016 at 13:31
  • 1
    $\begingroup$ The hidden syntax of Solve together with MaxExtraConditions helps in this case, try Solve[{y == z, x + Sin[y] == 5}, x, {y}, MaxExtraConditions -> Infinity] Solve[{x + Cos[y]*Sin[y] == 5, y == z}, x, {y}, MaxExtraConditions -> Infinity] Solve[eqs1, {a1[t]}, {y[t]}, MaxExtraConditions -> Infinity] Solve[eqs2, {a1[t], x'[t]}, {y[t]}, MaxExtraConditions -> Infinity] $\endgroup$
    – xzczd
    Commented Feb 14, 2017 at 9:30
  • 1
    $\begingroup$ Method -> Reduce also helps: Solve[{y == z, x + Sin[y] == 5}, x, {y}, Method -> Reduce] $\endgroup$
    – xzczd
    Commented Feb 14, 2017 at 11:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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