2
$\begingroup$

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[[1]] - bc1[[2]])*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[[1]]*Sin[(α x/L) + β]*Sin[(δ y/l) + θ], {x, 0, L}, {y, 0, l}] == Integrate[bc1[[2]]*Sin[(α x/L) + β]*Sin[(δ y/l) + θ], {x, 0, L}, {y, 0, l}];

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

$\endgroup$
3
  • $\begingroup$ 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. $\endgroup$
    – Natas
    Jul 2, 2020 at 7:37
  • $\begingroup$ Is the appearance of List ({ }) in the definition of tc on purpose? $\endgroup$
    – Natas
    Jul 2, 2020 at 7:55
  • $\begingroup$ @Natas No I just wanted to specify that it is a product of E^(-bcy/l). I should have used (). $\endgroup$
    – Avrana
    Jul 2, 2020 at 8:40

1 Answer 1

3
$\begingroup$

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[[1]] - bc1[[2]])*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 *)
$\endgroup$
7
  • $\begingroup$ 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 ? $\endgroup$
    – Avrana
    Jul 2, 2020 at 8:42
  • $\begingroup$ 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. $\endgroup$
    – Natas
    Jul 2, 2020 at 8:59
  • $\begingroup$ 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. $\endgroup$
    – Avrana
    Jul 2, 2020 at 9:05
  • $\begingroup$ worked perfectly. Thanks, this was really helpful. I tried the whole procedure on my other ortheq2 and was successful there too. $\endgroup$
    – Avrana
    Jul 2, 2020 at 10:08
  • $\begingroup$ May I ask, the reason behind the recent edit to the answer where you included Subtract ? Is it supposed to provide improved performance ? $\endgroup$
    – Avrana
    Jul 7, 2020 at 8:36

Your Answer

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