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 8652037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:12:52+00:00 2026-06-12T14:12:52+00:00

A, B and C are matrices. A*B = C Now I want to do

  • 0

A, B and C are matrices.

A*B = C

Now I want to do a reverse i.e calculate A using B and C. How do I do it?
Matlab says that B should be a square matrices to calculate its inverse.

  • 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-06-12T14:12:53+00:00Added an answer on June 12, 2026 at 2:12 pm

    IF a unique solution exists, then one might best use pinv to find it. Using the example posed by schwarz…

    A = [2 3 4];
    B = [11 11 11; 12 12 12; 13 13 13];
    C = A*B;
    
    Ahat = C*pinv(B)
    Ahat =
            2.788       3.0415       3.2949
    

    The problem is, B is singular. So there are potentially infinitely many solutions.

    B = magic(3)
    B =
         8     1     6
         3     5     7
         4     9     2
    A = [2 3 4];
    C = A*B
    C =
        41    53    41
    
    Ahat = C*pinv(B)
    Ahat =
                2            3            4
    
    Ahat = C/B
    Ahat =
         2     3     4
    

    See that pinv and slash both yield the same solution, since B is non-singular AND it is well conditioned.

    But how about if we try something that is less well conditioned? In this next xample, I’ll use a matrix that is not really that bad.

    >> A = [2 3 4];
    >> B = [1 1 1;1 2 3;2 3 4.00001]
    B =
        1              1              1
        1              2              3
        2              3        4.00001
    

    Well, it has a pretty large condition number, but this matrix is not what I’d call numerically singular.

    cond(B)
    ans =
               2865128.4655819
    
    C = A*B
    C =
                            13                        20                  27.00004
    

    Lets try several different solutions now.

    format long g
    Ahat1 = C*pinv(B)
    Ahat1 =
         2     3     4
    

    pinv did quite well.

    Ahat2 = C/B
    Ahat2 =
              2.00000000017764          3.00000000017764          3.99999999982236
    
    Ahat3 = C*inv(B)
    Ahat3 =
              1.99999999953434          2.99999999953434          4.00000000046566
    

    slash and inv were both not bad, although clearly worse in this case. The pinv solution seems a bit more stable for this problem.

    We might as well throw a QR factorization at this too. Use a pivoted solution for the best stability. Note that when your system is nearly singular, we will still expect problems.

    [Q,R,P] = qr(B);
    

    You can see the problem by inspecting R. The last diagonal element is tiny compared to the remainder. This will cause problems in the solution, amplifying any noise.

    R
    R =
             -5.09902735824196         -2.35339392337313         -3.72620671848107
                             0         0.679365175314723         0.339681455393392
                             0                         0     -2.88675134520189e-06
    

    The QR factors have the property that Q*R*P’ = B. So we can solve for A here as:

    Ahat4 = ((C*P)/R)*Q'
    Ahat4 =
              2.00000000076851           3.0000000007685           3.9999999992315
    

    Note that I’ve arranged the parens to be as efficient as possible, since MATLAB will use the property of R as a triangular matrix to simply do a backsolve. We don’t want MATLAB to be factorizing a matrix that is already factored.

    But now lets look at one posed by vahid:

    Ahat5 = C*B'*(inv(B*B'))
    Ahat5 =
                  1.9970703125               2.998046875              4.0029296875
    

    However, the solution posed by vahid was simply terrible. Do NOT use this last form. PLEASE. There is a reason why people tell you not to do so, or they should have told you that! Yes, I know there are a group of people who do not know the mathematics involved, and they keep spreading it. You may even find it in some uninformed textbooks.

    The nice thing about pinv is it works for any matrix, singular or not. If a solution exists, it will find one. If the solution is unique, it will work. If the solution is not unique, then well, what do you expect?

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

Sidebar

Related Questions

from a simulation problem, I want to calculate complex square matrices on the order
I have a R script I'm running now that is currently using 3 correlated
I have two matrices that I want to apply a function to, by rows:
I am adding two matrices (or possibly many) in ActionScript 3.0. Now my problem
I have two matrices a and b (with equal number of columns). I want
Basically, what is the best way to go about storing and using dense matrices
I have 150 32 by 48 matrices of values that represent color intensities from
[I'm splitting a population number into different matrices and want to test my code
I'm trying to make an application with flash builder that performs operations on square
I have two expressions in MATLAB that represent a 365x24 matrix. The first expression

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.