Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3950588
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:37:45+00:00 2026-05-20T01:37:45+00:00

I obtained the folloiwng equation (as an example): {2 w11 + 3 w21 ==

  • 0

I obtained the folloiwng equation (as an example):

{2 w11 + 3 w21 == 2 w12, w11 == 4 w12 + 3 w22, w11 + 2 w21 + w22 == 0,
  2 w12 + w21 + 2 w22 == 0}

And I want to determine w11, w12, w21, w22. However, simply do the following:

Solve[{3 w11 + 2 w21 == 5 w11 + 3 w12, w11 + w21 == 5 w21 + 3 w22, 
  3 w12 + 2 w22 == -2 w11 - w12, w12 + w22 == -2 w21 - w22}, {w11, 
  w12, w21, w22}]

Because the system of equations is under-determined. I have one thought, i.e. using matrix algebra. But I need to automatically group those coefficients in front of w11, w12, w21, w22 into a matrix (list of lists) then go from there. But I am not sure how to manipulate these equations easily to generate such a matrix. Please help, or if you have better ideas, please share too.

Many thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T01:37:46+00:00Added an answer on May 20, 2026 at 1:37 am

    Here are your equations and variables:

    vars = {w11, w12, w21, w22};
    eqs = {2 w11 + 3 w21 == 2 w12, w11 == 4 w12 + 3 w22, 
       w11 + 2 w21 + w22 == 0, 2 w12 + w21 + 2 w22 == 0};
    

    Here is the matrix:

    In[48]:= matrix =  Transpose[ eqs /. Equal :> Subtract /. 
        Map[Thread[vars -> #] &, IdentityMatrix[Length[vars]]]]
    
    Out[48]= {{2, -2, 3, 0}, {1, -4, 0, -3}, {1, 0, 2, 1}, {0, 2, 1, 2}}
    

    EDIT:

    The same works for your second group of equations:

    In[49]:= eqs = {3 w11 + 2 w21 == 5 w11 + 3 w12,  w11 + w21 == 5 w21 + 3 w22, 
      3 w12 + 2 w22 == -2 w11 - w12,  w12 + w22 == -2 w21 - w22};   
    
    In[50]:= matrix = Transpose[ eqs /. Equal :> Subtract /. 
        Map[Thread[vars -> #] &, IdentityMatrix[Length[vars]]]]
    
    Out[50]= {{-2, -3, 2, 0}, {1, 0, -4, -3}, {2, 4, 0, 2}, {0, 1, 2, 2}}
    

    EDIT:

    Expanding on the solution, upon request. First, how it works: the idea is to first bring all variables to the left, which is achieved by replacing the equals operator with subtraction:

    In[69]:= eqs = {3 w11 + 2 w21 == 5 w11 + 3 w12,  w11 + w21 == 5 w21 + 3 w22, 
         3 w12 + 2 w22 == -2 w11 - w12,  w12 + w22 == -2 w21 - w22};
    

    In[70]:= eqs /. Equal :> Subtract

    Out[70]= {-2 w11 – 3 w12 + 2 w21, w11 – 4 w21 – 3 w22, 2 w11 + 4 w12 + 2 w22, w12 + 2 w21 + 2 w22}

    The rules are constructed so that for any group of rules, only one variable is set to 1, and the rest to 0:

     In[71]:= Map[Thread[vars -> #] &, IdentityMatrix[Length[vars]]]
    
     Out[71]= {{w11 -> 1, w12 -> 0, w21 -> 0, w22 -> 0}, {w11 -> 0, w12 -> 1, w21 -> 0, w22 -> 0}, 
            {w11 -> 0, w12 -> 0, w21 -> 1, w22 -> 0}, {w11 -> 0, w12 -> 0, w21 -> 0, w22 -> 1}}
    

    This allows to compute the coefficients:

    In[72]:= eqs /. Equal :> Subtract /. Map[Thread[vars -> #] &, IdentityMatrix[Length[vars]]]
    
    Out[72]= {{-2, 1, 2, 0}, {-3, 0, 4, 1}, {2, -4, 0, 2}, {0, -3, 2, 2}}
    

    Upon inspecting how the rules work, it is easy to see that we need to apply Transpose to the result.

    Now, your second request requires more work:

    In[53]:= eqs = {3 w11 + 2 w12 == 5 w11 + 3 w21 + a, w11 + w12 == 5 w12 + 3 w22 - c, 
       3 w21 + 2 w22 + b == a - 2 w11 - w21, w21 + w22 == f - 2 w12 - w22};
    
    In[55]:= modifiedEqs = With[{alts = Alternatives @@ vars},
       eqs //. {lhs_ == HoldPattern[Plus[left___, x_, right___]] /; !FreeQ[x, alts] :> 
                        lhs - x == left + right,
                HoldPattern[Plus[left___, x_, right___] == rhs_] /; FreeQ[x, alts] :> 
               (left + right == rhs - x)}]
    
    Out[55]= {-2 w11 + 2 w12 - 3 w21 == a, w11 - 4 w12 - 3 w22 == -c,  
         2 w11 + 4 w21 + 2 w22 == a - b,   2 w12 + w21 + 2 w22 == f}
    
    In[68]:= matrix = {Transpose[# /. (lhs_ == rhs_) :> lhs /. 
        Map[Thread[vars -> #] &, IdentityMatrix[Length[vars]]]], #[[All,2]]} &[modifiedEqs]
    
    Out[68]= {{{-2, 2, -3, 0}, {1, -4, 0, -3}, {2, 0, 4, 2}, {0, 2, 1,  2}}, {a, -c, a - b, f}}
    

    The main difference is that we need an extra step to separate the constants and bring them to the r.h.s. You may find it more useful to figure out the details of how this works yourself.

    Edit:

    Yes, I forgot to mention: to understand the solution, you should know what happens when you apply rules in nested lists – in this case, each list of rules inside a larger lists results in a transformed copy of an expression, for example:

    In[73]:= {a, b, c} /. {{a -> 1}, {b -> 1}, {c -> 1}}
    
    Out[73]= {{1, b, c}, {a, 1, c}, {a, b, 1}}
    

    HTH

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a detailed explanation for results obtained on evaluating the following on REPL.
This has to be obtained from a remote machine. The following query works not
While learning Prolog, I'm trying to solve the following problem, using accumulators: Write a
Given two interface references obtained from different sources. Is there a programmatic way to
I'm using a java.util.concurrent.ExecutorService that I obtained by calling Executors.newSingleThreadExecutor() . This ExecutorService can
I have a custom control that shows a value obtained from the database (the
After I get response from httpwebrequest, I'd like the cookies obtained to save for
I have a bit of a problem. I am trying to do the following
I have the following problem. My main activity consists of a ListView populated with
I have the following code, which is the basis for pagination in a larger

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.