2
$\begingroup$

I have the equations

eq1=(a[3] - a[4]) \[Psi] . \[Xi] + (a[1] + 2 a[2]) \[Psi] . \[Phi]
eq2=2 (a[3] - a[4]) \[Psi] . \[Xi]
eq3=(a[1] + a[2] + a[3] + a[4]) \[Psi] . \[Phi]

Question: How do I make Mathematica to solve for the coefficients a[1], a[2], a[3] and a[4] the system of equations given by eq1=0, eq2=0 and eq3=0?

Elaborating on the question:

When equating any of the above equations to zero, each term should vanish separately, so that eq1=0 gives a[3] - a[4]=0 and a[1] + 2 a[2]=0.

For example, I could solve manually the system eq1=0, eq2=0 and eq3=0 in terms of a[1], a[2] and a[3]

Solve[{a[3] - a[4]==0,a[1] + 2 a[2]==0,a[1] + a[2] + a[3] + a[4]==0},{a[1],a[2],a[3]}]

To obtain

{{a[1] -> -4a[4], a[2] -> 2a[4], a[3] -> a[4]}}

But I want Mathematica to do the solving step for me and I don't want to specify for what variables it should solve for, It doesn't matter if It solves for a[1], a[3], a[4] as a function of a[2] instead. In my original code I can have more than three independent equations for the coefficients (these are the equations given by imposing eq1=0, eq2=0 and eq3=0) and the number of coefficients is not limited to four. This makes manually solving not feasible.

$\endgroup$

1 Answer 1

6
$\begingroup$
$Version

(* "13.0.0 for Mac OS X x86 (64-bit) (December 3, 2021)" *)

Clear["Global`*"]

eq1 = (a[3] - a[4]) ψ . ξ + (a[1] + 2 a[2]) ψ . ϕ;
eq2 = 2 (a[3] - a[4]) ψ . ξ;
eq3 = (a[1] + a[2] + a[3] + a[4]) ψ . ϕ;

var = Variables[Level[{eq1, eq2, eq3}, {-1}]]

(* {ξ, ϕ, ψ} *)

sol = Select[Solve[{eq1, eq2, eq3} == 0], 
  FreeQ[#, Alternatives @@ var] &]

(* {{a[1] -> -4 a[3], a[2] -> 2 a[3], a[4] -> a[3]}} *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.