<jupyter_start><jupyter_text>How to run this file   To run code in each cell,  use shift enter or tinker  with cell part of the bar menu above   You may come across run issues, look up online references or tinker and figure out, failure of the  code is not a big deal as you can always delete a file and start afresh.   About this block   This is a markdown cell, it was created by using the cell menu above and selecting the markdown option.  For more on the usage of Markdown scriptlook up the corresponding wikipedia page. The cell below defines two lines, shows the resuluting plot and gives the intersection point if it is unique.Feel free to tinker with the code and rerurn using shift enter.<jupyter_code># Comments are given on the right side in blue after the # prompt.
# Please note that indentation is used for nested statements without using "end".
# If you have a line equations of the form ax + by = c, bring them to y = mx + c form to use this code.


import numpy as np                      # Python library for efficient computation
import matplotlib.pyplot as plt         # Plot library
x = np.arange(-10, 10, 0.5)             # defining the x range and step size
m1 = 2                                  # m1 is slope for line 1
c1 = 3                                  # c1 is intercept for line 1
m2 = 2                                  # m2 is slope for line 2
c2 = -2                                 # c2 is intercept for line 2
def y(x,m,c):                                             # The definition of the line
    return m*x + c
plt.plot(x, y(x,m1,c1), 'b', x, y(x,m2,c2), 'p')          # Plotting the two lines in two colors, blue 'b' and green 'g'
plt.show()                                                # After creating the plot object, it has to be shown.<jupyter_output><empty_output><jupyter_text>Create a cell below using the insert menu at the top. Declare the cell of type "markdown" by selecting "cell menu -> cell type" and write some really important information like "Computing is cool"<jupyter_code># Solving the two equations, check for special cases
x0 = "not defined"
y0 = "not defined"
if  (m1*m2)==0 :                             #If at least one of the line is horizontal.
    if m1 != 0:
        y0 = c2
        x0 =  (c2 - c1)/m1
    elif  m2 != 0 :
        y0 = c1 
        x0 =  (c1 - c2)/m2
    elif  c1 == c2:
         print("The lines are the same, zero slope")
         print("infinite number of solutions")
    else:
        print("parallel lines zero slope, solution doesn't exist")    
elif (m1-m2) != 0 :
    x0 = (c2-c1)/(m1 - m2)
    y0 = m1*x0 + c1
elif (c1 == c2) :
    print("The lines are the same")
    print("infinite number of solutions")
elif c1 != c2 :
    print("parallel lines, solutions doesn't exist")
(x0,y0)<jupyter_output>parallel lines, solutions doesn't exist<jupyter_text>Matrix form of the equation is$$\left(\begin{array}{cc}m1 & -1\\m2 & -1\end{array}\right)\left(\begin{array}{c}x \\y\end{array}\right)=\left(\begin{array}{c}-c1 \\-c2\end{array}\right)$$<jupyter_code># Define two lines and draw them
m1p = 2
m2p = -1
c1p = 1
c2p = -2
plt.plot(x, y(x,m1p,c1p), 'pink', x, y(x,m2p,c2p), 'c')
plt.show()
# Repeat the exercise to draw three lines
# Write the code below<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09140767824497258, 'fraction_numerical': 0.0258988421694089, 'mean_word_length': 2.395036194415719, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 13, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '24907', 'license': 'MIT', 'n_tokens_mistral': 1037, 'n_tokens_neox': 995, 'n_words': 437, 'path': 'note1geometric.ipynb', 'repo_name': 'mitaxim/Linear-Algebra', 'size': '3282'}