# Converting an equation to the form $ax+by=c$

I have a linear equation that comes as a result of applying orthogonality on a non-homogeneous boundary condition with two unknowns $$C_1$$ and $$C_2$$. Can someone help me to express this equation in the form:

$$a(C_1) + b(C_2)=c\tag A$$

The code to derive the equation is as follows:

T[x_, y_, z_] = (C1* E^(γ z) + C2* E^(-γ z))*Sin[(α x/L) + β]*Sin[(δ y/l) + θ] + Ta;
tc[x_, y_] = E^(-bcy/l)*{tci + (bc/l)*Integrate[E^(bc*s/l)*T[x, s, 0], {s, 0, y}]};
bc1 = (D[T[x, y, z], z] /. z -> 0) == pc (T[x, y, 0] - tc[x, y]);
ortheq1 = Integrate[(bc1[] - bc1[])*Sin[(α x/L) + β]*Sin[(δ y/l) + θ], {x, 0, L}, {y, 0, l}, Assumptions -> {C1 > 0, C2 > 0, L > 0, l > 0, α > 0, β > 0, γ > 0, δ > 0, θ > 0, NTUC > 0, pc > 0, Ta > 0, tci > 0}] == 0;


One can also use the following to derive ortheq1 but it gives a longer result

ortheq1 = Integrate[bc1[]*Sin[(α x/L) + β]*Sin[(δ y/l) + θ], {x, 0, L}, {y, 0, l}] == Integrate[bc1[]*Sin[(α x/L) + β]*Sin[(δ y/l) + θ], {x, 0, L}, {y, 0, l}];


It is the ortheq1 that I would like in the form $$(A)$$.

• If it is a polynomial in C1 and C2 use CoefficientList, else have a look at Select and FreeQ. Also Collect[ortheq1, {C1, C2}] might work. – Natas Jul 2 at 7:37
• Is the appearance of List ({ }) in the definition of tc on purpose? – Natas Jul 2 at 7:55
• @Natas No I just wanted to specify that it is a product of E^(-bcy/l). I should have used (). – Indrasis Mitra Jul 2 at 8:40

Assuming that the appearance of List in the definition of tc is not on purpose, i.e.

T[x_, y_, z_] = (C1* E^(γ z) + C2* E^(-γ z))*Sin[(α x/L) + β]*Sin[(δ y/l) + θ] + Ta;
tc[x_, y_] = E^(-bcy/l)*(tci + (bc/l)*Integrate[E^(bc*s/l)*T[x, s, 0], {s, 0, y}]);
bc1 = (D[T[x, y, z], z] /. z -> 0) == pc (T[x, y, 0] - tc[x, y]);
ortheq1 = Integrate[(bc1[] - bc1[])*Sin[(α x/L) + β]*Sin[(δ y/l) + θ], {x, 0, L}, {y, 0, l}, Assumptions -> {C1 > 0, C2 > 0, L > 0, l > 0, α > 0, β > 0, γ > 0, δ > 0, θ > 0, NTUC > 0, pc > 0, Ta > 0, tci > 0}] == 0;


Then you can use CoefficientList

Module[{coeffs = CoefficientList[Subtract @@ ortheq1, {C1, C2}]},
a[C1_] = coeffs[[2, 1]] C1;
b[C2_] = coeffs[[1, 2]] C2;
c = -coeffs[[1, 1]];
]
(Subtract @@ ortheq1) - (a[C1] + b[C2] - c) // Simplify
(* 0 *)

• Thanks for this. But were you able to get the coefficients a,b,c. When I run your code it throws an error saying Object of unequal length, but the code kep t on running and gave an output. Now should i access $a$ using a[C1] , $b$ as b[C2] ? And how can I access c ? – Indrasis Mitra Jul 2 at 8:42
• Have you run the code I have posted? My definition of tc is different than yours (no List as discussed in the comments above). It should not give an error. You can then simply access a and b as functions and c is a "constant". The last line demonstrates this, where I show that the result is correct. – Natas Jul 2 at 8:59
• Oh I think I just added the second part of your answer to my original code. I will run your version from the start. Thanks again. – Indrasis Mitra Jul 2 at 9:05
• worked perfectly. Thanks, this was really helpful. I tried the whole procedure on my other ortheq2 and was successful there too. – Indrasis Mitra Jul 2 at 10:08
• May I ask, the reason behind the recent edit to the answer where you included Subtract ? Is it supposed to provide improved performance ? – Indrasis Mitra Jul 7 at 8:36