# Spray a Line!!!

<p class="callout info"><span style="white-space: pre-wrap;"><b>What</b>: Sprinkle points along a 2D line and play  
<b>Why</b>: The equations and inequlities dealing with lines suddenly make better sense 
<b>How</b>: Get your eyes trained on reading math and code, by simply copy-paste one or few lines of the ff scripts below into new ff programs and use show or different plots to study the internal structures of the program.
<b>Time To Complete</b>: 6 hours </span></p>

<!--
comment
-->
<a href="https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode.en" target="_blank">
<img src="https://wiki.compclassnotes.com/uploads/images/gallery/2026-05/scaled-1680-/cc.png" alt="Alt Text" width="20%" height="20%">

</a>

<span style="color: rgb(0, 0, 0); white-space: pre-wrap;">**pts2** is your friend the Line! In 2D, any equation of the form <span style="background-color: rgb(251, 238, 184);">a&#42;x+b&#42;y + c = 0 </span> has solutions namely the x and y coordinates that satisfy the identity, namely lhs = rhs, line up along a fixed line specified by the three constants a, b and c. </span>

<span style="color: rgb(0, 0, 0); white-space: pre-wrap;">Pay attention to the function-call <span style="background-color: rgb(251, 238, 184);">color [{red, black,green}];</span> that sets a list of colors for three plots of points form pts1, pts2 and pts3. As you can see the black color corresponds to the second plot which is obtained from the pts2. </span>

<span style="color: rgb(0, 0, 0); white-space: pre-wrap;">The single line of function-call below: </span> 

<code><span style="color:purple" >pts2 = instance[linear == 0 and -5<x<5 and -5<y<5 , 50];</span></code>

<span style="color: rgb(0, 0, 0); white-space: pre-wrap;"><span style="background-color: rgb(251, 238, 184);">linear == 0</span> sets up an equation for 3&#42;x+2&#42;y-3 to be always 0. </span>

<span style="color: rgb(0, 0, 0); white-space: pre-wrap;"><span style="background-color: rgb(251, 238, 184);">50</span> is the number of requested randomly generated solutions to the Line Equation 3&#42;x+2&#42;y-3 = 0. </span>

<span style="color: rgb(0, 0, 0); white-space: pre-wrap;"><span style="background-color: rgb(251, 238, 184);">-5<x<5 and -5<y<5</span> indicates a rectangular region of the 2D plane to solve the Line Equation 3&#42;x+2&#42;y-3 = 0 for. </span> 

<p class="callout success">
<span style="color: rgb(0, 0, 0); white-space: pre-wrap;">As you will learn in future we can alter that rectagular shape for much more intricate and exciting ones. </span></p>

<span style="color: rgb(0, 0, 0); white-space: pre-wrap;"><span style="background-color: rgb(251, 238, 184);">and</span> indicates both inequalities -5<x<5 and -5<y<5 to hold or be satisfied by the choice of x and y. </span>

```
//do not use the reserved word line, alter e.g. linear;

linear = 3*x+2*y-3;

//points residing on one side of the line;
pts1 = instance [linear < 0 and -5<x<5 and -5<y<5 , 50];

//points residing on the line;
pts2 = instance [linear == 0 and -5<x<5 and -5<y<5 , 50];

//points residing on the other side of the line;
pts3 = instance [linear > 0 and -5<x<5 and -5<y<5 , 50];

//make a list of colors corresponding to the points in each region;
color[{red, black,green}];

//show all points;
pointplot pts1 also pts2 also pts3;

save as line;
```

**Output**

[![line_less_equal_greater.jpg](https://wiki.compclassnotes.com/uploads/images/gallery/2026-05/scaled-1680-/line-less-equal-greater.jpg)](https://wiki.compclassnotes.com/uploads/images/gallery/2026-05/line-less-equal-greater.jpg)

<p class="callout success"><span style="white-space: pre-wrap;"> Run the Free Form code again and you should each time get a different distribution of the scattered points.</p>

**Output**

[![line_less_equal_greater2.jpg](https://wiki.compclassnotes.com/uploads/images/gallery/2026-05/scaled-1680-/line-less-equal-greater2.jpg)](https://wiki.compclassnotes.com/uploads/images/gallery/2026-05/line-less-equal-greater2.jpg)