# Eliminate functions from system of ordinary differential equations

I have the following system of ODE

eq1 = -s^2 ep[x] - cp''[x] + ep''[x] - θp''[x];
eq2 = A cp[x] - B cp''[x] + ep''[x] + C θp''[x];
eq3 = E cp[x] + F cp[x] + s ϵ ep[x] + G ep[x] + s θp[x] + K θp[x] - θp''[x];


A, B, C, E, F, G and K are constants. I need to eliminate both ep[x] and cp[x] from the equations so I solved eq1 and eq2 and got ep[x] and cp[x] by:

 Solve[eq1 == 0, cp[x]] // Simplify
Solve[eq2 == 0, cp[x]] // Simplify
eq3 // Simplify


Then how I can eliminate cp[x] and ep[x] and their derivatives from eq3? Using the substituting /. rule will remove cp[x] and ep[x] but not their derivatives. I should obtain a 6th order differential equation of θp only.

• Do you get this error in a fresh Mathematica session? – J. M. will be back soon Dec 21 '16 at 1:16
• Do not use E as a constant, because it is used in Mathematica as the base of natural logarithms. In general, it is a good idea not to begin symbols with capital letters. Finally, I do not obtain any errors when I run your code. – bbgodfrey Dec 21 '16 at 1:26
• Thank you bbgodfrey. Most of the constants I used in the original file are in Greek letters. did you eliminate the functions cp[x] and ep[x] between eq1 and eq2? Did you got a six order differential equation in θp[x]?? – Essam Dec 21 '16 at 5:57
• I just noticed you had done 2 rollbacks and discarded the format improvement by bbgodfrey, may I ask why? – xzczd Dec 23 '16 at 5:34

This question is actually very similar to this one. It can be solved in the following way:

Eliminate[{eq1 == 0, D[eq1, x, x] == 0, eq2 == 0, D[eq2, x, x] == 0, eq3 == 0,
D[eq3, x, x] == 0, D[eq3, {x, 4}] == 0}, {cp[x], ep[x], cp''[x], ep''[x], cp''''[x],
ep''''[x]}] // Simplify

(*  (s^2 (C (E + F) + B (K + s)) + A (G + K + s (1 + s + ϵ)))
θp''[x] + (-1 + B) θp''''''[x] ==
A s^2 (K + s) θp[x] + (A + E + C E + F + C F + B G + C G - K + B K -
s + B s + B s^2 + B s ϵ + C s ϵ) θp''''[x]  *)


We can also make use of the hidden syntax of Solve. (In many cases it performs better than Eliminate):

Equal @@@ First@
Solve[{eq1 == 0, D[eq1, x, x] == 0, eq2 == 0, D[eq2, x, x] == 0, eq3 == 0,
D[eq3, x, x] == 0, D[eq3, {x, 4}] == 0}, θp[x], {cp[x], ep[x], cp''[x],
ep''[x], cp''''[x], ep''''[x]}] // Simplify

• Thank you xzczd. But the kernel hangs when I try the following: ' eq1 = -s^2 ep[x] - (cp^[Prime][Prime])[x] + (ep^[Prime][Prime])[ x] - ([Theta]p^[Prime][Prime])[x]; eq2 = s [Alpha]2 (1 + s [Tau]) cp[x] - [Alpha]3 ( cp^[Prime][Prime])[x] + (ep^[Prime][Prime])[ x] + [Alpha]1 ([Theta]p^[Prime][Prime])[x]; eq3 = s [Alpha]1 [Epsilon] cp[x] + s^2 [Alpha]1 [Epsilon] [Tau]o cp[x] + s [Epsilon] ep[x] + s^2 [Tau]o ep[x] + s [Theta]p[x] + s^2 [Tau]o [Theta]p[x] - ([Theta]p^[Prime][Prime])[x];' – Essam Dec 23 '16 at 3:00
• @Essam You need to use  rather than ' to create code block in comment. As to the new question, check my edit. – xzczd Dec 23 '16 at 3:54
• Grateful. it is working. Appreciate. But actually I don't know how to type code in comment. What you mean by "rather than". Thank you very much. – Essam Dec 23 '16 at 4:31
• @Essam You've mistakenly used two quotation marks. (This is a quotation mark: ') The code should be between two backticks (This is a backtick: , find it in the left-top corner of your keyboard). I've also used backtick when editing your question, if you still don't know how to use it, check how I edit your question. – xzczd Dec 23 '16 at 5:19
• Like this code ep[x] -> (-s \[Alpha]2 cp[x] - s^2 \[Alpha]2 \[Tau] cp[x] - (cp^\[Prime]\[Prime])[ x] + \[Alpha]3 (cp^\[Prime]\[Prime])[ x] - (\[Theta]p^\[Prime]\[Prime])[ x] - \[Alpha]1 (\[Theta]p^\[Prime]\[Prime])[x])/s^2 – Essam Dec 23 '16 at 6:08