Friday, March 21, 2014

#codemaths: Considering different solutions as variables change

A symbolic extension to our current learning in class
I presented this as a challenge for my students today that were ready to move on from the review that others were still doing in class. All students worked on the initial question and a handful moved on to try to program the solution in #codemaths. I was happy to see that a couple of my female students were working on this and I talked to them about the movement to try and get more girls into programming in what is typically seen as a male career path--they thought that was pretty cool.

Here is the example the class worked on and the skills I went over to prepare students for what they would need to do in order to connect the Javascript to the mathematics they were applying:

What is the solution to ax+b≥c where a, b and c are any value? Are there any circumstances that cause your solution to be different?

Javascript skills needed: using the eval() function and joining a string with variable expressions.

Joining strings with variable values:
“This sentence includes the value “+b;
displays as
“This sentence includes the value 3”
when b = 3.

Using the eval() function:
You can do math using the eval() function as well:
“x>”+eval(a*b-c)
would display as
“x>-1”
when a=1, b=2 and c=3.

In this #codemaths challenge, you will want to change the variable ‘solved’ in the constraints section to output a correct solution for any inequality that may result for random variables a, b and c that is programmed in the question section.
Notice in the first line of code
if(a==0){a = 3;}

that a will be changed to 3 if it is ever equal to 0.

1 comment:

  1. Oh my goodness, this is such a rich activity for them! I've always said that I see parallels between geogebra and coding! For example, my kids had to make the zero of a function always appear in the correct place on their graph, no matter what the parameters of the function are, so they have to input the coordinates of the linear zero as (-k/a, 0) for example. And for some functions, there is no zero, eg the exponential, so they have to also make it say (This function has no zero) under the right conditions. Thanks for this, I feel validated!

    ReplyDelete