You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Restructured content and added the workaround for reserved terms. (#222)
* Restructured content and added the workaround for reserved terms.
* GH-221 Actioned Peter's comments in #222.
* GH-221 Refactored README to separate implicit multiplication
* Added note about #223 in the docs
Copy file name to clipboardExpand all lines: app/docs/user.md
+58-25Lines changed: 58 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,13 +21,15 @@ If you want to use `I` for the imaginary constant, set the grading parameter `co
21
21
22
22
Changes the implicit multiplication convention. If unset it will default to `equal_precedence`.
23
23
24
-
If set to `implicit_higher_precedence` then implicit multiplication will have higher precedence than explicit multiplication, i.e. `1/ab` will be equal to `1/(ab)` and `1/a*b` will be equal to `(1/a)*b`.
24
+
If set to `implicit_higher_precedence` then implicit multiplication will have higher precedence than explicit multiplication, i.e. `1/ab` will be equal to `1/(ab)` and `1/a*b` will be equal to `(1/a)*b`.
25
+
26
+
**_NOTE:_** Currently, if implicit multiplication has higher precedence, then multi-character custom symbols are not supported. For example, if you have defined the symbol `bc` with an answer `a/(bc*d)` then `a/(bcd)` will fail, as it is treated as `a/(b * c * d)`.
25
27
26
28
If set to `equal_precedence` then implicit multiplication will have the same precedence than explicit multiplication, i.e. both `1/ab` and `1/a*b` will be equal to `(1/a)*b`.
27
29
28
30
#### `criteria`
29
31
30
-
The `criteria` parameter can be used to customize the comparison performed by the evaluation function. If unset the evaluation function will will default to checking if the answer and response are symbolically equal.
32
+
The `criteria` parameter can be used to customize the comparison performed by the evaluation function. If unset the evaluation function will default to checking if the answer and response are symbolically equal.
31
33
32
34
The `criteria` parameter takes a string that defines a set of (comma separated) mathematical statements. If all statements in the list are true the response is considered correct.
33
35
@@ -498,7 +500,7 @@ $3$
498
500
499
501
If the parameter `complexNumbers` is set to `true` then `I` will be interpreted as the imaginary constant $i$.
500
502
501
-
**Note:** When `i` is used to denote the imaginary constant, then it can end up forming reserved keywords when used with other symbols, e.g. `xi` will be interpreted as $\xi$ instead of $x \cdot i$. To see how to avoid this kind of issue, see *Overriding greek letters or other reserved symbols with input symbols*.
503
+
**Note:** When `i` is used to denote the imaginary constant, then it can end up forming reserved keywords when used with other symbols, e.g. `xi` will be interpreted as $\xi$ instead of $x \cdot i$. To see how to avoid this kind of issue, see [Working with Reserved Characters](#workiing-with-reserved-characters).
502
504
503
505
In this example, `complexNumbers` is set to `true` and the answer is `2+I`. An input symbols has also been added so that `I` can be replaced with `i` or `j`.
504
506
@@ -510,26 +512,6 @@ Any response that is mathematically equivalent $2+i$ to will be accepted, e.g. `
510
512
511
513
Examples of how to use the `constant` and `function` assumptions for symbols.
512
514
513
-
#### Overriding greek letters or other reserved symbols with input symbols
514
-
515
-
Sometimes there can be ambiguities in the expected responses. For example `xi` in a response could either be interpreted as the greek letter $\xi$ or as the multiplication $x \cdot i$.
516
-
517
-
If there is an ambiguity the parser will choose the longest corresponding string, in the example above that means that `xi` will be interpreted as $\xi$ rather than $x \cdot i$.
518
-
519
-
This behaviour can in many cases be overridden using input symbols, by letting the meaning with the longer corresponding string be an alternative to the interpretation consisting of several shorter strings. In the above example adding an input symbol with code `x\*i` and alternative `xi` will ensure that `xi` will be interpreted as $x \cdot i$ rather than $\xi$.
520
-
521
-
In this example the answer is set to $5 x \mathbf{i}-12 y \mathbf{j}$, while `strict_syntax` is set to false and `elementary_functions` is set to true.
522
-
523
-
In order for the response `5xi-12yj` to be interpreted as $5 x \mathbf{i}-12 y \mathbf{j}$ instead of $5 \xi-12 y \mathbf{j}$ the following input symbols have been added:
524
-
525
-
| Symbol | Code | Alternatives |
526
-
|:--------------------|:-----|:-------------|
527
-
|`\$x\$`| x ||
528
-
|`\$\\mathbf{i}\$`| i ||
529
-
|`\$x \\mathbf{i}\$`| x\*i | xi |
530
-
|`\$y\$`| y ||
531
-
|`\$\\mathbf{j}\$`| j ||
532
-
533
515
#### Comparing equalities involving partial derivatives - Using the `constant` and `function` assumptions
534
516
535
517
The response should be some expression that is equivalent to this equation (i.e. `answer`):
@@ -620,7 +602,58 @@ Here is an example of an integral that can be fully evaluated, more specifically
620
602
621
603
The boundary and function does not need to be defined explicitly. As an example of a more abstract integral we can consider $\int_a^b f(x)+g(x) \mathrm{d}x$. If the answer is set to `Integral(f(x)+g(x), (x, a, b))` then, for example, `int(g(x)+f(x), (x, a, b))` $\int_a^b g(x)+f(x) \mathrm{d}x$ and `int(f(x), (x, a, b)) + int(g(x), (x, a, b))` $\int_a^b f(x) \mathrm{d}x+\int_a^b g(x) \mathrm{d}x$.
622
604
623
-
## Euler's number
605
+
##Working with Reserved Characters
624
606
625
-
SymPy recommends that you not use I, E, S, N, C, O, or Q for variable or symbol names, as those are used for the imaginary unit, the base of the natural logarithm, the sympify function, numeric evaluation, the big O order symbol, and the assumptions object that holds a list of supported ask keys, respectively. You can use the mnemonic OSINEQ to remember what Symbols are defined by default in SymPy. Or better yet, always use lowercase letters for Symbol names. Python will not prevent you from overriding default SymPy names or functions, so be careful."
607
+
SymPy recommends that you not use I, E, S, N, C, O, or Q for variable or symbol names, as those are used for the imaginary unit ($i$), the base of the natural logarithm ($e$), the sympify function (`S()`), numeric evaluation (`N()`), the big O order symbol (as in $O(n)$), and the assumptions object that holds a list of supported ask keys (such as `Q.real`), respectively. You can use the mnemonic OSINEQ to remember what Symbols are defined by default in SymPy. Or better yet, always use lowercase letters for Symbol names. Python will not prevent you from overriding default SymPy names or functions, so be careful."
626
608
For more information checkout the [SymPy Docs](https://docs.sympy.org/latest/explanation/gotchas.html#predefined-symbols)
609
+
610
+
If you want to use a symbol that is usually reserved for some reserved character, e.g. ‘E’, do as follows:
611
+
1. Create an input symbol where the code is different that the symbol you want to use, e.g. ‘Ef’ or 'Euler' instead of ‘E’
612
+
2. Add the symbol you want to use as an alternative, e.g. the alternatives could be set to ‘E’
613
+
614
+
#### Example:
615
+
For the answer:
616
+
$A/(E*l)$, $E$ is reserved, so we replace $E$ with $ef$ and provide alternatives as input symbols:
617
+
618
+
Symbol: $ϵ$
619
+
620
+
Code: `ef`
621
+
622
+
Alternatives: `ϵ,ε,E,e,Ep`
623
+
624
+
Here the answer $A/(E*l)$ is marked as correct.
625
+
626
+
627
+
### Reserved Characters and Implicit Multiplication
628
+
As implicit multiplication cannot decypher what is a multi-character code and what are two variables that should be multiplied, single letter codes should be used.
629
+
630
+
#### Example
631
+
With `"convention": "implicit_higher_precedence"` set
632
+
633
+
For the answer:
634
+
$A/(E*l)$ $E$ is reserved, so we replace $E$ with $b$ and provide alternatives as input symbols:
635
+
Symbol: ϵ
636
+
Code: b
637
+
Alternatives: ϵ,ε,E,e,Ep
638
+
639
+
Here the answer A/El is marked as correct.
640
+
641
+
### Overriding greek letters or other reserved symbols with input symbols
642
+
643
+
Sometimes there can be ambiguities in the expected responses. For example `xi` in a response could either be interpreted as the greek letter $\xi$ or as the multiplication $x \cdot i$.
644
+
645
+
If there is an ambiguity the parser will choose the longest corresponding string, in the example above that means that `xi` will be interpreted as $\xi$ rather than $x \cdot i$.
646
+
647
+
This behaviour can in many cases be overridden using input symbols, by letting the meaning with the longer corresponding string be an alternative to the interpretation consisting of several shorter strings. In the above example adding an input symbol with code `x\*i` and alternative `xi` will ensure that `xi` will be interpreted as $x \cdot i$ rather than $\xi$.
648
+
649
+
In this example the answer is set to $5 x \mathbf{i}-12 y \mathbf{j}$, while `strict_syntax` is set to false and `elementary_functions` is set to true.
650
+
651
+
In order for the response `5xi-12yj` to be interpreted as $5 x \mathbf{i}-12 y \mathbf{j}$ instead of $5 \xi-12 y \mathbf{j}$ the following input symbols have been added:
0 commit comments