Calculated question : adding new math functions: Difference between revisions
From MoodleDocs
Line 119: | Line 119: | ||
|- | |- | ||
|exp | |exp | ||
| | |||
| | |||
| | |||
| | |||
|Calculates the exponent of e | |Calculates the exponent of e | ||
|- | |- | ||
|expm1 | |expm1 | ||
| | |||
| | |||
| | |||
| | |||
|Returns exp(number) - 1, computed in a way that is accurate even when the value of number is close to zero | |Returns exp(number) - 1, computed in a way that is accurate even when the value of number is close to zero | ||
|- | |- | ||
|floor | |floor | ||
| | |||
| | |||
| | |||
| | |||
|Round fractions down | |Round fractions down | ||
|- | |- | ||
|fmod | |fmod | ||
| | |||
| | |||
| | |||
| | |||
|Returns the floating-point modulus of two numbers - i.e. the remainder when the first is divided by the second. | |Returns the floating-point modulus of two numbers - i.e. the remainder when the first is divided by the second. | ||
|- | |- | ||
|is_finite | |is_finite | ||
| | |||
| | |||
| | |||
| | |||
|Finds whether a value is a legal finite number | |Finds whether a value is a legal finite number | ||
|- | |- | ||
|is_infinite | |is_infinite | ||
| | |||
| | |||
| | |||
| | |||
|Finds whether a value is infinite | |Finds whether a value is infinite | ||
|- | |- | ||
|is_nan | |is_nan | ||
| | |||
| | |||
| | |||
| | |||
|Finds whether a value is not a number | |Finds whether a value is not a number | ||
|- | |- | ||
|log10 | |log10 | ||
| | |||
| | |||
| | |||
| | |||
|Base-10 logarithm | |Base-10 logarithm | ||
|- | |- | ||
|log1p | |log1p | ||
| | |||
| | |||
| | |||
| | |||
|Returns log(1 + number), computed in a way that is accurate even when the value of number is close to zero | |Returns log(1 + number), computed in a way that is accurate even when the value of number is close to zero | ||
|- | |- | ||
|log | |log | ||
| | |||
| | |||
| | |||
| | |||
|Natural logarithm (''ln'') | |Natural logarithm (''ln'') | ||
|- | |- | ||
|max | |max | ||
| | |||
| | |||
| | |||
| | |||
|Find highest value | |Find highest value | ||
|- | |- |
Revision as of 02:50, 12 December 2014
The calculated question type could benefit of the EvalMath module to increase the math functions useable in the Calculated, Simple calculated et Multiple choice calculated question types.
Available functions
Calculated questions can use more than simple arithmetic operators. The following functions are allowed in versions 1.5 and newer.
Function | 1,5+ | Eval
Math |
2.9 | tested | Explanation |
---|---|---|---|---|---|
abs | Absolute value | ||||
acos | Arc cosine -- output in radians. | ||||
acosh | Inverse hyperbolic cosine -- output in radians. | ||||
asin | Arc sine -- output in radians. | ||||
asinh | Inverse hyperbolic sine.-- output in radians. | ||||
atan2 | Arc tangent of two variables -- pass in two values like (y, x), and you'll get the atan(y/x), adjusted to the proper quadrant. (Note: The variables are in the reverse order to atan2(x,y) in Excel) Output is radians. | ||||
atan | Arc tangent -- output in radians. | ||||
atanh | Inverse hyperbolic tangent-- output in radians. | ||||
bindec | Binary to decimal | ||||
ceil | Round fractions up | ||||
cos | Cosine -- in radians!!! Convert your degree measurement to radians before you take the cos of it. | ||||
cosh | Hyperbolic cosine -- in radians!!! Convert your degree measurement to radians before you take the cosh of it. | ||||
decbin | Decimal to binary | ||||
decoct | Decimal to octal | ||||
deg2rad | Converts the number in degrees to the radian equivalent | ||||
exp | Calculates the exponent of e | ||||
expm1 | Returns exp(number) - 1, computed in a way that is accurate even when the value of number is close to zero | ||||
floor | Round fractions down | ||||
fmod | Returns the floating-point modulus of two numbers - i.e. the remainder when the first is divided by the second. | ||||
is_finite | Finds whether a value is a legal finite number | ||||
is_infinite | Finds whether a value is infinite | ||||
is_nan | Finds whether a value is not a number | ||||
log10 | Base-10 logarithm | ||||
log1p | Returns log(1 + number), computed in a way that is accurate even when the value of number is close to zero | ||||
log | Natural logarithm (ln) | ||||
max | Find highest value | ||||
min | Find lowest value | ||||
octdec | Octal to decimal | ||||
pi() | Get value of pi - the function does not take an argument, like in Excel. | ||||
pow (numberToRaise, NumberRaisedTo) | Exponential expression | ||||
rad2deg | Converts the radian number to the equivalent number in degrees | ||||
rand | Generate a random integer | ||||
round | Rounds a float | ||||
sin | Sine -- in radians!!! Convert your degree measurement to radians before you take the sin of it. | ||||
sinh | Hyperbolic sine -- in radians!!! Convert your degree measurement to radians before you take the sinh of it. | ||||
sqrt | Square root | ||||
tan | Tangent -- in radians!!! Convert your degree measurement to radians before you take the tan of it. | ||||
tanh | Hyperbolic tangent -- in radians!!! Convert your degree measurement to radians before you take the tanh of it. |