1
$\begingroup$

I have a question in FindRoot of matrix operation equations.

It's my first time use Matrix operation in FindRoot, i have write a simple example, it shows FindSolve can solve Matrix equations.

a = {{1, 2}, {3, 4}}; b = {{1, 3}, {2, 2}};

{c} /. FindRoot[
  c == a.b - IdentityMatrix[2],
  {c, IdentityMatrix[2]}
  ]

Very fast and simple!

Can I write a new expression in FindRoot like

a = {{1, 2}, {3, 4}}; b = {{1, 3}, {2, 2}};
d = {{1, 1}, {3, 3}};
{c} /. FindRoot[
  var == d.b,
  c == a.var - IdentityMatrix[2],
  {c, IdentityMatrix[2]}
  ]

and return c and var, well, var is some function result I want update in FindRoot and used to the equation I want to solve like c == a.var. var isn't need to solve.

Above code have issues. Here is my idea:

a = {{1, 2}, {3, 4}}; b = {{1, 3}, {2, 2}};
d = {{1, 1}, {3, 3}};
{var = d.b, c /. FindRoot[
   c == a.var - IdentityMatrix[2],
   {c, IdentityMatrix[2]}
   ]}

Can I achieve same result in a more compact form?Putting expressions (eg. var) that don't need to solve into FindRoot will cause errors.

$\endgroup$
10
  • $\begingroup$ By the way, can I display the Math symbol more comfortable when I paste the code from notebook to this question? ` [CapitalOmega]` is not easy to reading. $\endgroup$
    – Ben
    Nov 30, 2021 at 15:36
  • $\begingroup$ It might be helpful if you show the matrixequation you try to solve ! Your first example seems to be unclear $\endgroup$ Nov 30, 2021 at 16:02
  • 1
    $\begingroup$ q is not defined when the definition of qE0 refers to its parts. For your simple example, Solve works: c /. Solve[{c == a . b - IdentityMatrix[2], c \[Element] Matrices[{2, 2}]}, c][[1]] $\endgroup$
    – Bob Hanlon
    Nov 30, 2021 at 16:25
  • 1
    $\begingroup$ See Additional useful buttons for our M.SE editor $\endgroup$
    – Bob Hanlon
    Nov 30, 2021 at 16:28
  • 1
    $\begingroup$ Why not a.d.b - IdentityMatrix[2] directively? There no equation in your examples indeed. $\endgroup$
    – cvgmt
    Dec 1, 2021 at 0:16

1 Answer 1

3
$\begingroup$
a = {{1, 2}, {3, 4}}; b = {{1, 3}, {2, 2}};
d = {{1, 1}, {3, 3}};

With[{var = d . b},
 c /. Solve[{c == a . var - IdentityMatrix[2],
     c ∈ Matrices[2]}, c][[1]]]

(* {{20, 35}, {45, 74}} *)

With[{var = d . b},
 c /. FindRoot[c == a . var - IdentityMatrix[2],
   {c, IdentityMatrix[2]}]]

(* {{20., 35.}, {45., 74.}} *)
$\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.