3
$\begingroup$

In these sets of equations and elims, Eliminate is not able to handle nonlinearity, so it does not give an answer for the desired output. Any suggestions? (I excluded a2[t],a2'[t],a2''[t] from elimination list to help it proceed)

equat := {M == T1 + J1*a1''[t],
T2 == J2*a2''[t] + k*(a2[t] - x[t]) + d*(a2'[t] - x'[t]),
a1[t] == a2[t], a1'[t] == a2'[t], a1''[t] == a2''[t], T1 == T2, x[t] == (2*pi/c)*y[t],
x'[t] == (2*pi/c)*y'[t], x''[t] == (2*pi/c)*y''[t],
y[t] == z[t] - p*Cos[U[t]], y'[t] == z'[t] + p*U'[t]*Sin[U[t]],
y''[t] == z''[t] + p*U''[t]*Sin[U[t]] + p*(U'[t]^2)*Cos[U[t]],
U[t] == ArcSin[r[t]/b],
U'[t] == (r'[t])/(b*(1 - ((r[t])^2)/b^2)^(1/2)),
U''[t] == r''[t]/(b*(1 - ((r[t])^2)/(b^2))^(1/2)) +
(r[t]*(r'[t])^2)/(b^3*(1 - ((r[t])^2)/(b^2))^(3/2))}

elim := {x[t], x'[t], x''[t], U[t], U'[t], U''[t], y[t], y'[t],y''[t], T1, T2}

First@Solve[(Eliminate[equat, elim] // FullSimplify) /. a1 -> a2, {a1''[t]}]

it results in empty, while there is an answer manually. And it gives two error messages as:

Eliminate::ifun: Inverse functions are being used by Eliminate, so some solutions may not be found; use Reduce for complete solution information. >>
Solve::fulldim: The solution set contains a full-dimensional component; use Reduce for complete solution information. >>

I should note that I am after an answer for a1''[t] as a function of r[t], r'[t], z[t] and z'[t]. Thanks. I should also mention that I cannot change the format of equation list.

$\endgroup$
2
  • $\begingroup$ Why are you not using DSolve[]? $\endgroup$
    – Feyre
    Commented Feb 14, 2017 at 14:56
  • $\begingroup$ Because Dsolve is for finding a solution for a differential equation. For example having a differential equation for a1''[t] and asking for a solution for a1[t]. In this example I am not after a solution, the aim is to eliminate some variables and find a1''[t] with respect to the rest of the variables. $\endgroup$
    – F R
    Commented Feb 14, 2017 at 15:03

2 Answers 2

3
$\begingroup$

How about

Solve[Eliminate[{M == T1 + J1*a1''[t], 
    T2 == J2*a2''[t] + k*(a2[t] - x[t]) + d*(a2'[t] - x'[t])} //. {a1 -> a2, T1 -> T2, 
    x -> Function[t, (2*pi/c)*y[t]], y -> Function[t, z[t] - p*Cos[U[t]]], 
    U -> Function[t, ArcSin[r[t]/b]]}, T2], a2''[t]]

Update

OK, if equat can't be modified, how about

rule = Cases[equat, (lhs : Alternatives @@ elim) == rhs_ :> (lhs -> rhs)];
Solve[DeleteCases[equat /. a1 -> a2 //. rule, True], a2''[t], 
 Complement[elim, rule[[All, 1]]]]

or a bit simpler:

rule = Rule @@@ Cases[equat, Alternatives @@ elim == _];
Solve[And @@ (equat /. a1 -> a2 //. rule), a2''[t], Complement[elim, rule[[All, 1]]]]
$\endgroup$
12
  • $\begingroup$ Thanks, this works, and I see you excluded some nonlinear equations from list of equations. But I cannot extract those from equations since all of the equations are sent from Matlab to be solved in Mathematica and the solution will be read back in Matlab. So the process will be automatic and I cannot intervene in equations list. I guess there should be a way not to separate equations. $\endgroup$
    – F R
    Commented Feb 14, 2017 at 15:26
  • $\begingroup$ @fr …You mean the equation system is deduced by MATLAB? $\endgroup$
    – xzczd
    Commented Feb 14, 2017 at 15:29
  • $\begingroup$ Yes, my differential equations are produced in Matlab. @xzczd $\endgroup$
    – F R
    Commented Feb 14, 2017 at 15:34
  • $\begingroup$ @fr If the nonlinear equation always have the structure like y[t]=…… i.e. the function or derivative of the function is on the left hand side of the equation, it's possible to extract the equation with program. Is that so? $\endgroup$
    – xzczd
    Commented Feb 14, 2017 at 15:37
  • $\begingroup$ Yes that is true, the format of the functions are always the same. But I cannot predict nonlinear equations and number of them in different systems. This was just very simplified version of equation list that I can have. They are usually much more complex. @xzczd $\endgroup$
    – F R
    Commented Feb 14, 2017 at 15:43
2
$\begingroup$

Another solution is to to not use functions, but just normal variables.

rep = {a1 -> a2, a2''[t] -> appt, a2'[t] -> apt, a2[t] -> at, 
   x''[t] -> xppt, x'[t] -> xpt, x[t] -> xt, y''[t] -> yppt, 
   y'[t] -> ypt, y[t] -> yt, z''[t] -> zppt, z'[t] -> zpt, z[t] -> zt,
    r''[t] -> rppt, r'[t] -> rpt, r[t] -> rt, U''[t] -> uppt, 
   U'[t] -> upt, U[t] -> ut};
revrep = Rest[Reverse /@ rep];

Solve:

FullSimplify@Solve[Quiet@Eliminate[equat/.rep, elim/.rep], appt] /. revrep

{{(a2^′′)[t] -> ( 1/((J1 + J2)^2))(-(J1 + J2) (-M + k a2[t] + d Derivative[1][a2][t]) - ( 2 Sqrt[c^2 d^2 (J1 + J2)^2 p^2 pi^2 (b^2 - r[t]^2) Sin[ U[t]]^2 Derivative[1][r][t]^2])/(c^2 (b^2 - r[t]^2)) + ( 2 (J1 + J2) pi (-k p Cos[U[t]] + k z[t] + d Derivative[1][z][t]))/c)}, {(a2^′′)[t] -> ( 1/((J1 + J2)^2))(-(J1 + J2) (-M + k a2[t] + d Derivative[1][a2][t]) + ( 2 Sqrt[c^2 d^2 (J1 + J2)^2 p^2 pi^2 (b^2 - r[t]^2) Sin[ U[t]]^2 Derivative[1][r][t]^2])/(c^2 (b^2 - r[t]^2)) + ( 2 (J1 + J2) pi (-k p Cos[U[t]] + k z[t] + d Derivative[1][z][t]))/c)}}

$\endgroup$
5
  • $\begingroup$ This works also, thanks. But, you changed the format of equations list completely, I cannot intervene and make any changes in equations, since they are being sent by Matlab. @Feyre $\endgroup$
    – F R
    Commented Feb 14, 2017 at 15:36
  • $\begingroup$ Interesting. I guess you're in v11? It doesn't work in v9. $\endgroup$
    – xzczd
    Commented Feb 14, 2017 at 15:38
  • $\begingroup$ Mine is 10.4 @xzczd $\endgroup$
    – F R
    Commented Feb 14, 2017 at 15:56
  • $\begingroup$ @FR I edited my question to prevent the changes to the lists. $\endgroup$
    – Feyre
    Commented Feb 14, 2017 at 16:36
  • $\begingroup$ @xzczd Both 10.4 and 11, I'm actually surprised this doesn't work on 9. $\endgroup$
    – Feyre
    Commented Feb 14, 2017 at 16:36

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.