• Home
  • About
    • Cong-Yao Huang's Personal Homepage photo

      Cong-Yao Huang's Personal Homepage

      Moon is a minimal, one column jekyll theme for your blog.

    • Learn More
    • Facebook
    • LinkedIn
    • Instagram
    • Github
  • Posts
    • All Posts
    • All Tags
  • Projects

Homework 2 : Mathematical Expressions

08 Apr 2018

Reading time ~1 minute

1 Solving Linear System

A linear system is given below. please write a program to find its solution, using kramer’s rule.

\[ 3a + 4b + 5c + 6d + 7e =78\] \[ 2b + 3c + 4d + 5e =50 \] \[c + 2d + 3e =25 \] \[2d + 9e =46 \] \[3d + e =19 \]

Note that the solution of a two-variable system is known. For example, Given the system below

\[ ax + by =c \] \[ dx + ey =f \]

The solution is

\[ x = \frac{ce - bf}{ae - bd} \] \[ y = \frac{af - cd}{ae - bd} \]

So you can use the above rule to solve d and e first, and than solve c, b and finally a. After finding the solution, please verify its correctness. That is, substitute the solution found to the left-hand side of the linear system and print out the right-hand side numbers. These numbers should match with those given above. The output of your program should have the following format:

Solution:
  a=x b=xxx c=x d=x e=x
Verification:
  3a+ 4b+ 5c+ 6d+ 7e= 78
      2b+ 3c+ 4d+ 5e= 50
           c+ 2d+ 3e= 25
              2d+ 9e= 46
              3d+  e= 19


cpphwmath Share Tweet +1