imaginary Numbers/generated numbers will multiple choice

Jump to solution
JustinDavidson
Community Explorer

Going over powers of i. The only answers are i, -1, -i, or 1.

First attempt was to use a formula question with i^`a` and have it randomly generate natural numbers for a. I learned that Canvas doesn't like imaginary numbers, so only will generate a values that produce 1 or -1. Not very helpful for the concept.

Multiple choice questions, to my knowledge, cannot have generated numbers/formulas in them. I'm hoping to NOT have to create a bunch of MC questions where I just change the exponent. Any ideas? TIA!

0 Likes
1 Solution
James
Community Champion

@JustinDavidson 

I've had to hack Canvas in similar ways before so that I can use a formula question.

What I would do is give them an answer key as part of the question.

2024-03-08_18-14-28.png

Here is the HTML of the question. Nothing fancy other than adding extra spacing after the question prompt because Canvas doesn't.

 

<p style="padding-bottom: 1em;">Simplify \(i^{`n`}\).</p>
<p>Use these directions for entering your answer.</p>
<ul>
    <li>Enter 1 if the answer is \(1\)</li>
    <li>Enter -1 if the answer is \(-1\)</li>
    <li>Enter 2 if the answer is \(i\)</li>
    <li>Enter -2 if the answer is \(-i\)</li>
</ul>

 

We know the answer is dependent upon n mod 4. I took the easy way out and used the modulus to get the value in a specific position within a list.

  • For n mod 4 = 0, we get \(i^0=1\) so we want the answer to be 1
  • For n mod 4 = 1, we get \(i^1=i\) so we want the answer to be 2
  • For n mod 4 = 2, we get \(i^2=-1\) so we want the answer to be -1
  • For n mod 4 = 3, we get \(i^3=-i\) so we want the answer to be -2

Canvas doesn't have a facility for entering a list directly. You can use reverse() to enter it in reverse order or sort() to a list. Sort() won't help, but reverse() will maintain the order. Since we want 1, 2, -1, -2, we have to enter it as reverse(-2, -1, 2, 1).

Once you have a list, you can use the at() function to get the number from a certain position. It uses a 0-based index, which works great with our remainders.

Here's the code I used for the answers.

 

at(reverse(-2,-1,2,1),mod(n,4))

 

Using this technique allows you to change the codes. For example, you could say enter 1, 2, 3, or 4. The reason I went with the weird way I did is that it's going to be confusing to the student to enter 3 when the answer is -1, but they can see that the i thing is different.

You might add a note that the reason we're using the conversion table is because Canvas will not allow you to enter an i with a formula question.

View solution in original post