# Evaluating an expression

**URL:** <https://cl.desmos.com/t/evaluating-an-expression/2367>\
**Category:** Questions\
**Tags:** simplefunction, validation, correctness\
**Created:** [January 12, 2021, 1:33pm UTC](https://cl.desmos.com/t/evaluating-an-expression/2367 "2021-01-12T13:33:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jeff\_Mahood](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/jeff_mahood/32/1707_2.png) [@Jeff\_Mahood](https://cl.desmos.com/u/Jeff_Mahood)\
**Post date:** [January 12, 2021, 1:33pm UTC](https://cl.desmos.com/t/evaluating-an-expression/2367/1 "2021-01-12T13:33:16Z")

</div>

I want to have a question that asks students whether an ordered triple satisfies a plane’s equation. I know that I need to have three different math inputs since Desmos only recognizes ordered pairs, and that’s fine - I have three inputs called ans\_x, ans\_y, and ans\_z.

I can’t seem to get the right syntax to evaluate the function. For the purposes of this question, let’s say that the equation of the plane is 2x+y+z=1.

I _think_ I want to use something like simpleFunction. Here’s the relevant snippet:

```auto
plane = simpleFunction("2a+b+c", "a", "b", "c")
checkValue = plane.evaluateAt(ans_x.numericValue,ans_y.numericValue,ans_z.numericValue)
when checkValue = 1 "Correct!"
otherwise "Incorrect"

```

---

<div class="post-metadata">

**Author:** ![Susan\_Lauer](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/susan_lauer/32/1832_2.png) [@Susan\_Lauer](https://cl.desmos.com/u/Susan_Lauer)\
**Post date:** [January 12, 2021, 2:09pm UTC](https://cl.desmos.com/t/evaluating-an-expression/2367/2 "2021-01-12T14:09:53Z")

</div>

If this is in a Note component, you just need to add the sink  
`content: when . . .`  
on your third line.

---

<div class="post-metadata">

**Author:** ![Jeff\_Mahood](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/jeff_mahood/32/1707_2.png) [@Jeff\_Mahood](https://cl.desmos.com/u/Jeff_Mahood)\
**Post date:** [January 12, 2021, 4:31pm UTC](https://cl.desmos.com/t/evaluating-an-expression/2367/3 "2021-01-12T16:31:15Z")

</div>

I was unclear; sorry. The content: when is already there, but earlier, because I’ve got this snippet only resolving when ans\_x, ans\_y and ans\_z are submitted. Is that my problem? Should the plane and checkvalue be defined before the initial content condition list?

---

<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:** [January 12, 2021, 4:49pm UTC](https://cl.desmos.com/t/evaluating-an-expression/2367/4 "2021-01-12T16:49:12Z")

</div>

What she means is, the last two lines of your code need to be preceded by "content: ". As is, your when-otherwise is part of the `checkValue` definition on line 2.

```auto
plane = simpleFunction("2a+b+c", "a", "b", "c")
checkValue = plane.evaluateAt(ans_x.numericValue,ans_y.numericValue,ans_z.numericValue)
content: when checkValue = 1 "Correct!"
otherwise "Incorrect"

```

With the content sink added in, it seems to work fine. Without your activity link, I have to assume ans\_x, ans\_y, and ans\_z are all math inputs.

---

<div class="post-metadata">

**Author:** ![Susan\_Lauer](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/susan_lauer/32/1832_2.png) [@Susan\_Lauer](https://cl.desmos.com/u/Susan_Lauer)\
**Post date:** [January 12, 2021, 5:06pm UTC](https://cl.desmos.com/t/evaluating-an-expression/2367/5 "2021-01-12T17:06:27Z")

</div>

Did you want to give them a few ordered triples and ask if they’re on the plane like this?  
 ![image](https://canada1.discourse-cdn.com/flex031/uploads/desmos/original/2X/6/6048a9a367eb4c23df3f8139b49cbf87735c974c.png)
