# Count number usage

**URL:** <https://cl.desmos.com/t/count-number-usage/2717>\
**Category:** Questions\
**Tags:** patterns\
**Created:** [February 20, 2021, 2:01am UTC](https://cl.desmos.com/t/count-number-usage/2717 "2021-02-20T02:01:29Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Julia\_Smith](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/julia_smith/32/281_2.png) [@Julia\_Smith](https://cl.desmos.com/u/Julia_Smith)\
**Post date:** [February 20, 2021, 2:01am UTC](https://cl.desmos.com/t/count-number-usage/2717/1 "2021-02-20T02:01:29Z")

</div>

I am trying to adapt a code from a colleague’s activity to a new activity but I can’t get the table to recognize a correct answer. I am pretty sure my error is in using countnumberusage. Can someone guide me on this?

> **[Test 2 Review • Activity by Julia Smith](https://classroom.amplify.com/activity/602f200c75f4c1379fb387b5)**
>
> by Julia Smith

---

<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:** [February 20, 2021, 3:15am UTC](https://cl.desmos.com/t/count-number-usage/2717/2 "2021-02-20T03:15:49Z")

</div>

Your \> and \< are backwards.

---

<div class="post-metadata">

**Author:** ![Julia\_Smith](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/julia_smith/32/281_2.png) [@Julia\_Smith](https://cl.desmos.com/u/Julia_Smith)\
**Post date:** [February 20, 2021, 3:29am UTC](https://cl.desmos.com/t/count-number-usage/2717/3 "2021-02-20T03:29:55Z")

</div>

Thanks! I fixed that and now it only counts the first one as correct. Still not recognizing all the other ones.

---

<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:** [February 20, 2021, 5:58am UTC](https://cl.desmos.com/t/count-number-usage/2717/4 "2021-02-20T05:58:41Z")

</div>

Apparently, simpleFunction is more stable than numericValue, so I tried this and it works:

```auto
check2=simpleFunction("\sqrt{512}").evaluateAt(0)=
 simpleFunction("${table1.cellNumericValue(2,2)}").evaluateAt(0) and 
countNumberUsage(a2,16)=1 and countNumberUsage(a2,22)=0 and 
countNumberUsage(a2,7)=0 

```

---

<div class="post-metadata">

**Author:** ![Julia\_Smith](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/julia_smith/32/281_2.png) [@Julia\_Smith](https://cl.desmos.com/u/Julia_Smith)\
**Post date:** [February 22, 2021, 12:34am UTC](https://cl.desmos.com/t/count-number-usage/2717/5 "2021-02-22T00:34:01Z")

</div>

Thanks! Will that also work for sqrt(-98)? Or will I need a different type of argument because of the i?

---

<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:** [February 22, 2021, 5:36am UTC](https://cl.desmos.com/t/count-number-usage/2717/6 "2021-02-22T05:36:59Z")

</div>

You could do something like:

```auto
check2=simpleFunction("\sqrt{98i}","i").evaluateAt(2)=
 simpleFunction("${table1.cellNumericValue(2,2)}","i").evaluateAt(2) and 
countNumberUsage(a2,7)=1 and countNumberUsage(a2,2)=1

```

---

<div class="post-metadata">

**Author:** ![Julia\_Smith](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/julia_smith/32/281_2.png) [@Julia\_Smith](https://cl.desmos.com/u/Julia_Smith)\
**Post date:** [February 22, 2021, 2:35pm UTC](https://cl.desmos.com/t/count-number-usage/2717/7 "2021-02-22T14:35:19Z")

</div>

So I still don’t know what I am doing wrong. Here is the activity again. I have fixed the first 5 on slide 8 and I will be honest, I am having the same issue on slide 9.

> **[Test 2 Review • Activity Builder by Desmos](https://teacher.desmos.com/activitybuilder/custom/602f200c75f4c1379fb387b5)**
>
> by Julia Smith

---

<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:** [February 22, 2021, 6:18pm UTC](https://cl.desmos.com/t/count-number-usage/2717/8 "2021-02-22T18:18:10Z")

</div>

Your evaluations for a3 are not right.  
For f(i)=-10+23i,  
f(1)=13  
f(2)=36

It will also be easier to compare simpleFunction to simpleFunction (which _should_ work for your answers with radicals as well instead of using \< and \> comparisons). I made a few adjustments (like fa3 is the function for a3, and exp3 the function for the expected answer):

```auto
#(4+i)(-1+6i)=-10+23i
a3=table2.cellContent(3,2)
fa3= simpleFunction(a3,"i")
exp3=simpleFunction("-10+23i","i")
check3=fa3.evaluateAt(1)=exp3.evaluateAt(1) and fa3.evaluateAt(2)=exp3.evaluateAt(2) 
     and fa3.evaluateAt(3)=exp3.evaluateAt(3) 
     and countNumberUsage(a3,10)=1 and countNumberUsage(a3,23)=1
answer3 =
  when check3 1
  otherwise 0

```

---

<div class="post-metadata">

**Author:** ![Julia\_Smith](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/julia_smith/32/281_2.png) [@Julia\_Smith](https://cl.desmos.com/u/Julia_Smith)\
**Post date:** [August 4, 2021, 9:01pm UTC](https://cl.desmos.com/t/count-number-usage/2717/9 "2021-08-04T21:01:54Z")

</div>

Count number usage is not my friend. I struggle with it every time I try to use it. Can you tell me why it isn’t working on slide 3 of this activity?

> **[Function Operations • Activity Builder by Desmos](https://teacher.desmos.com/activitybuilder/custom/5fe250ca9e08540bbc6feec1?collections=5e2b06b94841800ca67887cd)**
>
> by Julia Smith

---

<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 5, 2021, 1:52am UTC](https://cl.desmos.com/t/count-number-usage/2717/10 "2021-08-05T01:52:03Z")

</div>

I don’t see anything wrong with your code. I think the issue is the function notation in the initial latex. When I deleted that part, it was marked as correct. If you want to include that notation, you might be able to parse the left side of the equation and use pattern matching to get this to work.

---

<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:** [August 5, 2021, 8:17pm UTC](https://cl.desmos.com/t/count-number-usage/2717/11 "2021-08-05T20:17:49Z")

</div>

I actually don’t think the issue is with countNumberUsage. I’m pretty sure simpleFunction only works with “`y=`” or “`f(x)=`” (or other letter besides f). I changed to this and it worked:

```auto
check1= simpleFunction(parseEquation(exp1.latex).rhs).evaluateAt(0)=-2 and 
simpleFunction(parseEquation(exp1.latex).rhs).evaluateAt(1)=2 and 
simpleFunction(parseEquation(exp1.latex).rhs).evaluateAt(-1)=-2 and 
countNumberUsage(exp1.latex,6)=0 and countNumberUsage(exp1.latex,5)=0

```
