{"id":211,"date":"2017-12-27T03:31:00","date_gmt":"2017-12-27T02:31:00","guid":{"rendered":"https:\/\/kindsonthegenius.com\/blog\/2017\/12\/27\/program-to-solve-simultaneous-equation-in-python\/"},"modified":"2020-08-22T11:06:18","modified_gmt":"2020-08-22T09:06:18","slug":"program-to-solve-simultaneous-equation-in-python","status":"publish","type":"post","link":"https:\/\/kindsonthegenius.com\/blog\/program-to-solve-simultaneous-equation-in-python\/","title":{"rendered":"Program to Solve Simultaneous Equation in Python"},"content":{"rendered":"<div style=\"color: #555555; font-size: 18px; line-height: 30px; text-align: justify;\">\n<div style=\"font-family: 'segoe ui';\">For all lovers of the Python Programming Language, I would like to share a program to solve simultaneous equation(system of linear equation) in Python. I have written the program, so you just have to copy and paste in your Python IDE enjoy running it.<\/p>\n<div style=\"clear: both; text-align: center;\"><a href=\"https:\/\/4.bp.blogspot.com\/-b-MFz7sU6CY\/WkMRYuGHEII\/AAAAAAAAAkk\/TgpxxrN3Hk0ixJvCc0oq6CJHohw3VNK4ACLcBGAs\/s1600\/Simultaneous%2BEquation%2Bin%2BPython.JPG\" style=\"margin-left: 1em; margin-right: 1em;\"><img decoding=\"async\" loading=\"lazy\" border=\"0\" data-original-height=\"690\" data-original-width=\"685\" height=\"640\" src=\"https:\/\/4.bp.blogspot.com\/-b-MFz7sU6CY\/WkMRYuGHEII\/AAAAAAAAAkk\/TgpxxrN3Hk0ixJvCc0oq6CJHohw3VNK4ACLcBGAs\/s640\/Simultaneous%2BEquation%2Bin%2BPython.JPG\" width=\"634\" \/><\/a><\/div>\n<p>I would like to explain a bit of how the program works.<\/p>\n<p><b>How it Works<\/b><br \/>First, the program request for inputs a1, a2 and a3, those are the coefficient of the first equation. Then it prompts for the coefficients: b1, b2 and b3, the coefficients of the second equation.<br \/>It then solves and display the result for x1 and x2<\/p>\n<p><span style=\"font-family: &quot;Courier New&quot;, Courier, monospace;\"><b>Source code:<\/b><\/span><\/p>\n<div style=\"text-align: left;\"><span style=\"color: #20124d;\"><span style=\"font-family: &quot;Courier New&quot;, Courier, monospace;\">#**************************************************&nbsp;&nbsp; <\/span><\/span><\/div>\n<div style=\"text-align: left;\"><span style=\"color: #20124d;\"><span style=\"font-family: &quot;Courier New&quot;, Courier, monospace;\">#PROGRAM BY: KINDSON THE GENIUS<br \/>#CATEGORY:&nbsp;&nbsp; PYTHON TUTORIALS&nbsp;<\/span><\/span><\/div>\n<div style=\"text-align: left;\"><span style=\"color: #20124d;\"><span style=\"font-family: &quot;Courier New&quot;, Courier, monospace;\">#DATE:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 26TH DECEMBER2017 #***************************************************<\/p>\n<p>print(&#8220;n*** PROGRAM TO SOLVE 2&#215;2 SIMULTANEOUS EQUATIONnn&#8221;)<br \/>print &#8220;nEquation of the form a1x + b1y = c1, a2x + b2y = c2&nbsp; nnn&#8221;<\/p>\n<p>#INPUT THE COEFFICIENTS OF EQUATION 1<br \/>a1 = input(&#8220;nEnter a1: &#8220;)<br \/>b1 = input(&#8220;nEnter b1: &#8220;)<br \/>c1 = input(&#8220;nEnter c1: &#8220;)<\/p>\n<p>#INPUT THE COEFFICIENTS OF EQUATION 2<br \/>a2 = input(&#8220;nEnter a2: &#8220;)<br \/>b2 = input(&#8220;nEnter b2: &#8220;)<br \/>c2 = input(&#8220;nEnter c2: &#8220;)<\/p>\n<p>#USING CRAMER&#8217;S RULE&#8230;<br \/>D = (a1 * b2) &#8211; (a2 * b1)<br \/>Dx = (c1 * b2) &#8211; (c2 * b1)<br \/>Dy = (a1 * c2) &#8211; (a2 * c1)<br \/>x = Dx\/D<br \/>y = Dy\/D<\/p>\n<p>#DISPLAY THE&nbsp; RESULTS<br \/>print &#8220;*********The results are:******************* nn&#8221;<br \/>print &#8220;x = {}&#8221;.format(x)<br \/>print &#8220;y = {}&#8221;.format(y)<br \/>raw_input(&#8220;nnPress &lt;Enter&gt; to exit&#8230;&#8221;)<\/span><\/span><\/div>\n<div style=\"text-align: left;\"><\/div>\n<div style=\"text-align: left;\"><\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>For all lovers of the Python Programming Language, I would like to share a program to solve simultaneous equation(system of linear equation) in Python. I &hellip; <\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[7],"tags":[],"_links":{"self":[{"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/posts\/211"}],"collection":[{"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/comments?post=211"}],"version-history":[{"count":1,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/posts\/211\/revisions"}],"predecessor-version":[{"id":1470,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/posts\/211\/revisions\/1470"}],"wp:attachment":[{"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/media?parent=211"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/categories?post=211"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/tags?post=211"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}