I'm a math teacher wanting to insert some dynamic math into a website. What I'd like to achieve is to have a button that a student can press to randomly vary a question so that it's the same type of question, but with different numbers. For example,
Factor the quadratic expression of the form ax^2 + bx + c, where a = 1, and b and c are positive integers between 1 and 100, and such that the roots would be real whole numbers.
If I'm using MathML to encode the math (e.g., like the markup below), stored in a database (e.g., MySQL), how could I set things up so that the computer automatically and randomly varies the math expression in the way I described above? I don't know much about server-side scripting... could I achieve this with PHP? Or would this be more a job of JavaScript on the client side? I'm just looking for some advice to guide my choice of study path. Thank you
<math xmlns='http://www.w3.org/1998/Math/MathML'>
<mrow>
<msup>
<mi>x</mi>
<mn>2</mn>
</msup>
<mo>+</mo>
<mrow>
<mn>7</mn>
<mo>⁢</mo>
<mi>x</mi>
</mrow>
<mo>+</mo>
<mn>12</mn>
</mrow>
</math>
One way is to store generic formulas in your database, i.e. the example you gave ax^2 + bx + c
. Example of database called formulas
:
id_formulas formula_problem constants type formula_solution
1 ax^2 + bx + c = 0 a{split}b{split}c polynomial x = (-1*{b} + ({b}^2 - 4*{a}*{c}) ) / 2*{a} {split} x = (-1*{b} - ({b}^2 - 4*{a}*{c}) ) / 2*{a}
2 y = mx + b b{split}m{split}y graph x = ({b} - {y}) / -1*{m}
3 etc etc etc etc
Then (psuedocode):
formula_problem
from database (either any type, or of a certain type)formula_solution
with numbers from step 2 (inside {}
so easy to find)Split("{split}")
into array)This web application can be written in Java/C#.NET/VB.NET/PHP/any web technology. The database can be SQL Server/MySQL/PostgreSQL/XML/etc. The processing can all be done server side in one of the aforementioned languages, or, once the data (formula) is retrieved from the database, the processing could be done in client side JavaScript.
This question is very open ended because there are many approaches that a developer could take, and it comes down to preference. My personal opinion though is that it would be harder to program some of this stuff in client side JavaScript versus server side C# or PHP.
If you know any computer languages already, i.e. C++, then pick a scripting technology that looks similar and start learning by reading books and online tutorials/code examples.
(sorry I'm not a math guy though)
Well, you can use javascript and random numbers to vary the coefficients. Have a look at the following web side for agood lesson on how to do this:
JavaScript: Random Scripts
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With