# Calculation Help

**URL:** <https://cl.desmos.com/t/calculation-help/3616>\
**Category:** Questions\
**Tags:** validation, correctness\
**Created:** [August 25, 2021, 1:26am UTC](https://cl.desmos.com/t/calculation-help/3616 "2021-08-25T01:26:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![yearby21](https://avatars.discourse-cdn.com/v4/letter/y/a698b9/32.png) [@yearby21](https://cl.desmos.com/u/yearby21)\
**Post date:** [August 25, 2021, 1:26am UTC](https://cl.desmos.com/t/calculation-help/3616/1 "2021-08-25T01:26:45Z")

</div>

I am trying to get my math input to check the students answer. I have used random integers so that every time a student practices the problem they receive different values. I would love for the math input to check their work so that I can see if they did it correctly. However, I am having a hard time figuring out how to have the math input calculate the answer based on random integers.

> **[Calculate Answer Test Run • Activity by Noah Ward](https://classroom.amplify.com/activity/61259bbd2449fa607e781d06)**
>
> by Noah Ward

---

<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:** [August 25, 2021, 12:21pm UTC](https://cl.desmos.com/t/calculation-help/3616/2 "2021-08-25T12:21:14Z")

</div>

You can add this to your input component to get a check on the teacher dashboard.

```auto
correct = simpleFunction(`-\sqrt{r^2-x^2}`, `r`, `x`).evaluateAt(note.script.b, note.script.a)=this.numericValue

correct: correct

```

Make sure to name your note component (I used “note”). You’ll also want to set the sketch to `readOnly: true`.

---

<div class="post-metadata">

**Author:** ![Bryn](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/bryn/32/40_2.png) [@Bryn](https://cl.desmos.com/u/Bryn)\
**Post date:** [August 26, 2021, 10:05am UTC](https://cl.desmos.com/t/calculation-help/3616/3 "2021-08-26T10:05:53Z")

</div>

I have a feeling this could be a bit risky if you are testing whether a square root is equal to another value, because it could be off by a tiny bit due to computer rounding issues?

When I’m dealing with functions that aren’t very basic I tend to replace equality tests with code like the below:

```auto
diff = simpleFunction("\\operatorname{abs}(x - y)", "x", "y")
diff.evaluateAt(..., ...) <= 0.0000001

```
