1
$\begingroup$

How to find the constants A1, A2, B1, B2 using linear solve or null space function in Mathematica.

ClearAll;
W1 = A1*Sin[b*x] + B1*Cos[b*x];
W2 = A2*Sin[b*(x - z)] + B2*Cos[b*(x - z)];
(*Boundary condition*)
e1 = W1 /. {x -> 0};
e2 = (D[W1, {x, 1}]) /. {x -> 1};
(*Compatability condition*)
e3 = (W1 /. {x -> z}) - (W2 /. {x -> z});
e4 = ((D[W1, {x}]) /. {x -> z}) - ((D[W2, {x}]) /. {x -> z});
(*Forming matrix*)

R = Normal@
   CoefficientArrays[{e1, e2, e3, e4}, {A1, B1, A2, B2}][[2]];
MatrixForm[R]
LinearSolve[R, {0, 0, 0, 1}]
NullSpace[R]
$\endgroup$

1 Answer 1

1
$\begingroup$

A simple way to solve your equations is:

e1 == W1 /. {x -> 0};
e2 == (D[W1, {x, 1}]) /. {x -> 1};
e3 = (W1 /. {x -> z}) - (W2 /. {x -> z});
e4 = ((D[W1, {x}]) /. {x -> z}) - ((D[W2, {x}]) /. {x -> z});
Solve[{e1, e2, e3, e4} == {0, 0, 0, 1}, {A1, A2, B1, B2}]

enter image description here

However, look at your equations:

TableForm[Transpose[Append[Transpose[R], {0, 0, 0, 1}]], 
 TableHeadings -> {{}, {"A1", "B1", "A2", "B2", "1"}}]

enter image description here

The first row states: B1==0, the second: A1==0, the third: B2==0 and the last: A2==-1/b. Is this really what you want or are the equations erroneous?

$\endgroup$

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.