# Writing Equation of a Line

**URL:** <https://cl.desmos.com/t/writing-equation-of-a-line/3708>\
**Category:** Questions\
**Created:** [September 26, 2021, 2:51pm UTC](https://cl.desmos.com/t/writing-equation-of-a-line/3708 "2021-09-26T14:51:36Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Terry\_Daniels](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/terry_daniels/32/2449_2.png) [@Terry\_Daniels](https://cl.desmos.com/u/Terry_Daniels)\
**Post date:** [September 26, 2021, 2:51pm UTC](https://cl.desmos.com/t/writing-equation-of-a-line/3708/1 "2021-09-26T14:51:36Z")

</div>

Trying to show correctness of a linear equation for a given graphed line. The code below works if I take the initialLatex: “y=” line out. Does not work if it is in. Any advice on how to get this to work? Thanks in advance.

initialLatex: “y=”

p = patterns

sumPattern = p.sum(p.expression,p.expression)  
difPattern = p.difference(p.expression,p.expression)  
productPattern = p.product(p.expression,p.expression)

valid = sumPattern.matches(this.latex) or difPattern.matches(this.latex)

correct =  
xyLine(this.latex).slope = -0.5 and  
xyLine(this.latex).yIntercept = 3 and  
valid

correct: correct

---

<div class="post-metadata">

**Author:** ![StoyanNYC](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/stoyannyc/32/2967_2.png) [@StoyanNYC](https://cl.desmos.com/u/StoyanNYC)\
**Post date:** [September 26, 2021, 3:45pm UTC](https://cl.desmos.com/t/writing-equation-of-a-line/3708/2 "2021-09-26T15:45:20Z")

</div>

I’ve done this is in the past but used a different approach. Here is the activity. Hopefully, this is helpful.

> **[Checking Linear Equation for Correctness • Activity Builder by Desmos](https://teacher.desmos.com/activitybuilder/custom/6150946fc4cfd809137dd2fa)**
>
> by Stoyan Stoyanov

---

<div class="post-metadata">

**Author:** ![Terry\_Daniels](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/terry_daniels/32/2449_2.png) [@Terry\_Daniels](https://cl.desmos.com/u/Terry_Daniels)\
**Post date:** [September 26, 2021, 4:39pm UTC](https://cl.desmos.com/t/writing-equation-of-a-line/3708/3 "2021-09-26T16:39:20Z")

</div>

Thanks. Not sure I totally understand why it works. I am guessing it is actually using the graph to check. Is there a way to have it show as a Checkmark in the Dashboard as well?

---

<div class="post-metadata">

**Author:** ![StoyanNYC](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/stoyannyc/32/2967_2.png) [@StoyanNYC](https://cl.desmos.com/u/StoyanNYC)\
**Post date:** [September 26, 2021, 4:53pm UTC](https://cl.desmos.com/t/writing-equation-of-a-line/3708/4 "2021-09-26T16:53:33Z")

</div>

The number b that is calculated in the graph component is a sum of differences between the values of correct function and the student input function at 21 different values of x. If the two functions are identical, there would be no difference, so b will be zero.

I’ve edited it so there will be a dashboard checkmark if the student is correct.

Here is the edited version

> **[Checking Linear Equation for Correctness-Check Mark Added • Activity Builder...](https://teacher.desmos.com/activitybuilder/custom/6150a3171eada80912066949)**
>
> by Stoyan Stoyanov

---

<div class="post-metadata">

**Author:** ![Terry\_Daniels](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/terry_daniels/32/2449_2.png) [@Terry\_Daniels](https://cl.desmos.com/u/Terry_Daniels)\
**Post date:** [September 26, 2021, 4:57pm UTC](https://cl.desmos.com/t/writing-equation-of-a-line/3708/5 "2021-09-26T16:57:33Z")

</div>

Perfect! Thank you for your help.

---

<div class="post-metadata">

**Author:** ![StoyanNYC](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/stoyannyc/32/2967_2.png) [@StoyanNYC](https://cl.desmos.com/u/StoyanNYC)\
**Post date:** [September 26, 2021, 5:03pm UTC](https://cl.desmos.com/t/writing-equation-of-a-line/3708/6 "2021-09-26T17:03:08Z")

</div>

If you’d like to add a graph of the line, make sure that the CL for the graph component says

readOnly: true

Otherwise, you’ll be getting a dot on the dashboard instead of a checkmark.

---

<div class="post-metadata">

**Author:** ![Terry\_Daniels](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/terry_daniels/32/2449_2.png) [@Terry\_Daniels](https://cl.desmos.com/u/Terry_Daniels)\
**Post date:** [September 26, 2021, 6:17pm UTC](https://cl.desmos.com/t/writing-equation-of-a-line/3708/7 "2021-09-26T18:17:07Z")

</div>

Thanks. I did know that and had already done it.

---

<div class="post-metadata">

**Author:** ![Daniel\_Grubbs](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_grubbs/32/719_2.png) [@Daniel\_Grubbs](https://cl.desmos.com/u/Daniel_Grubbs)\
**Post date:** [September 27, 2021, 3:03pm UTC](https://cl.desmos.com/t/writing-equation-of-a-line/3708/8 "2021-09-27T15:03:23Z")

</div>

Instead of “this.latex” you’ll need to use “parseEquation(this.latex).rhs”. The issue with your pattern (with y=) is that it’s attempting to check the pattern of an expression rather against an equation. If you parse the right hand side and check that against your pattern, it should work.
