-
-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a parserLogb.pl
macro for logarithms with base b.
#1147
base: develop
Are you sure you want to change the base?
Conversation
af19abe
to
cc0123a
Compare
cc0123a
to
bf63330
Compare
bf63330
to
9d0ec6e
Compare
I find that I have to set
before I run
Here is the file I am testing with:
|
Something came up today where a person used |
9d0ec6e
to
b604fd6
Compare
I tested with your sample code, and I do not see any errors or warnings about undefined HASH references. The I am not sure that I agree to adding |
Ahh, you may need to restart the webwork2 app to get the changes in this pull request to take effect (if you are not using |
Yeah, oops. I had not restarted |
b604fd6
to
b08d196
Compare
This is similar to the `parserRoot.pl` macro. To enable the usage of the `logb` function in the current context call `Parser::Logb->Enable`. You can call `$n = logb(3, 5)` to get the value of the logarithm with base 3 evaluated at 5, or `$ans = Compute("logb(3, 5)")` to use as an answer. You can also call `Parser::Logb->EnableComplex` to allow negative bases and evaluation at negative numbers. Note that attempting to use a negative base or evaluate at a negative number would otherwise produce an error message. An answer in this context will automatically have the MathQuill option `logsChangeBase => 0` set. To facilitate this without the need to have numerous special cases for contexts in the `ENDDOCUMENT` method of `PG.pl`, there is a new `mathQuillOpts` context flag. The default value for this flag is a reference to a hash with no keys. Any context can set keys in this hash, and those will be tranferred to the MathQuill options for any answer rule in the context. This is now used by the the `parserRoot.pl` macro to set `rootsAreExponents => 0`, and by the new `parserLogb.pl` macro to set `logsChangeBase => 0`. To facilitate students entering a logarithm with a base, if the `logsChangeBase` option is 0 (or not set), then a subscript button is added to the MathQuill toolbar.
b08d196
to
241bcb1
Compare
This is similar to the
parserRoot.pl
macro. To enable the usage of thelogb
function in the current context callParser::Logb->Enable
.Then you can call
$n = logb(3, 5)
to get the value of the logarithm with base 3 evaluated at 5, or$ans = Compute("logb(3, 5)")
to use as an answer.You can also call
Parser::Logb->EnableComplex
to allow negative bases and evaluation at negative numbers. Note that attempting to use a negative base or evaluate at a negative number would otherwise produce an error message.An answer in this context will automatically have the MathQuill option
logsChangeBase => 0
set. To facilitate this without the need to have numerous special cases for contexts in theENDDOCUMENT
method ofPG.pl
, there is a newmathQuillOpts
context flag. The default value for this flag is a reference to a hash with no keys. Any context can set keys in this hash, and those will be tranferred to the MathQuill options for any answer rule in the context. This is now used by the theparserRoot.pl
macro to setrootsAreExponents => 0
, and by the newparserLogb.pl
macro to setlogsChangeBase => 0
.To facilitate students entering a logarithm with a base, if the
logsChangeBase
option is 0 (or not set), then a subscript button is added to the MathQuill toolbar.Note that MathQuill is already set up to output the text
logb(b, x)
iflog_b(x)
is entered.