Formulas: More examples: Difference between revisions
No edit summary |
|||
Line 94: | Line 94: | ||
<div style="margin:20px 0 20px;"> | <div style="margin:20px 0 20px;"> | ||
[http://35.193.77.29/mod/quiz/view.php?id=152<span style="background-color:#f98012;box-shadow: 0 5px 10px #cbcbcb;border: none;color:white;padding: 8px 16px;text-align:center;text-decoration: none;cursor:pointer;">Play it</span>] [[Formulas_question_type#Examples|Login info]] ''(Open in new tab: Ctrl+Shift+Click)'' | [http://35.193.77.29/mod/quiz/view.php?id=152<span style="background-color:#f98012;box-shadow: 0 5px 10px #cbcbcb;border: none;color:white;padding: 8px 16px;text-align:center;text-decoration: none;cursor:pointer;">Play it</span>] [[Formulas_question_type#Examples|Login info]] ''(Open in new tab: Ctrl+Shift+Click)'' | ||
</div> | |||
</div> | |||
==Significant figures== | |||
''"The significant figures of a number are digits that carry meaning contributing to its measurement resolution."'' (Reference: https://en.wikipedia.org/wiki/Significant_figures). | |||
The Formulas question has no built-in function to display numbers with a given number of significant figures. However, it is easy to work out this function as the following variable assignment which works with any real number: | |||
<pre style="font-size:113%;width: 98%;"> | |||
xr=x==0?x:round(x*pow(10,nsf-1-floor(log10(abs(x)))),0)*pow(10,-nsf+1+floor(log10(abs(x)))); | |||
</pre> | |||
where <span style="font-family: monospace;font-size:113%;">x</span> is the number to be rounded, <span style="font-family: monospace;font-size:113%;">nsf</span> the number of significant digits to keep and <span style="font-family: monospace;font-size:113%;">xr</span> the resulting rounded value. | |||
<div style="border:1px solid #bce8f1;border-radius:4px;padding: 0px 15px 0px; margin:20px 0 25px;"> | |||
<div style="font-family:Lucida Sans Unicode;font-size:150%;color:#f98012;margin:10px 0 10px;>Example</div> | |||
This example deals with the display of the correct answers with different numbers of significant figures. | |||
The Formulas question should look like this: | |||
[[File:Formulas201712310126.png|680px]] | |||
<div style="margin:20px 0 20px;"> | |||
[http://35.193.77.29/mod/quiz/view.php?id=153<span style="background-color:#f98012;box-shadow: 0 5px 10px #cbcbcb;border: none;color:white;padding: 8px 16px;text-align:center;text-decoration: none;cursor:pointer;">Play it</span>] [[Formulas_question_type#Examples|Login info]] ''(Open in new tab: Ctrl+Shift+Click)'' | |||
</div> | </div> | ||
</div> | </div> |
Revision as of 07:03, 2 January 2018
Significant figures
"The significant figures of a number are digits that carry meaning contributing to its measurement resolution." (Reference: https://en.wikipedia.org/wiki/Significant_figures).
The Formulas question has no built-in function to display numbers with a given number of significant figures. However, it is easy to work out this function as the following variable assignment which works with any real number:
xr=x==0?x:round(x*pow(10,nsf-1-floor(log10(abs(x)))),0)*pow(10,-nsf+1+floor(log10(abs(x))));
where x is the number to be rounded, nsf the number of significant digits to keep and xr the resulting rounded value.
This example deals with the display of the correct answers with different numbers of significant figures.
The Formulas question should look like this:
Play it Login info (Open in new tab: Ctrl+Shift+Click)
This example is a significant figures drill.
General Question name! Significant figures drill Variables Random variables # a plus or minus sign # b exponent varying from -4 to 4 in steps of 0.01 # rnsf random number of significant figures : 1, 2, 3, or 4 a={-1,1}; b={-4:4.01:0.01}; rnsf={1,2,3,4}; Global variables # nx number x = ± 10^b nx=a*pow(10,b); # Rounding routine: # x number to round # nsf number of significant figures # xr rounded value of x x=nx; nsf=rnsf; xr=x==0?x:round(x*pow(10,nsf-1-floor(log10(abs(x)))),0)*pow(10,-nsf+1+floor(log10(abs(x)))); Main question Question text! Significant figures drill Part 1 Part's mark* 1 Answer type Number Answer* xr Grading criteria* Relative error < 0.0001 Part's text Number to round: {nx} Number of significant digits to keep: {ncs} Rounded number: {_0} Combined feedback For any correct response The correct answer is: {xr} For any incorrect response The correct answer is: {xr}
In the Variables fields (random, global and local), lines starting with # are treated as comments.
In this example, values to be rounded range from -10 000 to +10 000. In order to have the same number of values in each order of magnitude, hence a more interesting exercise, the random variable b is used as a power of 10. By letting:
with b ranging from -4 to +4 in steps of 0.01, there are one hundred random values in each order of magnitude (0.000 1 to 0.001, 0.001 to 0.01, 0.01 to 0.1, 0.1 to 1, 1 to 10, 10 to 100, 100 to 1 000 and 1 000 to 10 000), both positive and negative.
In total, this example generates 6 408 different random questions:
The Formulas question should look like this:
Play it Login info (Open in new tab: Ctrl+Shift+Click)
Significant figures
"The significant figures of a number are digits that carry meaning contributing to its measurement resolution." (Reference: https://en.wikipedia.org/wiki/Significant_figures).
The Formulas question has no built-in function to display numbers with a given number of significant figures. However, it is easy to work out this function as the following variable assignment which works with any real number:
xr=x==0?x:round(x*pow(10,nsf-1-floor(log10(abs(x)))),0)*pow(10,-nsf+1+floor(log10(abs(x))));
where x is the number to be rounded, nsf the number of significant digits to keep and xr the resulting rounded value.
This example deals with the display of the correct answers with different numbers of significant figures.
The Formulas question should look like this:
Play it Login info (Open in new tab: Ctrl+Shift+Click)