Mathematical question
  • 12 Jan 2023
  • 50 Minutes to read
  • Contributors
  • Dark
    Light
  • PDF

Mathematical question

  • Dark
    Light
  • PDF

Article Summary

Advanced mathematical question type, powered by SOWISO.

The SOWISO question type for the exact sciences is an open ended item that allows the answers to be in the form of formulas.

The answers can be scored and checked automatically and can be accompanied with targeted feedback.

Moreover, questions can be created with random parameters, that make every question unique. Read more about 'What types of questions Sowiso items can be used for?"

This manual describes the different options for the Sowiso maths question in Cirrus:

What types of questions can Sowiso items be used for?

Sowiso questions are useful for questions requiring assessment of the answer within one of the domains listed below. Also read our note on some differences between Sowiso questions in Cirrus and Sowiso stand-alone usage.

  • (decimal) numbers (using ranges)
  • complex numbers
  • expressions/formulas using variable(s), constants (e, i, pi) en subscript
  • sum en product calculations
  • comparisons en inequality / odds
  • trigonometric functions
  • system of linear equations
  • mathematical logic
  • algebra: vectors and matrices
  • intervals
  • Latin and Greek characters
  • lists and collections
  • limits
  • differential and integral calculus

Enabling Sowiso Maths Item

To start using the Sowiso Maths Item please reach out to your Cirrus contact for commercial details before we can fully enable this.

When using the SOWISO (Maths) Item in Cirrus please be aware that the decimal delimiter will be a point (.) no matter your environment's or user's Regional Settings.

SOWISO will train you and can help you develop questions. Alternatively you can import your SOWISO questions into Cirrus or buy large sets of pre-developed content, just sent us a mail.

Important differences between Sowiso questions in Cirrus and Sowiso stand-alone usage

The Sowiso 'maths' question is a unique collaboration with our partners at sowiso. Please be aware that the integration has some limitations because of usage and (technical) setup:

  • Sowiso questions are not meant to be used for questions requiring the candidate to draw an answer.

  • This question type in Cirrus is based on what Sowiso calls the exercise type 'open':

image.png

  • If you are familiar with Sowiso please be aware of this and do not use other Sowiso excercise types to import in Cirrus.

  • Also Sowiso has elaborate table layout opportunities. Be aware that this does not translate 1:1 to the table editor in Cirrus. When you want to import questions made in Sowiso keep it simple or have your question fully finished before importing them into Cirrus.

Formative versus Summative mathematical questions and their delivery

There is an important difference between sowiso questions that are set to formative instead of summative:

A formative sowiso question like any formative question in Cirrus will only be available when creating an assessment of type  'formative' or 'mixed'.
When taking their assessment candidates can (have to) press a 'Check' button. They are allowed to practice the singular (formative) question an unlimited amount of times - thought this will of course lead to less time for the other question in the assessment. Only the last given answer will be stored as the given answer in Cirrus.

Question Tab of your Sowiso Maths Item

The 'Question' tab allows you to edit different placeholders in an exercise:
Screenshot 2021-09-03 at 15.39.37.png
The following fields/options are available under ‘Question’:

  1. Question is the text the user gets to see during the assessment

  2. Settings - is where you set the maximum score for this question

  3. Solution (text) this solution text is shown to the candidate if setup by the author of an assessment to:

    1. Show directly after the exam on detailed results report
    2. On the Candidate's Dashboard > Completed > detailed tab
  4. Pre and post input are the texts before and after the answer field (for example for x= ... ,  or for a unit, like …. meters).

  5. Solutions - The Solutions area is where you define what the correct answer is.

    1. Choose an 'Evaluation type' for the mathematical area from the dropdown-list. Evaluation types are used to interpret the answer and give appropriate feedback. on evaluation types below, including a list of evalutation types.
    2. Evaluation type in combination with the Definition field is used to define the correct answer.
    3. You can add multiple solution rules via‘'Add solution' to score multiple answers as correct.
      Screenshot 2021-09-03 at 16.23.28.png

Input of formulas in a Sowiso maths question

When you enter the formulas in a sowiso maths question, you need to use the appropriate LaTex and Tex or asciimathml delimiters:

LaTex and TeX delimiter:

  • inline math opens and closes with #, or opens with ( and closes with ). Use the delimiters [ ] or ## ## for display math with centered alignment on a separate line. If you want inline math to be centered, you can use the html Align center option () of the editor. If you want inline math to be printed as displaymath, you can use the \displaystyle command before the TeX
  • e.g. for #\frac{1}{2}=0.5#, use #\frac{1}{2}=0.5#

asciimathml delimiter:

Variables Tab

In the Variables tab you can define variables that can be use to randomise your question content.

To create a new variable go to the Variables tab and click the Add variable button. Variables are named alphabetically and a new variable will be created with the name next in line of the alphabet. i.e. when variables $a, and $b already exist variable $c will be created.

Variables have an id and four fields to maintain:

  1. id: is a letter from the alphabet. Whenever you want to reference this variable, use the id of the variable with a a. After $v, the variable list continues with wa, wb, etc. The maximum number of variables per exercise is 126.
  2. definition:: here you define the value of the variable by using valid php syntax. You can use php (math) functions, as described here:
  • e.g. to create a random variable between 1 and 10, use the function rand(1,10).
  • Existing variables can be used in the definition. e.g. if variable
  • $a = rand(1,10), then $b can be
  • a,10).
  • Extra functions created by SOWISO are available via the prefix sw_. A list of extra functions can be found at the end of this document.
  1. decimals: In case the result of the variable is a float, this field sets the number of decimals. Note that when a variable is used in another variable, the variable is not rounded. Only when the variable is used outside other variables (in texts and definition fields of rules) it will be rounded. e.g.
    b = 7$a = 1.00 with 2 decimals*
  2. If you want an explicit rounding, use the php round($value, $precision, $roundmode) function.
  3. trailing zeros checkbox: when checked and the number of decimals is larger than 0, trailing zeros are removed from the end of any float value. e.g. 1.200 => 1.2

Feedback Rules Tabs

When answers are evaluated, the answers goes through the following flow:
image.png

  1. The user inserts a formula using the keyboard and optionally, also the virtual keyboard. When the answer contains a syntax error, this is immediately show on screen.
  2. a. based on the selected  evaluation type, sometimes feedback can be given for an incorrect form. For example. for some evaluation types it is always necessary to get the answer in the form of an equation.
    If this is not the case, default feedback will be given.
    b. the solution rules are checked for mathematical equivalence.
  3. If a positive feedback rule is hit, the corresponding feedback is presented and the user is not ´finished´ with the exercise in a formative assessment, or in a summative assessment he will only get a partial score (or 0).
  4. If a negative feedback rule is hit, the corresponding feedback is presented and the user is not ´finished´ with the exercise, or in a summative assessment he will get a score of 0.
  5. Finally, if the answer is correct according to the solution(s) and no positive feedback rules are hit, the answer is marked correct, the student is ´finished´ with the exercise and can progress, or receives the full score in a summative assessment.

Evaluation types

Feedback rules are used to interpret the answer and give appropriate feedback. You can maintain the following fields to define a feedback rule:

  • Definition: this is an input field, where the required input depends on the chosen evaluation type. See the table below. A feedback rule can be skipped during the evaluation by letting the definition begin with the keyword ignore. This can be useful when you need to apply a rule based on your variables.
  • Feedback Category: this is the Feedback Category the rule belongs to. It is used in reporting, but you can also use it to inject predefined feedback texts, see Custom feedback text underneath.
  • Priority: is some cases, multiple rules can apply to an answer, but only one rule per time can be hit. In those cases, you can set the priority to determine what rule has precedence: the lower the number in the Priority field, the higher the priority.
  • Answer field: in case you have more than 1 answer field in the exercise, you can choose the field to apply the rule to here.
  • Evaluation type: See the table below.
  • Opposite evaluation: This negates the working of the rule. For instance, if you select evaluation type "is not a number", the rule is hot when the answer is not a number. However, when you select "Opposite evaluation", the rule is hit when the answer is a number.
  • Test usage: Select this option to apply this rule when the exercise is used in tests. When selected, you can choose a desired partial score when the answer hits this rule.

Evaluation types

For mathematical answers the evaluation types are listed in the table underneath. In case of relations like equations or inequalities, you can specify a rule to only apply to a side of the relations using rhs: for right hand side or lhs: for left hand side, before the definition. e.g. contains_var with Definition *rhs:x *checks for the variable x in only the right hand side.

namedescriptionautomated feedback
contains_bracketsChecks whether the user input contains brackets. Note that brackets for function arguments like ln() also count as brackets. With no arguments at least one occurrence triggers the rule. With one argument, the argument defines the number of bracket pairs that occur, optionally specified by one of le, lt, ge, gt, ne, eq, <=, >=, <>, ==, !=, <, >, =
contains_floatChecks whether the user input contains floats. With no arguments at least one occurrence triggers the rule. With one argument, the argument defines the number of occurrences, optionally specified by one of le, lt, ge, gt, ne, eq, <=, >=, <>, ==, !=, <, >, =
contains_integerChecks whether the user input contains integers. With no arguments at least one occurrence triggers the rule. With one argument, the argument defines the number of occurrences, optionally specified by one of le, lt, ge, gt, ne, eq, <=, >=, <>, ==, !=, <, >, =
contains_numberChecks whether the number in the Definition field is present in the user input. Works for both positive and negative floats and integers.
Without argument (Definition field is empty), at least one occurrence of a number in the answer triggers the rule.
With two arguments (; separated) , the second argument defines the number of occurrences. e.g. 2;2 optionally specified by one of le, lt, ge, gt, ne, eq, <=, >=, <>, ==, !=, <, >, =. eg. 2; le 2
contains_one_base_powerAnswer contains exactly one power at the base.
contains_symbolChecks whether the user input contains the symbol from the Definition field.
With one argument, at least one occurrence triggers the rule. e.g. minus
With two arguments (; separated) , the second argument defines the number of occurrences. e.g. minus;2, optionally specified by one of le, lt, ge, gt, ne, eq, <=, >=, <>, ==, !=, <, >, =. eg. minus; le 2.
With a list in the Definition field like [arg1,arg2], each element will be treated as an argument like above, where the arguments will be treated as an OR. i.e. [cos;lt2,sin;lt2] is whether either sin or cos occur less than two times.
Alternatively, the occurrence can be placed after the list, like so [arg1,arg2];lt2. e.g. [sin,cos];lt2 checks whether sin or cos together occur less than two times.
The symbol is one of
operators: abs, divide, minus, plus, power, root, times, unary_minus, factorial
relations: approx, eq, geq, gt, leq, lt, neq
trigonometry: arccos, arcsec, arcsin, arctan, cos, cot, sec, sin, tan
logarithms: ln, log
numbers: e, i, infinity, pi
linear algebra: matrix,vector
logic: and, equivalent, false, implies, not, or, true, xor
sets: N, Q, R, Z, cartesian_product, in, intersect, notin, notsubset, set, setdiff, size, subset, union, emptyset, suchthat, list
limits: limit, null, lambda
permutations: permutation, cycle
units: degree

You kind find the symbols in a student answer using the editor.
contains_symbol_other_thanThe user answer does not contain any other symbol than the one in the list in the Definition field, separated by ;, e.g. plus;minus means that only the symbols plus or minus may be present in the user`s answer. The symbol is one the list as specified in the contains_symbol evaluation type.
contains_symbol_withinChecks if the second operator in the definition field is present in the first operator of the answer. i.e. times,plus checks whether there is a multiplication that has a plus as a descendant.
The second argument can be a list, where multiple symbols can be searched with an OR. The third argument optionally specifies the position of the child. i.e. times,[plus,minus] checks whether there is a multiplication that has a plus or a minus as a descendant. divide,[plus,minus],2 checks whether the denominator of a fraction is a plus or minus or has one in it.
contains_variableChecks whether the user input contains the variable from the Definition field.
Without argument (Definition field is empty), at least one occurrence of a variable in the answer triggers the rule.
With one argument, at least one occurrence triggers the rule. e.g. x
With two arguments (; separated) , the second argument defines the number of occurrences. e.g. x;2, optionally specified by one of le, lt, ge, gt, ne, eq, <=, >=, <>, ==, !=, <, >, =. eg. x;gt 2

With a list in the Definition field like [arg1,arg2], each element will be treated as an argument like above, where the arguments will be treated as an OR. i.e. [x;lt2,y;lt2] is whether either x or y occur less than two times.
Alternatively, the occurrence can be placed after the list, like so [arg1,arg2];lt2. e.g. [x,y];lt2 checks whether x or y together occur less than two times.
contains_variable_in_symbolChecks if the variable in the definition field is present in the first operator/symbol of the answer. i.e times,x checks whether there is a multiplication that has a variable x as a descendant. The second argument can be a list, where multiple symbols can be searched with an OR. The third argument optionally specifies the position of the child. i.e. times,[x,y] checks whether there is a multiplication that has a variable x or a variable y as a descendant. divide,[x,y],2 checks whether the denominator of a fraction has a variable x or a variable y in it.
contains_variable_other_thanThe user answer does not contain any other variable than the one in the list in the Definition field, separated by ;, e.g. x;y means that only the variables x or y may be present in the user answer.
default_incorrectAlways reacts on wrong answers and has a predefined priority of 99.
eq_one_sideOne side of the equation must be equal to the variable in the Definition. e.g. x means the the answer must be either something like x=...x=... or ...=x...=x
eval_domainChecks whether the user input is equal to the domain in Definition field where both should be in the form of a simplified equation in the disjunctive normal form with only one variable, e.g. x=3 or x=-3.
eval_eq_exactCheck whether solutions indicated in the Definition field are solutions to the equation in the user input, using substitution. Define a list of equations in the Definition field that should be substituted in the equation the user input.
eval_eq_numericNumerical check whether solutions indicated in the Definition field are solutions to the equation in the user input. The Precision field indicates the accepted margin of error. Define a list of variables in the Definition field that should be substituted in the equation the student answers. e.g. [x=3,y=4] when correct answer: x2+y=13x2+y=13.
eval_exactExact mathematical comparison of expression in the Definition field with user input. No simplification rules are applied to the student answer.
eval_graphsLines: Checks whether each pair of points from the user input is on a line defined in the Definition field and whether each line in the Definition fields has two points in the user input. e.g. x=y+1
Points: Checks whether each point from the user input is defined once in the Definition field. e.g. [2,1]
Vector: Checks whether the start and end point of the vector from the user input is defined in the Definition field via a 2x2 matrix. Define the vector via a matrix e.g. matrix([0,0],[2,1])
eval_intervalChecks whether the interval provided by the student is equal to that in the Definition field, where the Definition is specified as a 1st or 2nd degree (in)equality. The variable you use is free, as long you do not use more than one. e.g. x^2+3*x >= 0 for [0,)(,3][0,)(,3] Note that automatic feedback is given for answers that have [[ or ]].
eval_lin_eqsEvaluate a system of linear equations. As a Definition, write the maxima equations in disjunctive normal form, and after that write a ";" with a list of variables in "[]" and separated with a comma ",". e.g. (2*x=2) and (3*y=2) and (2*z=5) ; [x,y,z] Optionally, use a third argument and set it to 1 to escape the mandatory final form of the answer.
eval_listChecks if the answer is a list and if each expression is equal to the expression at the same index in the list of the Definition field, using eval normal. The list in the Definition field should be comma "," separated. e.g. [2,3,1]. Note that this evaluation types automatically checks for the right input form (list or vector) and the length of the list and gives appropriate feedback accordingly.
eval_logic_equivComparison of logical form in the Definition field with normal form of user input.
eval_matrixCheck if the matrix from the Definition field is equal to the answer. Can be used with fb_matrix for feedback. It accepts input of matrix or a list of lists. e.g. matrix([1,2,3],[4,5,6]) or [[1,2,3],[4,5,6]]
eval_matrix_elementNumerically compares the [row,column] entry of the matrix from the user input [row,col]=...with the number represented by the expression in the Definition field.
E.g. [1,1]=2 means that the value 2 must be equal to the matrix element on dimension [1,1]
eval_normalExact mathematical comparison of normal form of expression in the Definition field with normal form of user input. e.g. x^2.
eval_numericNumeric comparison of expression in the Definition field with user input, e.g. 2*3.
The Precision field defines the accepted absolute value of the margin of error for numerical answers, e.g. if the correct answer is 1, you can use 0.1 to accept all answers between 0.9 and 1.1.
If any of the Range fields are used (not 0 or empty), the system checks whether the answer is within the range.
eval_openmathComparison between the OpenMath xml object in the Definition field and the result object of the student input in the formula editor. To create a solution, get the Transformed OpenMath from the editor here.
eval_param_repEvaluate a parameter representation of the solution set of a list of linear equations. In the Definition field, use 2 arguments (separated with a ;), where the first is the list of linear equations [eq1,eq2,...] and the second is a list of the coordinates [x,y,...]. Optionally, you can add a third argument to prescribe the parameters that may be used, like [lambda,mu]. e.g. [z-y+2*x-1=0,3*z+11*y-4*u+9=0];[x,y,z,u] or with a third argument [z-y+2*x-1=0,3*z+11*y-4*u+9=0];[x,y,z,u];[lambda,mu]
eval_polynomialAutomated polynomial checker that can be used together with fb_polynomial. In the Definition field a (multivariate) polynomial is entered to specify the correct answer. Then you can create just one positive and one negative feedback rule in with evaluation type fb_polynomial that will provide automated feedback. Feedback works for basic, free (any polynomial), expanded and factored form. See fb_polynomial for more information about these form types.
eval_rational_functionAutomated checker for rational functions that can be used together with fb_rational_function. In the Definition field a rational function is entered to specify the correct answer, e.g. (x^2+1)/(x+6). Then you can create just one positive and one negative feedback rule in with evaluation type fb_rational_function that will provide automated feedback. Feedback works for basic, combined , split and quotient form. See fb_rational_function for more information about these form types.
eval_statementEvaluate the maxima statement in the Definition field, where the user input can be referenced using answer for the answer that belongs to the rule, or answers for alist of the answers in all answer fields like [1,2,3]. In case an answer value is empty, the answer value to maxima gets replaced with %null in the answers list. A simple example of the usage of answer is e.g. elementp(answer,{sin(1),sin(2),sin(3)}). Or you can write your own maxma block function. For instance, you can differentiate the answer to check if it is a valid integral by automatically differentiation away the constants. e.g. for the integral of sin(x)sin(x) you could use
block(adiff:diff(answer,x),is(radcan(adiff-(sin(x)))=0))
to allow for all answer that are correct after differentiating them, like cos(x)+ccos(x)+c, but also cos(x)+Ccos(x)+C

Normally the answer field specifies the answer.
For input graphs all answers are checked against the statement and the answer form is
Lines: [[x_1,y_1],[x_2,y_2]]
Points: [x,y]
Vector: [[x_1,y_1],[x_2,y_2]]
eval_unitsConverts the answer to base units and the compares the value and unit. For units support, maxima's ezunits package is used. In the Definition field you can specify the solution with a backtick ` between the value and the unit, like 1`g.
The Precision field defines the accepted absolute value of the margin of error in terms of the base unit specified in the Definition field, e.g.
Definition 10`g with Precision 0.1 accepts all answers between and including 9.9 and 10.1 grams.
If any of the Range fields are used (not 0 or empty), the system checks whether the answer is within the range. e.g.
Low 0.9`m and High 1.2`m accepts all answers between 0.9 and 1.2 meter.
For supported units and their notation, have a look at the Units table.
eval_vector_repChecks whether the vector representation of the user input corresponds to the line defined by the linear equation in x and y in the Definition field. e.g. y+3*x=1
eval_vector_linChecks whether the two dimensional vector of the user input and the two dimensional vector in the Definition field are linearly dependant. e.g. [2,1]
fb_genericProvides automatic negative feedback on the student answer. The student answer will be compared with the expression in the Definition field of this feedback rule. This feedback type is particularly good at pointing out minor mistakes in the student answer. Use the Precision field to indicate a minimum percentage of similarity between the Defintion and the answer at which the feedback kicks in (0 is the default).
fb_lin_eqsUse only with a solution rule that uses evaluation type eval_lin_eqs to give feedback the following specified cases. Use one of the following in the Definition field.
- 1 or nonlinear: the answer contains a nonlinear equation
- 2 or toobig: each solution of the original system of equations occurs in the answer, but at least one solution of the answer is not a solution of the original system
- 3 or toosmall: each solution of the answer is correct, but at least one solution of the original system does not appear in the answer
- 4 or incomparable: the answer is incomparable
- 5 or strangevar: the answer contains a variable that is not an unknown
- 6 or noequation: at least one of the expressions separated by the logic symbols is not an equation
- 7 or andornestingtoodeep: the nesting of the logic symbols is too complicated. We only accept answers in which the or symbol never appears in an expression that consists of two or more parts separated by an and symbol
fb_matrixUse only with a solution rule that uses evaluation type eval_matrix to give feedback the following specified cases. Use one of the following in the Definition field.
- 2 or wrong_length: answer does not have the same dimensions as the matrix in the Definition field of the solution
- 3 or wrong_matrix: answer does have the right dimensions but is wrong
- 4 or no_matrix: The answer does not evaluate to a matrix.
fb_param_repUse only with a solution rule that uses evaluation type eval_param_rep to give feedback the following specified cases. Use one of the following in the Definition field.
- 2 or no_vector: answer is not a vector
- 3 or wrong_length: answer does not have the right length
- 4 or wrong_basevec: the base vector of the answer is not a solution of the equations
- 5 or too_few_params: answer does not have enough parameters
- 6 or too_many_params: answer has too many parameters
- 7 or wrong_params: the parameters in the answer are not as required
- 8 or non_linear: answer is non-linear on one of the parameters
- 9 or wrong_vector: answer has at least one vector that is not a solution of the equations
- 10 or lin_dep: the direction vectors in the answer are linearly dependent
fb_polynomialProvides automated feedback coming from eval polynomial in the solution. The value in the Definition specifies what type of polynomial form is desired. The value in the Definition van be
free: Polynomial in free form. Performs no form checks.
basic: Polynomial in basic form. Positive/Negative feedback checks are the same:
  • Invalid variables
  • Missing variables
  • Invalid operations
  • Non-constant exponents
  • Dividing by non-constants
  • Non-integer exponents
  • Negative exponents
expanded: Polynomial in expanded form.
Positive feedback checks:
  • All basic checks
  • Check for non-atoms under exponents, i.e. (x y)^3
  • Check for multiplication by non-constant non-atoms, i.e. (x + 1) 2
  • Check for variables appearing twice in multiplication, i.e. x^2 y x^3
  • Check for monomials appearing multiple times, i.e. x + x + x
Negative feedback checks:
  • All basic checks
  • Check if degrees match
  • Check if there are superfluous monomials
  • Check if there are monomials missing
  • Check for wrong coefficients
factored_basic: Polynomial in factored form.
Postive feedback checks:
  • All basic checks
  • Check if polynomial is factorized more then the authors answer.
  • Performs positive feedback checks for expanded polynomial against each factor.
Negative feedback checks:
  • All basic checks
  • Check if all factors divide the authors answer.
  • Check if there are factors missing.
  • Check if the constant is right.
factored_basic_count: Sames as factored_basic, but with an extra positive feedback check if the number of factors are correct.

factored_expanded: Polynomial in factored form.
Postive feedback checks:
  • All basic checks
  • Check if polynomial is factorized more then the authors answer.
Negative feedback checks:
  • All basic checks
  • Check if all factors divide the authors answer.
  • Check if there are factors missing.
  • Check if the constant is right.
factored_expanded_count: Sames as factored_expanded, but with an extra positive feedback check if the number of factors are correct.
fb_rational_functionUse only with a solution rule that uses evaluation type eval rational function to give feedback on the following specified cases. Use one of the following in the Definition field:
- basic: Answer should be constructed using standard operations [+, -, *, /] and raising to integral exponents
- combined: Answer should be given as P / Q with P, Q coprime polynomials.
- split: Answer should be given as a sum P + sum P_{ij} / Q_i^j, with the Q_i irreducible and deg(P_{ij}) <= deg(Q_i).
- quotient: Answer is p/q with p and q polynomials. Not necessarily coprime.
fb_solve_in(eq)
previously called domain_dependence
Use only with a solution rule that uses evaluation type solve_inequality or solve_equality to give feedback on how the domain of the answer compares to the domain of the solution. Use one of the following in the Definition field.
- 0 or none: the answer domain is neither in nor around the solution domain
- 2 or inside: The answer is in the solution domain, but it does not contain it; it is too small.
- 3 or contains: The answer contains the solution domain, but is not contained in it; it is too big.
fraction_denominatorChecks whether the user input contains a fraction with another denominator as defined in the Definition field. e.g. 4
fraction_diff_denominatorsWhen the user input has more than one fraction, it checks whether all fractions have the same denominator.
fraction_is_improperChecks whether the absolute value of all fractions in user input is greater than or equal to one
fraction_lcm_not_usedChecks for each fraction in user input if the denominators are not equal to or greater than the number in the Definition field.
fraction_not_simplifiedChecks whether all fractions in the user input are simplified. In the Definition field you can use the same values as for is_not_simplified_fraction to control what type of fractions are considered simplified.
is_decimal_lengthChecks whether the user input is a float with the same number of decimals as specified in the Definition field, optionally specified by one of le, lt, ge, gt, ne, eq, <=, >=, <>, ==, !=, <, >, =
E.g. gt2 checks whether the answer contains a float with more than two decimals.
is_lengthChecks whether the user input is a float or integer with the same length as specified in the Definition field, optionally specified by one of le, lt, ge, gt, ne, eq, <=, >=, <>, ==, !=, <, >, =. eg. gt 2
is_not_factorizedComparison of the factors in the Definition with the factors of the answer. e.g. Definition (x-3)*(x+2) can be used when it's asked to factorize x2x6x2x6
is_not_floatCheck whether the user input is not a float.
is_not_fractionCheck whether the user input is not a fraction.
is_not_ifactorizedChecks if the answer is decomposed into prime factors. No Definition is needed.
is_not_integerChecks whether the user input is not an integer.
is_not_numberChecks whether the user input is not an integer and not a float.
is_not_polynomialChecks if the answer is a polynomial in the variables in the list from the Definition field.
With two arguments, the second is a test for the grade. e.g. x;le6 checks if the answer is a polynomial in x of degree at most 6.
is_not_rationalCheck whether the user input is either an integer or a fraction with the denominator unequal to zero.
is_not_simplified_fractionChecks whether the user input is a simplified fraction. Also works for equations, where it checks whether at least one side is a simplified fraction. With Definition set to
- 1 the final form must be a proper fraction or integer like 112112, 11 or 1212 but not 3232 or 4242. The minus must be in front of the fraction.
- 2 allows for both proper and improper fractions and integers like 112112 and 3232 but not 4242. The minus is not allowed in the denominator.
- 3 same as 1, only also float values will be accepted.
- 4 same as 2, only also float values will be accepted.
- otherwise it only allows improper fractions and integers like 1212 or 3232 but not 112112. The minus is not allowed in the denominator.
is_not_simplified_rootChecks whether the answer (which is assumed to be an expression involving integers, multiplications, divisions, and higher roots) is in the normal form (a/b) * (c-th root of d), where b,c,d are positive integers and a is an integer.
is_not_simplified_complexChecks whether the answer is not in the form a+b*i, b*i, i or c where a,b and c are either simplified fractions, floats or integers and a and b are not 0 and, in the case of a+b*i, there's no minus in b*i. Examples of allowed forms are
3+2i,3+i,32i,0,2,12+12i,2i,2.2i,1.5+0.5i,0.5,343+2i,3+i,-3-2i,0,2,12+12i,2i,2.2i,1.5+0.5i,0.5,34
Examples of disallowed forms are
0+i,1+0i,1+42i,22+2i,1+1+i,1+i2,1+2i,12i,420+i,1+0i,1+42i,22+2i,1+1+i,1+i2,1+-2i,1--2i,42
is_not_top_symbolChecks whether the symbol with the highest precedence in the answer is not equal to one of the symbols in the Definition field. Define a list of one or more symbols in the Definition field. e.g. times;root means the highest symbol is either a times or a root symbol.
is_not_vector_lengthCheck whether the user input has all vectors of the same length. Optionally, use an integer in the Definition field to expect a vector with the prescribe the length, optionally specified by one of le, lt, ge, gt, ne, eq, <=, >=, <>, ==, !=, <, >, =
E.g. gt2 checks whether the answer is a vector with more than two elements.
.
is_not_unitCheck whether the student answer is a unit. With no Definition specified (empty), a check will be done whether the student answer is a unit. The Definition can be used to specify the unit(s) that must be used in the answer, like gram. When multiple units are needed, you can use a list (separated with a comma) of units that must be used in the answer, like gram,liter for g/l. By default, all prefixes are allowed to be used. However, per unit, you can specify which prefixes are allowed by specifying a preceding list of prefixes between square brackets, like gram[centi,milli]. If you want to allow for a unit to be used without a prefix, like m, then use the prefix one, like [one,kilo;centi]meter,[one,kilo;centi]gramme.
same_formChecks the answer and the definition for having exactly the same form after maxima translation
solve_equationAutomatically solve and give feedback on 1st or 2nd degree equation. This type is limited to one variable equations. e.g. x^2=9
solve_inequalityEvaluate the inequality in the Definition field and evaluate the student answer accordingly. This type is limited to one variable inequalities. e.g. x^2<9

For text based answer fields the evaluation types are listed in the table underneath. If you would want to use a dollar ($) in your solution followed by a character, which is not a SOWISO variable like $a, you can do use by writing $/. So $a would then become $/a for the author, but the student would still need to answer $a.

namedescription
contains_wordChecks whether the user input contains all the words from the Definition field (not in the same order). The words must be separated by semicolon ';'. Variations of the same word (e.g. contractions) can also be added by placing them between square brackets [ ] and separating them by comma ','. e.g. [is not,isn't];and;tree then the user input must include the words 'and', 'tree' and one of the words 'is not' or 'isn't' in order to be considered correct.
contains_textChecks whether the user input contains all the texts from the Definition field (not in the same order). The texts must be separated by semicolon ';'. Variations of the same text (e.g. contractions) can also be added by placing them between square brackets '[ ]' and separating them by comma ','. For example if Definition: [is not,isn't];and;tree; then the user input must include the texts 'and', 'tree' and one of the words 'is not' or 'isn't' in order to be considered correct. Caution! The texts 'band' and 'trees' will also be correct because both 'and' and 'tree' are included in the two texts respectively.
text_case_insensitiveChecks whether the user input is equal to the text in the Definition field with a case insensitive check.
text_case_sensitiveChecks whether the user input is equal to the text in the Definition field with a case sensitive check.
text_combinationChecks whether the user input is unique across the answer fields out of the list of answer fields supplied in the Definition field as a list with square brackets [ ] and separating them by comma ,. e.g. apple[1,2] means 'apple' must be in either answer field 1 or 2, but cannot be in both.
Optionally, you can add a i at the end to make it case insensitive, like apple[1,2]i. Note spaces before and after the definition and answer are both removed before evaluation. Caution! Currently only works in question type open free.
text_regexChecks whether the user input matches the regex pattern entered in the Definition field.

The delimiter used for regular expressions in our system is the forward slash (/). If you need to include a forward slash in a regular expression, then you will need to escape it with a backslash (\/). For example, if you wanted to write a regular expression to match a date format such as dd/mm/yyyy then you would need to escape the forward slashes in the date as follow: ^(0?[1-9]|[12][0-9]|3[01])[\/\-](0?[1-9]|1[012])[\/\-]\d{4}$

Note that html-tags are stripped from the student answer, so usage of bold tags like The answer is <strong>apple</strong> will become The answer is apple.

To match exactly a word or a number, you need to include ^ to match the beginning of the line and $ to match the end of the line. For example, to match any of the numbers 1 through 5, the pattern would be as follows: ^[1-5]$
similar_textUse the php function similar_text to determine a percentage of similarity between the student answer and the solution Definition. Optionally, specify a Precision to set the tolerated percentage deviation between the student answer and the Definition, e.g. Precisions = 10 would mean there needs to be a 90% similarity.

Units

This are the supported base units from the metric system:

nameauthor inputuser input
ampAAA
CoulombCCC
degree CelsiusdegC°C°C
grammeggg
JouleJJJ
KelvinKKK
litrelll
metermmm
molemolmolmol
NewtonNNN
PascalPaPaPa
secondsss
voltVVV
WattWWW
This are the supported metric prefixes:
nameauthor inputuser input
attoaaa
centiccc
dekadadada
exaEEE
femtofff
gigaGGG
hectohhh
kilokkk
megaMMM
micromicrouu or μμ
millimmm
nanonnn
petaPPP
picoppp
teraTTT
yoctoyyy
yottaYYY
zeptozzz
zettaZZZ
This are the supported time units:
nameauthor inputuser input
secondsss
minuteminuteminmin
hourhourhh
daydaydd
weekweekww
monthmonthmomo
yearyearyy
This are the supported imperial units:
nameauthor inputuser input
acreacreacreacre
barbarbarbar
footfootftft
milemilemilemile
pintpintpintpint
yardyardyardyard

Subscript notation

Subscript notation is possible in SOWISO.
Just make sure that in the Definition fields, you use the syntax as a_(b) for abab, where a is the variable and b is the subscript.

Sowiso question sets: using variables over multiple questions

Upon opening a Sowiso question in Cirrus you can also find a tab 'Question set'. Using this tab unlocks the power of sowiso question sets:

  1. Using the question set tab you can:
    1. Add several questions to create a set of sowiso questions which use shared parameters.
    2. These will  show as one set 1a, 1b etc. on one page in preview, Candidate Delivery and when Marking.
  2. You can click on the item on the Sowiso tab to directly edit it. You can move the order of the items in a set
  3. Properties like Taxonomy, Learning Objective, Purpose are applied to the set as a whole. If you edit these you will get a warning explaining this.
  4. The max score for a question set is determined by the points per question.

Tips when using sowiso question sets:

  • On the Library overview page listing items in a collection you cannot see if the question is used as a part of a set. Tip: use labels if you want this marked as such.
  • Only single Sowiso items can be used in Sections.
  • If a Sowiso question uses a question set it cannot be used in Sections and also will not be available for Blueprint question selection.
  • It is not possible to copy/import the set to another collection
  • It is not possible to delete sowiso question from a set. Like for sections in Cirrus: you can only delete the set (section) as a whole.

PHP Functions

The following functions can be used in a Definition field of a variable:

abs, acos, acosh, addcslashes, addslashes, array, array_change_key_case, array_chunk, array_column, array_combine, array_count_values, array_diff, array_diff_assoc, array_diff_key, array_diff_uassoc, array_diff_ukey, array_fill, array_fill_keys, array_filter, array_flip, array_intersect, array_intersect_assoc, array_intersect_key, array_intersect_uassoc, array_intersect_ukey, array_key_exists, array_keys, array_map, array_merge, array_merge_recursive, array_multisort, array_pad, array_pop, array_product, array_push, array_rand, array_reduce, array_replace, array_replace_recursive, array_reverse, array_search, array_shift, array_slice, array_splice, array_sum, array_udiff, array_udiff_assoc, array_udiff_uassoc, array_uintersect, array_uintersect_assoc, array_uintersect_uassoc, array_unique, array_unshift, array_values, array_walk, array_walk_recursive, arsort, asin, asinh, asort, atan, atan2, atanh, base_convert, bcadd, bccomp, bcdiv, bcmod, bcmul, bcpow, bcpowmod, bcscale, bcsqrt, bcsub, bin2hex, bindec, ceil, chop, chr, chunk_split, cos, cosh, count, count_chars, current, decbin, dechex, decoct, deg2rad, each, end, exp, explode, expm1, extract, floor, fmod, getrandmax, hex2bin, hexdec, html_entity_decode, htmlentities, htmlspecialchars, htmlspecialchars_decode, hypot, implode, in_array, intdiv, is_finite, is_infinite, is_nan, join, key, key_exists, krsort, ksort, lcfirst, lcg_value, levenshtein, list, localeconv, log, log10, log1p, ltrim, max, metaphone, min, money_format, mt_getrandmax, mt_rand, mt_srand, natcasesort, natsort, next, nl2br, number_format, octdec, ord, pi, pos, pow, prev, preg-replace, rad2deg, rand, range, reset, round, rsort, rtrim, shuffle, similar_text, sin, sinh, sizeof, sort, soundex, sqrt, srand, str_getcsv, str_ireplace, str_pad, str_repeat, str_replace, str_rot13, str_shuffle, str_split, str_word_count, strcasecmp, strchr, strcmp, strcoll, strcspn, strftime, strip_tags, stripcslashes, stripos, stripslashes, stristr, strlen, strnatcasecmp, strncasecmp, strnmp, strpbrk, strpos, strrchr, strre, strripos, strrpos, strspn, strstr, strtok, strtolower, strtoupper, strtr, strval, substr, substr_compare, substr_count, substr_replace, tan, tanh, time, trim, uasort, ucfirst, ucwords, uksort, usort, wordwrap,

SOWISO PHP functions

Extra functions created by SOWISO are available via the prefix sw_

Warning: loading Maxima packages can make an exercise extremely slow and performance intensive. When used in a single exercise it works fine, but when a test must be generated, it's a lot of calls and it simply asks too much of the system. Subsequently, Maxima calls timeout and students see zero's or errors at the place of the variables, or in the worst cases the whole test creation fails. Maxima packages affected:

  • 'descriptive' -> use sw_R instead
  • 'distrib' -> use sw_R instead
functionreturns
[0,"a",2,3]returns a random item from the list. The list can be a mixed list of strings and numbers.
[[0,"a",2,3]]use double squared brackets to return an (php) array. The array can be a mixed list of strings and numbers. If no keys are provided, you can access value with a zero-based index key, like $var[0] for the first value and so on. Alternatively you can give keys names with an arrow like [['one'=>1,'two'=>2,'three'=>3,'ten'=>10]] in which case you can acces them by the name of the key like $var['two'].
sw_answer(a, opt1, opt2)gives access to a last given answer from the current or a previous exercise in the set. You can use the answer both in text and in the definitions of solutions and feedback for evaluation, where
a is the reference to the number of the answer field.
opt1: is the order of the exercise you want to reference in its set, starting at 1. You can use this argument to get the answers of another (prior) exercise from the same set. If you skip this argument, the answer is taken from the current exercise.
opt2: Optionally, you can specify a fallback answer in maxima syntax for when the previous exercise was unanswered. When the variable is used in text it will be converted to TeX. When this option is not used an the variable is used in a definition and there is no answer, the value will default to %null.
Note: do not use this function together with other functions in a definition of a variable, but always create a separate variable that only consists of the sw_answer() function. Also, do not use inline in text (between ~), but always via a variable. Finally, do not use the variable in text when the exercise is used in a test, since the answer of the previous exercise in a test is not sent in yet. e.g. sw_answer(2) represents the answer to the second answer field of the current exercise.
sw_answer(1,1,"2*x") represents the answer to the first answer field of the first exercise in the set. If there is no answer given, the value will fall back to x^2. This function is enabled for the following exercise types: Open, Radio_button, Dropdown, Multiple_choice, Radio_button_random, Open_free, Text, Multiple_choice_random, Strategy, Essay, Input_line_graph, Input_vector_graph, Input_point_graph
sw_answer_correct(a, opt)gives access to the evaluation of a last given answer from the current or a previous exercise in the set. You can use the outcome both in text and in the definitions of solutions and feedback for evaluation. In text it returns a string that is either "true" or "false" based on the evaluation of the answer. In Definitions of solutions and feedback it will be true or false (without double quotes). Argument:
a is the reference to the number of the answer field.
opt1: is the order of the exercise you want to reference in its set, starting at 1. You can use this argument to get the answers of another (prior) exercise from the same set. If you skip this argument, the answer is taken from the current exercise. In solution texts this can be used to adjust your text based on the evaluatino of an answer in a previous exercise. e.g. $a = sw_answer_correct(1,2) takes the first answer field from the second exercise in a set. In the third exercise you can then use $a in an inline php statement using a ternary operator like this: ~$a == "true" ? "Text when previous answer was correct" : "Text when previous answer was incorrect"~.
Note: do not use this function together with other functions in a definition of a variable, but always create a separate variable that only consists of the sw_answer_correct() function. Also, do not use inline in text (between ~), but always via a variable. This function is enabled for the following exercise types: Open, Radio_button, Dropdown, Multiple_choice, Radio_button_random, Open_free, Text, Multiple_choice_random, Strategy, Essay, Input_line_graph, Input_vector_graph, Input_point_graph
sw_answer_maxima(a, opt1, opt2)gives access to a last given answer from a previous exercise in the set in maxima syntax. You can use the answer in text (and sent it to maxima for further calculations when used in text between tildes ~, for example you can use it in text to differentiate the student answer to xx, when $a is the variable, via: #~sw_maxima("diff($a,x)")~# ) and in the definitions of solutions and feedback for evaluation, where
a is the reference to the number of the answer field.
opt1: is the order of the exercise you want to reference in its set, starting at 1. You can use this argument to get the answers of another (prior) exercise from the same set. If you skip this argument, the answer is taken from the current exercise.
opt2: Optionally, you can specify a fallback answer in maxima syntax for when the previous exercise was unanswered. When the variable is used in text it will be converted to TeX. When this option is not used an the variable is used in a definition and there is no answer, the value will default to %null.
Note: do not use this function together with other functions in a definition of a variable, but always create a separate variable that only consists of the sw_answer_maxima() function. Also, do not use inline in text (between ~), but always via a variable. Finally, do not use the variable in text when the exercise is used in a test, since the answer of the previous exercise in a test is not sent in yet. e.g. sw_answer_maxima(2) represents the answer to the second answer field of the current exercise.
sw_answer(1,1,"2*x") represents the answer to the first answer field of the first exercise in the set. If there is no answer given, the value will fall back to x^2. This function is enabled for the following exercise types: Open, Radio_button, Dropdown, Multiple_choice, Radio_button_random, Open_free, Text, Multiple_choice_random, Strategy, Essay, Input_line_graph, Input_vector_graph, Input_point_graph
sw_alist(a,b)returns an item from the list in the first argument a at position b from the second argument. Note that the first position is at index 0. e.g. sw_alist([1,2,3],2) returns 3
sw_comma(a)returns the input string a with all comma's replace by \comma for TeX presentation, e.g. sw_comma("1,2") returns 1\comma 2. Useful when presenting decimals with the comma as decimal sign because 1,2 is displayed as 1,21,2, where 1\comma 2 is displayed as 1,21,2
sw_concat(["a","b","c"])returns the concatenation of the strings in the argument, e.g. sw_concat(["a","b","c"]) returns abc
sw_descriptive(a, opt1, opt2)loads the maxima package descriptive for making descriptive statistical computations (http://maxima.sourceforge.net/docs/manual/maxima_49.html) with input a
opt1: when 1, the output is in tex, otherwise output is in maxima native syntax
opt2: when output is in tex, set the tex type as per sw_maxima()'s second argument
sw_distrib(a, opt1, opt2)loads the maxima package distrib for making probability computations (http://maxima.sourceforge.net/docs/manual/maxima_51.html) with input a
opt1: when 1, the output is in tex, otherwise output is in maxima native syntax
opt2: when output is in tex, set the tex type as per sw_maxima()'s second argument
sw_divisor(a, opt1, opt2)gives a random divisor of number a
opt1: when 1, also add self to random list
opt2: when 1, also add 1 to random list
sw_draw(a,opt2)draw objects in a in dimension opt1 ( options are 2 (two dimensional, this is the default), 3 (three dimensional) or "df" for direction fields. sw_draw also supports drawing on images as background (type png). See sw_image().
sw_eq(a, b)returns 1 if a is equal to b, otherwise it returns 0
sw_eq_sign(a, b)returns "=" if a is equal to b when both a and b are rounded to 10 decimals, otherwise it returns "\approx". a and b must both be numerical. Used for presenting decimal rounding as the solution after randomizing e.g. sw_eq_sign(1.2,12/10) returns "=" where sw_eq_sign(sqrt(2),1.4) returns "\approx". Useful for instance in 12=0.512=0.5 versus 230.67230.67.
sw_fact(a)returns the factorial of a
sw_finance(a, opt1, opt2)loads the maxima package finance for making financial computations (http://maxima.sourceforge.net/docs/manual/maxima_58.html) with input a
opt1: when 1, the output is in tex, otherwise output is in maxima native syntax
opt2: when output is in tex, set the tex type as per sw_maxima()'s second argument
sw_fraction(a, b, opt1, opt2)gives a presentation of the fraction a/b as a simplified mixed fraction for asciimathml use of with opt2 set to 1 in tex use.
opt1: when 1, print as proper fraction, otherwise it's a mixed fraction (3232 instead of 112112)
opt2: when 1, use tex syntax instead of asciimathml.
sw_gcd(a,b)gcd of a and b (the return value is always a positive number.) a can also be an array (in that case, b is ignored).
sw_ge(a, b)returns 1 if a is greater than or equal to b, otherwise it returns 0
sw_gt(a, b)returns 1 if a is greater than b, otherwise it returns 0
sw_iplot("a")displays a plot of one or more expressions in implicit form
sw_image("a")get a placeholder for a background image (type png) for sw_draw(), where a is the path of the image you uploaded. In sw_draw(), you must set it in the user_preamble together with the settings you see in the following example that have to do with scaling sizeing of the background. e.g. $image = sw_image("/images/uploads/exercises/100/sowiso.png") and
sw_draw("dimensions=[400,200],
user_preamble=\"reset;
set size ratio -1;
set lmargin 0;
set rmargin 0;
set tmargin 0;
set bmargin 0;
unset tics;
unset border;
set label 'label 1' at 25,157 front tc ls 1;
$image \"
")
sw_ilist(a, b)searches for b in the array in the first argument and returns its index. Note that the first position is at index 0, e.g. sw_list_index([4,5,6,7], 6) returns 2
sw_int(a)returns the integer part of a, e.g. sw_int(10.9382) returns 10
sw_lang("a")a way to make use preset text values to make text in a variable multi-lingual. As an index, you can choose from "all", "none", "yes, "no", "indeed", "not" . e.g. sw_lang("yes")
sw_lang([a])a way to make text in a variable multi-lingual. Use with a list of strings, where index 0 is Dutch, 1 is English, 2 is French and 3 is Spanish. e.g. sw_lang(["twee","two","deux", "dos"])
sw_lcm(a,b)lcm of a and b. Optionally, a list of multiple integers can be supplied in the first argument like sw_lcm([2,4,8])
sw_le(a, b)returns 1 if a is less than or equal to b, otherwise it returns 0
sw_logic(a)can be used to call maxima with logic package loaded. e.g. sw_logic(" pcnf(not(p and q) implies (p or q) )") returns p or q
sw_lsu(a, b)returns the unit in the b-th significant place of a, e.g. sw_lsu(9.7472, 4) returns 0.001
sw_lt(a, b)returns 1 if a is less than b, otherwise it returns 0
sw_mathml("a")converts OpenMath object from string a to mathml
sw_maxima("a",opt1)where a has to be of type string, that means with double quotes. Returns maxima interpretation of input in tex notation. Use for simplifying in text field and presentation form of maxima (native) syntax
opt1: can be used to adjust the behaviour of the tex, where
traditional is the default,
traditional_times is without a \cdot like for a multiplication
alphabetic is the with maxima's setting powerdisp:true to ensure alphabetic ordering of variables and ,
alphabetic_times is the same but without a \cdot like for a multiplication or
raw for the unchanged maxima tex function output.
e.g. sw_maxima("2/6") returns {{1}\over{3}}, sw_maxima("b*a", "alphabetic_times") returns a\,b
sw_maxima_native("a", opt1)use native maxima to calculate a variable and maxima's grind() output.
Use true for opt1 to get maxima's full answer.
e.g. sw_maxima_native("diff(3*x^5,x)") returns 15x^4
sw_maxima_list(a,opt1,opt2)converts a maxima list a into a string that can be interpreted by sw_tex_list. Set opt1 to true to get output in tex, otherwise it is in maxima native syntax. Set opt2 to true to get the output in unsimplified format, e.g. 2/2 remains 2/2, otherwise it becomes 1.
In the Preview of the variable, an Explode option is offered. This will auto create variables, based on the values in the list that is defined in this sw_maxima_list function. If possible, the new variable will get an alias that is named after the corresponding value in the list. A suffix of _tex or _max will be added to the alias, based on the value of opt1. For instance, when the Definition of a variable is sw_maxima_list("[variableA, variableB]"), then two new variables will be generated with an alias variableA_tex and variableB_tex.
sw_namegets the current user's first name.
sw_ne(a, b)returns 1 if a is not equal b, otherwise it returns 0
sw_normal(a)normalizes a domain a, which is in the logic expression form
sw_not(a)returns 1 if a equals 0, otherwise it returns 0
sw_number_of_divisors(a, opt1, opt2)gives the number of divisors of number a
opt1: when 1, also add self to the count
opt2: when 1, also add 1 to the count
sw_openmath("a")evaluates a and converts maxima syntax to an OpenMath expression
sw_plot("a",b,"c")plot functions in a in dimension b (2 or 3) with arguments c
sw_rand_sign(a)a with random sign
sw_rand_sign(a,b)random integer between a and b or -a and -b
sw_rand_exclude(a,b,c)random integer between a and b, but not c, where c can be an integer or a list of integers, e.g. sw_rand_exclude(1,10,[3,7])
sw_rand_steps(a, b, c)random integer between a and b with steps of c
sw_rand_divisors(a, b)gives a random integer smaller or equal to a that has at least b divisors
sw_rand_float(a, b, opt1)returns a random float between a and b. The optional argument opt1 indicates to which significant digit the float should be rounded. Note that the number of displayed decimals also needs to be adjusted in the variable editor.
sw_rank(a, b)returns the b-th largest item of the array in the first argument, e.g. sw_rank([40,30,50,20], 2) returns 40
sw_round_sig(a, b)returns a as a float rounded to b significant digits, e.g. sw_round_sig(10.7673, 3) returns 10.8. To prevent setting the number of decimals of the output of sw_round_sig(), set the decimals field of the variable to -1. Note that we do not use scientific notation, so the output of sw_round_sig(150, 1) is 200.
sw_root("a", opt1)rewrites an expression with products, roots, sqrts, integers and divisions from maxima syntax to TeX in the form (a/b)*sqrt[c](d). When opt1 is set to fraction the output form will be (a*sqrt[c](d))/b
sw_R(a)where a has to be of type string, that means with quotes. Returns stdout of the Rscript interpretation of the input. If the R code outputs several lines, the result will be an array.
It is advised to use single quotes around the R code and double quotes for strings within the code, for example: sw_R('x <- list(a="hello"); x$a'). The problem with using double quotes is that variables within double quotes are replaced, for example $a. That means you cannot use a dollar sign in a string with double quotes!
Some of the available packages are dplyr, ggplot2, readr, tibble, and purrr. For a full list of available packages, please put sw_R('installed.packages()[,0]') in a variable definition and save.
Generating files, like plots, csv's or Rdata files is also supported. Just make sure you write to the directory /tmp/sowiso/. When successful, a relative url will be returned with the name of the file in the key. See Create via R for examples.
sw_shuffle(a, opt1)shuffle the key/value pairs in the array/list a and output the shuffled list. e.g. sw_shuffle([1,2,3]) can give Array ( [1] => 2 [0] => 1 [2] => 3 ).
The function keeps the associated key value pairs intact, but optionally you can set the second argument opt1 to false to reindex the new list, so then sw_shuffle([1,2,3], false) can give Array ( [0] => 2 [1] => 1 [2] => 3 ).
sw_sn(a,b,opt1,opt2)scientific notation of number a with precision b and
opt1 as an optional argument 'e' or 'E' or '10' or 'tex' (default 'e'). '10' gives times 10nth power. 'tex' as well, but then in TeX formatting.
opt2 is an optional argument for the rounding mode, where
0 is the default and the scientific notation standard, meaning It rounds number in the proper scientific way. It rounds up if the next digit is greater than five. Rounds down if the next digit is less than five. If the next digit is five it rounds up half the time and down half the time based on whether the previous digit is even or odd. This ensures that cumulative rounding errors do not skew the data.
1 is ROUND_HALF_UP Round a up to b decimal places away from zero, when it is half way there. Making 1.5 into 2 and -1.5 into -2.
2 is ROUND_HALF_DOWN Round a down to b decimal places towards zero, when it is half way there. Making 1.5 into 1 and -1.5 into -1.
3 is ROUND_HALF_EVEN Round a to b decimal places towards the next even value.
4 is ROUND_HALF_ODD Round a to b decimal places towards the next odd value.
sw_tex_list(a,b)returns the b-th element of a list a generated by sm_maxima_list, starting at index 1 (b > 0).
sw_vect(a)loads the maxima package vect for vector analysis (http://maxima.sourceforge.net/docs/manual/maxima_23.html#SEC119) with input a. For example, to calculate a cross product you can use sw_vect("express([a,b,c]~[c,a,b])")

Was this article helpful?

What's Next