# How do I write a code for "correct equation"

**URL:** <https://cl.desmos.com/t/how-do-i-write-a-code-for-correct-equation/3210>\
**Category:** Questions\
**Created:** [April 30, 2021, 2:15am UTC](https://cl.desmos.com/t/how-do-i-write-a-code-for-correct-equation/3210 "2021-04-30T02:15:31Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kellen\_Wesson](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/kellen_wesson/32/2648_2.png) [@Kellen\_Wesson](https://cl.desmos.com/u/Kellen_Wesson)\
**Post date:** [April 30, 2021, 2:15am UTC](https://cl.desmos.com/t/how-do-i-write-a-code-for-correct-equation/3210/1 "2021-04-30T02:15:31Z")

</div>

I want my students to graph a sin function with an amplitude of 3 and a midline at y=2

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/desmos/original/2X/1/1cf39e58129d1a7c1287b710c5310eb9bac2621b.png)

---

<div class="post-metadata">

**Author:** ![cwinske](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/cwinske/32/3106_2.png) [@cwinske](https://cl.desmos.com/u/cwinske)\
**Post date:** [April 30, 2021, 5:32pm UTC](https://cl.desmos.com/t/how-do-i-write-a-code-for-correct-equation/3210/2 "2021-04-30T17:32:17Z")

</div>

This is a strategy that will work for any function and it relies on the use of the calculator. Here’s the functions you can use in the calculator:

> **[Desmos | Graphing Calculator](https://www.desmos.com/calculator/cgtk2oyuqr)**

In the graph component, use this CL:

```auto
function(`f`): simpleFunction(input.latex)

```

I’m not sure if you’re just looking for a dashboard display or some other feedback, but when the C\_{heck} variable in the graph equals 1, the graph is correct.

---

<div class="post-metadata">

**Author:** ![Kellen\_Wesson](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/kellen_wesson/32/2648_2.png) [@Kellen\_Wesson](https://cl.desmos.com/u/Kellen_Wesson)\
**Post date:** [April 30, 2021, 5:48pm UTC](https://cl.desmos.com/t/how-do-i-write-a-code-for-correct-equation/3210/3 "2021-04-30T17:48:25Z")

</div>

![image.png](https://canada1.discourse-cdn.com/flex031/uploads/desmos/original/2X/f/f327daf4a049475b16cce676c9a94fc2e0b72855.png)

I want the students to check: y=4sinx/3pi to know they have the right equation

---

<div class="post-metadata">

**Author:** ![cwinske](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/cwinske/32/3106_2.png) [@cwinske](https://cl.desmos.com/u/cwinske)\
**Post date:** [April 30, 2021, 7:24pm UTC](https://cl.desmos.com/t/how-do-i-write-a-code-for-correct-equation/3210/4 "2021-04-30T19:24:16Z")

</div>

Take the calculator screen I shared earlier and copy the URL. Open the graph on the activity you’ve shared and paste the URL into a line with an empty expression. In the folder that says “Correct Function,” enter the correct function. The other code I shared still applies. If you can’t get that to work, please share the activity as it’s easier to make adjustments that way. 😄

---

<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:** [April 30, 2021, 9:09pm UTC](https://cl.desmos.com/t/how-do-i-write-a-code-for-correct-equation/3210/5 "2021-04-30T21:09:05Z")

</div>

I’ve found that this does cause issues if you have an undefined output (e.g. using tanx instead of sinx and your list in increments of pi/4). Here’s how I changed your `C_{heck}` to avoid undefined values breaking it.

> **[AutoCheck functions](https://www.desmos.com/calculator/5qxp4ikl95)**

Note: I used the square root function as an example. C\_{heck2}=0 but C\_{heck} is okay.

---

<div class="post-metadata">

**Author:** ![cwinske](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/cwinske/32/3106_2.png) [@cwinske](https://cl.desmos.com/u/cwinske)\
**Post date:** [April 30, 2021, 9:42pm UTC](https://cl.desmos.com/t/how-do-i-write-a-code-for-correct-equation/3210/6 "2021-04-30T21:42:20Z")

</div>

Thanks for pointing that out. That thought didn’t cross my mind!

---

<div class="post-metadata">

**Author:** ![Kellen\_Wesson](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/kellen_wesson/32/2648_2.png) [@Kellen\_Wesson](https://cl.desmos.com/u/Kellen_Wesson)\
**Post date:** [May 3, 2021, 2:51pm UTC](https://cl.desmos.com/t/how-do-i-write-a-code-for-correct-equation/3210/7 "2021-05-03T14:51:58Z")

</div>

[https://teacher.desmos.com/activitybuilder/custom/60900df9ff9f48046a624247](https://teacher.desmos.com/activitybuilder/custom/60900df9ff9f48046a624247)

---

<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:** [May 3, 2021, 6:33pm UTC](https://cl.desmos.com/t/how-do-i-write-a-code-for-correct-equation/3210/8 "2021-05-03T18:33:41Z")

</div>

Here’s the graph I’d use for Slide 2. I’m guessing there’s a way to do it with pattern checking, but I’m not there yet.

> **[Desmos | Graphing Calculator](https://www.desmos.com/calculator/ggjafc5lsm)**

For dashboard correctness, use this in the input:

```auto
midline= Sketch6.number(`m_{id}`)=2
amplitude= Sketch6.number(`a_{mp}`)=3

correct: midline and amplitude and this.submitted

```

If you just wanted the equation `f(x)=3sin(x)+2` you could just change g(x) in my [AutoCheck Functions graph](https://www.desmos.com/calculator/5qxp4ikl95) to this equation. (My example in this post will also allow horizontal translations.)

---

<div class="post-metadata">

**Author:** ![Roger](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/roger/32/599_2.png) [@Roger](https://cl.desmos.com/u/Roger)\
**Post date:** [May 3, 2021, 9:29pm UTC](https://cl.desmos.com/t/how-do-i-write-a-code-for-correct-equation/3210/9 "2021-05-03T21:29:43Z")

</div>

You might one to explore the activity I made. Slide 20 was fun to program. I belive you might want to reuse some of my slides

> **[Over and over. Sinusoidal functions • Activity Builder by Desmos](https://teacher.desmos.com/activitybuilder/custom/608a27016137b10ba45eabfb)**
>
> by Roger Borrell Anglada
