# Randomizing values for a function

**URL:** https://cl.desmos.com/t/randomizing-values-for-a-function/2951
**Category:** Questions
**Created:** [March 19, 2021, 8:28pm UTC](https://cl.desmos.com/t/randomizing-values-for-a-function/2951 "2021-03-19T20:28:17Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Pamela\_Davis](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/pamela_davis/32/1890_2.png) [@Pamela\_Davis](https://cl.desmos.com/u/Pamela_Davis)
#### Post date: [March 19, 2021, 8:28pm UTC](https://cl.desmos.com/t/randomizing-values-for-a-function/2951/1 "2021-03-19T20:28:17Z")

</div>

I am trying to write a random number generator for a simple function: ax^b. I found an example that is similar and I am trying to copy the Computation Layer but when I go to preview it says “undefined”. I think it has something to do with “numericValue” for my c =.

Here’s the coding:

 ![Screenshot 2021-03-19 133457](https://canada1.discourse-cdn.com/flex031/uploads/desmos/original/2X/3/349b90e6bc36b52238bbfe2dfeaf7941312244e7.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: [March 19, 2021, 9:28pm UTC](https://cl.desmos.com/t/randomizing-values-for-a-function/2951/2 "2021-03-19T21:28:28Z")

</div>

You’re right, the numericValues are causing a problem. It looks like you just want c and d to be latex, where numericValue is meant to have an output of a number instead of an expression. Does something like this look like what you’re looking for? The answer matching isn’t very good because it’s looking for exact latex matching, so if you want a better method, let us know! I also adjusted your random numbers to avoid zero, but if you’re fine with it, use what you had before. 🙂

> **[Random Values for a Function • Activity Builder by Desmos](https://teacher.desmos.com/activitybuilder/custom/605514b9265c3340f95d0e76)**
>
> by Craig Winske

---

<div class="post-metadata">

### Author: ![Pamela\_Davis](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/pamela_davis/32/1890_2.png) [@Pamela\_Davis](https://cl.desmos.com/u/Pamela_Davis)
#### Post date: [March 19, 2021, 10:00pm UTC](https://cl.desmos.com/t/randomizing-values-for-a-function/2951/3 "2021-03-19T22:00:22Z")

</div>

This is great! Thank you.

However, when I was testing it, it keeps telling me to “try again” when it should be showing correct. Not sure how to fix this.

Note: I get correct when I type the answer with the operations, ie: 3\*4x^3-1  
but I don’t want that as the answer, I want the simplified answer: 12x^2

---

<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: [March 19, 2021, 11:00pm UTC](https://cl.desmos.com/t/randomizing-values-for-a-function/2951/4 "2021-03-19T23:00:09Z")

</div>

My fault. The previous link has been updated and should be correct now.

---

<div class="post-metadata">

### Author: ![Pamela\_Davis](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/pamela_davis/32/1890_2.png) [@Pamela\_Davis](https://cl.desmos.com/u/Pamela_Davis)
#### Post date: [March 19, 2021, 11:04pm UTC](https://cl.desmos.com/t/randomizing-values-for-a-function/2951/5 "2021-03-19T23:04:08Z")

</div>

Thank you! That works!!!
