How to write a quadratic equation with positive or negative coefficients

How to write a quadratic equation with positive or negative coefficients

ដោយ Dominique Bauer នៅ
ចំនួនតប៖ 6
រូបភាព Documentation writers រូបភាព Particularly helpful Moodlers រូបភាព Plugin developers

Since we often use equations in quizzes, I'm opening this discussion in the quiz forum.

Formulas_20200828_0017.png

The question looks like this:



Try it at https://moodleformulas.org/course/view.php?id=36&section=2 ↗

The way I describe above works fine. Does anyone know of an easier way to achieve the same result?

មធ្យមភាគនៃរង្វាយតម្លៃ: -
ឆ្លើយតបទៅកាន់ Dominique Bauer

Re: How to write a quadratic equation with positive or negative coefficients

ដោយ David Galiana នៅ

Hi Dominique

There is a simpler way to write polynomials using Moodle Formulas: poly() function.

For instance: 

Global variables:

equation=poly("x",[2,-3-5]);

Question text: \\({equation}=0\\) will throw \(2x^2-3x-5=0\)

Sample question attached.


មធ្យមភាគនៃរង្វាយតម្លៃ: -
ឆ្លើយតបទៅកាន់ David Galiana

Re: How to write a quadratic equation with positive or negative coefficients

ដោយ Ton Boerkoel នៅ
That is very cool, David! I had another work around---that I was proud of---but using the poly() function is brilliant.
មធ្យមភាគនៃរង្វាយតម្លៃ: -
ឆ្លើយតបទៅកាន់ Ton Boerkoel

Re: How to write a quadratic equation with positive or negative coefficients

ដោយ Ton Boerkoel នៅ
There is still the issue when we have polynomial equations with more than one variable x, y z, in which case  poly()  doesn't quite work. Below I have a way (using just builtin functions) to produce nice results. 

For example we would like to write {a11}x+{a12}y+{a13}z nicer.e.g.








Here is the code that produces this


and


Of course you can also code this with Javascript, but, as you can see, it can be done with string operations too.










មធ្យមភាគនៃរង្វាយតម្លៃ: -
ឆ្លើយតបទៅកាន់ Ton Boerkoel

Re: How to write a quadratic equation with positive or negative coefficients

ដោយ Ton Boerkoel នៅ
Here is a slightly improved version. The code maybe easier to read.
 


មធ្យមភាគនៃរង្វាយតម្លៃ: -
ឆ្លើយតបទៅកាន់ David Galiana

Re: How to write a quadratic equation with positive or negative coefficients

ដោយ Dominique Bauer នៅ
រូបភាព Documentation writers រូបភាព Particularly helpful Moodlers រូបភាព Plugin developers
Hello David,

Of course. What was I thinking!

Thank you for your post.
មធ្យមភាគនៃរង្វាយតម្លៃ: -
ឆ្លើយតបទៅកាន់ Dominique Bauer

Re: How to write a quadratic equation with positive or negative coefficients

ដោយ Dominique Bauer នៅ
រូបភាព Documentation writers រូបភាព Particularly helpful Moodlers រូបភាព Plugin developers
Hello David,

Your "Second degree equation" question is excellent. I made some changes to it and added it to moodleformulas.org (roots in increasing order, partial marks and other minor changes). Thanks again.

https://moodleformulas.org/course/view.php?id=31&section=49 ↗
មធ្យមភាគនៃរង្វាយតម្លៃ: -