МатематикаМоя статистика
Тест по системам компьютерной алгебры
100 вопросов в 10 темах (лёгкий — 35, средний — 40, сложный — 25). Выберите темы, уровень и количество вопросов — к каждому ответу есть объяснение.
Mathematica, Maple, Maxima и SymPy: синтаксис, упрощение, решение уравнений, анализ, дифференциальные уравнения, линейная алгебра, графики и численные ловушки. Вопросы на английском.
Все вопросы теста 100
Нажмите на вариант ответа, чтобы проверить себя, или «Показать ответ».
CAS basics10
In Mathematica, what is displayed as the output of the following input?
N[Sqrt[2]]- Sqrt[2]
- 1.41421
- 2^(1/2)
- 1.4
N[...] converts an exact expression into a machine-precision number; the front end shows 6 significant digits by default, so you see 1.41421. Without N, Sqrt[2] stays exact — that is the result you would get by forgetting N. 1.4 is just a rough hand rounding, not what N produces.
In Maple, with the default setting of Digits, what does the following command return?
evalf(Pi);- 3.141592654
- Pi
- 3.14
- 3.1415926535897932385
evalf evaluates to a floating-point number with Digits significant digits, and Digits is 10 by default: 3.141592654. Pi on its own stays exact (that is what you get without evalf), and 20 digits would require evalf(Pi, 20) or Digits := 20.
What does this Python/SymPy code print?
from sympy import symbols
x = symbols('x')
expr = x + 1
x = 2
print(expr)- 3
- x + 1
- 2 + 1
- NameError: name 'x' is not defined
expr was built from the Symbol object x; the line x = 2 only rebinds the Python name x to the integer 2 and does not touch the expression. To plug in a value use expr.subs(x, 2), which gives 3. Expecting 3 here is the classic confusion between a Python variable and a SymPy symbol.
In Mathematica, what does the following input return?
{Sin[Pi/6], Sin[Pi/6.]}- {0.5, 0.5}
- {1/2, 1/2}
- {1/2, 0.5}
- {Sin[Pi/6], 0.5}
Pi/6 is exact, so Sin[Pi/6] gives the exact value 1/2. In Pi/6. the decimal point makes 6. an inexact (machine) number, so the argument becomes 0.523599 and the result is the float 0.5. One trailing dot switches the whole computation from exact to numeric.
In SymPy, which expression creates exactly the rational number 1/10?
- Rational(0.1)
- S(0.1)
- Rational("0.1")
- Float("0.1")
Rational("0.1") parses the decimal string and returns 1/10. Rational(0.1) receives the binary float 0.1, which is not exactly 1/10, so it returns 3602879701896397/36028797018963968. S(0.1) and Float("0.1") give the Float 0.100000000000000, not a rational.
In Mathematica, what does the following input return?
Sqrt[8]- 2.82843
- Sqrt[8]
- 2.8284271247461903
- 2 Sqrt[2]
Exact input gives exact output: Mathematica pulls the perfect square out of the root, √8 = √(4·2) = 2√2, and keeps it symbolic. A decimal such as 2.82843 appears only if you ask for it with N[Sqrt[8]] or type an inexact number like Sqrt[8.].
In SymPy (after from sympy import *), which call gives a decimal approximation of π with 20 significant digits?
- float(pi)
- round(float(pi), 20)
- N(pi, 20)
- pi**20
N(expr, n) (or expr.evalf(n)) evaluates with arbitrary precision: 3.1415926535897932385. float(pi) converts to a Python float, which only carries about 16 significant digits, and rounding that float to 20 decimals cannot add digits it never had. pi**20 is π to the 20th power.
In Maple, what is displayed by the last command?
x := 3:
y := x^2:
x := 4:
y;- 16
- x^2
- y
- 9
An assignment with := evaluates its right-hand side first, so y receives the value 3^2 = 9, not the formula x^2. Changing x later does not affect y. Expecting 16 means treating := as a live formula; to keep the dependence you would define a function, f := x -> x^2.
In Mathematica, what does the following input return?
1/3 + 0.5- 5/6
- 1/3 + 0.5
- 0.833333
- 0.8
As soon as one operand is an approximate (machine) number, the whole sum is computed numerically: 0.333333 + 0.5 = 0.833333. The exact result 5/6 appears only if every number is exact (1/3 + 1/2). Mathematica does not leave the sum unevaluated.
In Mathematica, N[0.1, 30] does not give 30 correct digits of 1/10. Why?
- N only accepts up to 16 digits; anything larger is ignored
- The second argument of N is the number of decimal places to drop
- N needs an extra option, WorkingPrecision -> 30, to accept the request
- 0.1 is already a machine-precision number, and N cannot add precision it never had; N[1/10, 30] works
N raises precision only for exact input. Typing 0.1 creates a machine float (about 16 digits, and not exactly 1/10 in binary), so N[0.1, 30] just returns that machine number. Start from the exact 1/10: N[1/10, 30]. N itself has no 16-digit limit — N[Pi, 100] works.
Mathematica syntax10
Which input computes sin(π/2) in Mathematica?
- sin(pi/2)
- Sin(Pi/2)
- sin[Pi/2]
- Sin[Pi/2]
Built-in Mathematica functions and constants are capitalized (Sin, Pi), and function arguments go in square brackets. Parentheses only group, so Sin(Pi/2) is read as the product Sin·(Pi/2). sin and pi in lower case are just undefined symbols.
In Mathematica, what is the effect of the semicolon at the end of this input?
a = Integrate[x^2, x];- It is a required statement terminator; without it the input is a syntax error
- It turns the rest of the line into a comment
- The input is evaluated and a is assigned, but the output is not displayed
- It delays the integration until a is used
A trailing ; suppresses the printed output; the computation and the assignment still happen. It is not mandatory (without it you simply see x^3/3), it does not comment anything out, and delayed evaluation is the job of :=, not of ;.
Which input is equivalent to the following Mathematica input?
x^2 - 1 // Factor- x^2 - Factor[1]
- Factor[x^2] - 1
- Factor[x^2 - 1]
- x^2 - 1 (// starts a comment)
expr // f is postfix notation for f[expr], and // has very low precedence, so the whole expression x^2 - 1 is passed to Factor, giving (-1 + x) (1 + x). Comments in Mathematica are written (* ... *), not with //.
In Mathematica, what does the following input return?
f /@ {1, 2, 3}- f[{1, 2, 3}]
- {f[1], f[2], f[3]}
- f[1, 2, 3]
- {f, f, f}
/@ is Map: it applies f to each element of the list. f[{1, 2, 3}] is plain application (f @ {1, 2, 3}), and f[1, 2, 3] is what Apply (f @@ {1, 2, 3}) produces.
In Mathematica, what does the last line return?
f[x_?Positive] := Sqrt[x]
f[-4]- 2 I
- 2
- f[-4]
- -2
The pattern x_?Positive only matches arguments for which Positive[x] is True. -4 fails the test, so no definition applies and f[-4] is returned unevaluated. 2 I would be Sqrt[-4] — that is what you would get without the condition.
How do you write a list of the numbers 1, 2, 3 in Mathematica?
- [1, 2, 3]
- {1, 2, 3}
- (1, 2, 3)
- list(1, 2, 3)
Lists (and therefore vectors and matrices) use curly braces: {1, 2, 3}. Square brackets are reserved for function application, f[x], and parentheses for grouping. [1, 2, 3] is the Python/SymPy habit.
In Mathematica, what does the last line return?
a = 5;
f[x_] := a x;
a = 10;
f[2]- 20
- 10
- 2 a
- f[2]
SetDelayed (:=) stores the right-hand side unevaluated; it is evaluated each time f is called. At the call a is 10, so f[2] = 10·2 = 20. The answer 10 assumes := captured a = 5 at definition time — that is what = (Set) would do.
In Mathematica, which expression is the same as f @ g @ x?
- f[g][x]
- g[f[x]]
- f[g[x]]
- f[g, x]
@ is prefix application and groups to the right: f @ g @ x = f @ (g @ x) = f[g[x]]. f[g][x] would be the curried form, and reading the chain left to right as "first f, then g" gives the wrong g[f[x]].
In Mathematica, what does the last line return?
g[x] := x^2
g[3]- 9
- g[3]
- x^2
- 3^2
Without the blank, g[x] := x^2 defines g only for the literal symbol x — g[x] gives x^2, but g[3] matches no rule and stays unevaluated. To define a function for any argument, write g[x_] := x^2. Forgetting the underscore is the most common beginner error.
In Mathematica, which statement about these two lines is correct?
r = RandomReal[]; {r, r}
s := RandomReal[]; {s, s}- The first list has two equal numbers, the second list usually has two different numbers
- Both lists have two equal numbers
- Both lists usually have two different numbers
- The first list has two different numbers, the second list has two equal numbers
r = RandomReal[] evaluates once and stores the number, so both entries of {r, r} are that same value. s := RandomReal[] stores the unevaluated call, which is re-evaluated every time s is used, so each entry is a fresh random number. This is the practical difference between Set (=) and SetDelayed (:=).
Maple syntax10
Which operator assigns the value 5 to the name a in Maple?
- a = 5;
- a <- 5;
- a == 5;
- a := 5;
Maple assigns with :=. A single = builds an equation object a = 5 (used by solve, eval, dsolve) and assigns nothing. <- is R syntax and == is not Maple's equation operator.
In Maple, what does the last command display?
3 + 4;
10 * 2;
%% + 1;- 8
- 21
- 11
- Error, %% is not valid syntax
% is the last result, %% the second-to-last, %%% the third. Here the last result is 20 and the second-to-last is 7, so %% + 1 = 8. The answer 21 comes from reading %% as %.
In Maple, what does the last command return?
assume(x > 0):
sqrt(x^2);- x (displayed as x~)
- |x|
- sqrt(x^2)
- -x
Maple works over the complex numbers, so without information about x it leaves sqrt(x^2) as it is. After assume(x > 0) it knows √(x²) = x; the tilde in x~ only marks that x carries an assumption. |x| would be the answer for real x of unknown sign.
In Maple, f was defined as an expression, not as a function. What does the last command return?
f := x^2 + 1:
f(3);- 10
- x^2 + 1
- x(3)^2 + 1
- Error, f is not a procedure
f is the expression x^2 + 1, and applying an expression to an argument in Maple distributes the call over its parts: x becomes x(3) and the constant 1 applied to 3 stays 1. To get 10 define a function, f := x -> x^2 + 1, or substitute with eval(f, x = 3).
In Maple, what happens with the second command?
x := 3:
int(x^2, x);- It returns x^3/3
- An error, because x evaluates to 3 and 3 is not a valid integration variable
- It returns 9*x
- It returns 27
Maple evaluates the arguments before calling int, so the call becomes int(9, 3), and 3 is not a name to integrate with respect to. Unassign first with x := 'x' (or use another variable name). Forgetting an earlier assignment is a frequent source of strange Maple errors.
In Maple, what is the difference between ending a command with ; and with :?
- The colon executes the command, the semicolon only displays it
- The colon makes the command run only when the worksheet is saved
- The semicolon is needed for assignments, the colon for function calls
- Both execute the command; the colon suppresses the display of the result
In Maple both terminators execute the statement; ; shows the result and : hides it. The colon is handy for long intermediate results such as big matrices or plots data. Either can end any kind of statement.
What does the following Maple command do?
with(LinearAlgebra):- Loads the LinearAlgebra package so its commands can be called by short names such as Determinant(A)
- Creates a new empty matrix called LinearAlgebra
- Checks whether LinearAlgebra is installed and returns true or false
- Switches Maple into numeric-only mode for matrix computations
with(Package) makes the package's exports available under short names. Without it you must write the long form LinearAlgebra[Determinant](A) (or LinearAlgebra:-Determinant(A)). It neither creates objects nor changes the arithmetic mode.
In Maple, p := x^2 + 3*x is an expression (not a function). Which command evaluates p at x = 2?
- p(x = 2)
- eval(p, x = 2)
- p[2]
- eval(p, x := 2)
eval(expr, x = value) substitutes the value and evaluates: 4 + 6 = 10 (subs(x = 2, p) also works). p[2] is indexing, not substitution, and inside eval the substitution is written as an equation with =, not with the assignment :=.
In Maple, what does the following input display?
Digits := 5:
evalf(Pi);- 3.14159
- 3.1416
- 3.141592654
- 3.14
Digits sets the number of significant digits used by evalf. With Digits := 5 the result is π rounded to 5 significant digits: 3.1416. 3.141592654 is the default with Digits = 10; 3.14159 is 6 digits (the Mathematica-style display).
In Maple, what does the last command display?
x = 5;
x;- 5
- true
- x
- false
x = 5 with a single = creates and displays the equation x = 5; it does not assign anything, so x is still an unassigned name and evaluates to itself. Assignment needs :=. Expecting 5 is the typical slip of people coming from C or Python.
Maxima and SymPy10
Which input assigns the value 5 to the variable a in Maxima?
- a : 5;
- a = 5;
- a := 5;
- a <- 5;
Maxima assigns with a colon. a = 5 is an equation (used by solve), and := is the operator for defining functions, f(x) := .... Writing a := 5 out of Maple habit does not perform a plain value assignment.
In a fresh Python session, what happens when this code runs?
from sympy import *
expr = x**2 + 1- expr becomes x**2 + 1
- expr becomes 1
- SymPy asks which variable to use
- NameError: name 'x' is not defined
SymPy is a Python library: every symbol must first be bound to a Python name, for example x = symbols('x'). from sympy import * does not create x for you. Only then can x**2 + 1 build a symbolic expression.
What does this Python/SymPy code return?
from sympy import symbols
x = symbols('x')
x + 1/2- x + 1/2
- x
- TypeError: unsupported operand
- x + 0.5
1/2 is evaluated by Python before SymPy sees it, and in Python 3 it is the float 0.5, so the expression contains a Float. For an exact half write Rational(1, 2) or S(1)/2, which gives x + 1/2. (In old Python 2, 1/2 was 0, giving just x.)
In SymPy with x = symbols('x'), what do these two calls return?
sqrt(x).subs(x, 2)
sqrt(x).evalf(subs={x: 2})- sqrt(2) and 1.41421356237310
- 1.41421356237310 and sqrt(2)
- sqrt(2) and sqrt(2)
- 1.41421356237310 and 1.41421356237310
subs replaces x by the exact integer 2, so the result stays exact: sqrt(2). evalf(subs=...) substitutes and evaluates numerically in one step (15 digits by default). Expecting a decimal from subs alone is the usual mistake.
What does this Python/SymPy code do?
from sympy import symbols
x = symbols('x')
y = x^2- y becomes x**2
- y becomes 2*x
- y becomes x XOR 2 as a symbolic logic expression
- It raises TypeError, because ^ is Python's bitwise XOR, not a power
In Python source the power operator is **; ^ means XOR and is not defined between a Symbol and an int, so you get TypeError: unsupported operand type(s). (Only when parsing a string, sympify("x^2"), does SymPy convert ^ to ** by default.)
Which input defines the function f(x) = x² in Maxima?
- f(x) = x^2;
- f := x -> x^2;
- f[x_] := x^2
- f(x) := x^2;
In Maxima, functions are defined with :=, and ordinary values are assigned with :. f(x) = x^2 is only an equation, f := x -> x^2 is Maple syntax, and f[x_] := x^2 is Mathematica.
In Maxima, what does the following input return?
ratsimp((x^2 - 1)/(x - 1));- x + 1
- (x^2 - 1)/(x - 1)
- x - 1
- (x - 1)*(x + 1)
ratsimp rewrites a rational expression in canonical form, which cancels the common factor: (x² − 1)/(x − 1) = (x − 1)(x + 1)/(x − 1) = x + 1. (x − 1)(x + 1) is only the factored numerator.
In SymPy, f = lambdify(x, x**2 + 1). What is f and what is f(3)?
- f is a SymPy expression, and f(3) is 3*x**2 + 3
- f is an ordinary numeric Python function, and f(3) is 10
- f is a SymPy Function object, and f(3) stays unevaluated as f(3)
- f is a plot of x**2 + 1, and f(3) is an error
lambdify translates a symbolic expression into a fast numeric Python function (using math or NumPy). That is the standard way to evaluate a formula at many points or pass it to a numerical solver; subs/evalf would be much slower for that.
Which Maxima input gives the numeric value of π?
- float(%pi);
- float(pi);
- N[Pi]
- evalf(Pi);
Maxima's built-in constants carry a % prefix: %pi, %e, %i. pi without % is just an ordinary symbol, so float(pi) returns pi unchanged. N[Pi] is Mathematica and evalf(Pi) is Maple.
In SymPy with x = symbols('x'), what does the following comparison return?
(x + 1)**2 == x**2 + 2*x + 1- False
- True
- Eq((x + 1)**2, x**2 + 2*x + 1)
- It raises TypeError
In SymPy, == tests structural equality of expression trees, not mathematical equality: a power and an expanded sum are different trees. To test mathematical equality use simplify(a - b) == 0 or a.equals(b). For a symbolic equation object use Eq(a, b).
Algebra and simplification10
In SymPy with x = symbols('x'), what does the following call return?
factor(x**2 - 5*x + 6)- (x + 3)*(x + 2)
- (x - 3)*(x - 2)
- (x - 6)*(x + 1)
- x**2 - 5*x + 6
We need two numbers with product 6 and sum −5: −2 and −3, so x² − 5x + 6 = (x − 2)(x − 3). (x + 2)(x + 3) gives +5x, a sign error; (x − 6)(x + 1) has the right product shape but sum −5 and product −6.
In Mathematica, what does the following input return?
Solve[x^2 == 4, x]- {-2, 2}
- {{x -> -2}, {x -> 2}}
- {x -> 2}
- x == -2 || x == 2
Solve returns a list of solutions, each written as a list of replacement rules. You use them with /., e.g. x /. Solve[...] gives {-2, 2}. The logical form x == -2 || x == 2 is what Reduce returns, and {x -> 2} forgets the negative root.
Why does this Mathematica input fail?
Solve[x^2 = 4, x]- Solve needs the variable in braces: {x}
- Solve cannot handle quadratic equations; use NSolve
- A single = is assignment (Set) and tries to assign 4 to x^2; equations need ==
- The equation must be written as x^2 - 4 = 0
In Mathematica = is Set, so x^2 = 4 tries to assign a value to Power, which is protected, and Solve then receives the number 4 instead of an equation. Equations are written with ==: Solve[x^2 == 4, x]. Braces around a single variable are optional.
In SymPy with x = symbols('x'), what does the following call return?
apart(1/(x*(x + 1)))- 1/(x + 1) - 1/x
- -1/(x + 1) + 1/x
- 1/(x**2 + x)
- 1/x + 1/(x + 1)
apart performs a partial fraction decomposition: 1/(x(x + 1)) = A/x + B/(x + 1) with A = 1, B = −1. The swapped signs and the sum 1/x + 1/(x + 1) both fail a quick check at x = 1: the original gives 1/2. 1/(x**2 + x) only expands the denominator.
In SymPy, x and y are created with symbols('x y') and no assumptions. What does the following call return?
expand_log(log(x*y))- log(x*y)
- log(x) + log(y)
- log(x) * log(y)
- log(x) + log(y) + 2*I*pi
log(xy) = log x + log y is false for general complex numbers (try x = y = −1). SymPy only applies the rule if x and y are declared positive, e.g. symbols('x y', positive=True), or if you insist with expand_log(..., force=True). log x · log y is not a log rule at all.
In SymPy with x = symbols('x'), what does the following call return?
expand((x + 1)**3)- x**3 + 1
- x**3 + 3*x + 1
- x**3 + 3*x**2 + 3*x + 1
- (x + 1)**3
expand multiplies out products and powers: (x + 1)³ = x³ + 3x² + 3x + 1 (binomial coefficients 1, 3, 3, 1). x³ + 1 is the "freshman's dream" mistake of raising each term to the power separately.
In SymPy with x = symbols('x'), what does the following call return?
simplify(sin(x)**2 + cos(x)**2)- sin(x)**2 + cos(x)**2
- 1
- 2
- sin(2*x)
simplify tries many rewrites, including trigonometric ones, and recognizes the Pythagorean identity sin²x + cos²x = 1. Without calling simplify SymPy would keep the sum as written — it does not apply such identities automatically.
Which Mathematica input returns x?
- Simplify[Sqrt[x^2], x > 0]
- Simplify[Sqrt[x^2]]
- Expand[Sqrt[x^2]]
- FullSimplify[Sqrt[x^2]]
Mathematica treats symbols as complex by default, and √(x²) = x is false for, say, x = −3. Only with an assumption (second argument of Simplify, or Assuming) does it simplify to x. Without assumptions even FullSimplify leaves Sqrt[x^2].
In Maple, what does the following command return?
solve({x + y = 3, x - y = 1}, {x, y});- {x = 1, y = 2}
- [2, 1]
- x = 2
- {x = 2, y = 1}
Adding the equations gives 2x = 4, so x = 2 and y = 1. With a set of equations and a set of unknowns Maple returns the solution as a set of equations, which can be used directly in eval or assign. Swapping the values is a careless reading of the system.
In SymPy with x = symbols('x'), what does the following call return?
solve(sin(x), x)- [0]
- all multiples of pi: n*pi for integer n
- []
- [0, pi]
solve returns only a finite list of representative solutions for periodic equations — here 0 and π. To get the complete solution set use solveset(sin(x), x, S.Reals), which returns an infinite union of ImageSets (2nπ and 2nπ + π). Trusting solve's list as "all roots" is a common mistake.
Calculus10
In Mathematica, what does the following input return?
D[x^3, x]- x^4/4
- 3 x^3
- 3 x^2
- x^2
D[f, x] is the derivative with respect to x: d/dx x³ = 3x². x⁴/4 is the antiderivative, which you would get from Integrate, and 3x³ forgets to lower the exponent.
In Mathematica, what does the following input return?
Limit[Sin[x]/x, x -> 0]- 0
- 1
- Indeterminate
- ComplexInfinity
sin x / x → 1 as x → 0 (the classic remarkable limit). Plugging in 0 directly gives 0/0, which is why a naive evaluation would report Indeterminate; Limit finds the actual limiting value.
In SymPy with x = symbols('x'), what does integrate(1/x, x) return?
- log(Abs(x)) + C
- ln(x) + C
- log(x)
- -1/x**2
SymPy returns one antiderivative, without the constant of integration, and its log is the natural logarithm (there is no separate ln in the output). It also gives log(x) rather than log(|x|), which is valid for complex x. −1/x² is the derivative of 1/x, not its integral.
In Maxima, what does the following input return?
integrate(exp(-x^2), x, minf, inf);- sqrt(%pi)/2
- sqrt(%pi)
- 1
- %pi
This is the Gaussian integral: ∫ e^(−x²) dx over the whole real line = √π. In Maxima minf and inf denote −∞ and +∞. √π/2 is the value over half the line (0 to ∞), a frequent mix-up.
In SymPy with x = symbols('x'), what does the following call return?
limit(1/x, x, 0)- -oo
- oo
- zoo
- It raises an error because the two-sided limit does not exist
SymPy's limit is one-sided by default, with dir='+', so it computes lim 1/x as x → 0⁺ = +∞ (oo). The two-sided limit does not exist; you must ask for it explicitly with dir='+-'. Assuming a two-sided limit is the trap here.
In Maple, what does the following command return?
int(x^2, x = 0 .. 1);- 0.3333333333
- x^3/3
- 1/3
- 1
With a range x = a .. b, int computes the definite integral exactly: ∫₀¹ x² dx = 1/3. Without the range, int(x^2, x) would return the antiderivative x^3/3. A decimal appears only after evalf.
In SymPy with x = symbols('x'), what does the following call return?
diff(x**3*sin(x), x)- 3*x**2*cos(x)
- x**3*cos(x) + 3*x**2*sin(x)
- x**3*cos(x)
- 3*x**2*sin(x) - x**3*cos(x)
Product rule: (uv)' = u'v + uv' = 3x²·sin x + x³·cos x. 3x²·cos x multiplies the two derivatives, a common mistake, and a minus sign belongs to the quotient rule, not the product rule.
In Mathematica, what does the following input return?
Series[Sin[x], {x, 0, 5}]- x - x^3/6 + O[x]^4
- x - x^3/6 + x^5/120 + O[x]^6
- x - x^3/3 + x^5/5 + O[x]^6
- 1 - x^2/2 + x^4/24 + O[x]^6
Series[f, {x, x0, n}] expands up to the power n: sin x = x − x³/3! + x⁵/5! + O(x⁶). Dividing by n instead of n! gives x − x³/3 + x⁵/5, and 1 − x²/2 + x⁴/24 is the series of cos x.
In SymPy with x = symbols('x'), what does the following call return?
series(exp(x), x, 0, 4)- 1 + x + x**2/2 + x**3/6 + x**4/24 + O(x**5)
- 1 + x + x**2/2 + O(x**3)
- 1 + x + x**2/2 + x**3/6 + O(x**4)
- x + x**2/2 + x**3/6 + x**4/24
In series(expr, x, x0, n) the last argument is the order of the O-term, not the number of terms or the highest power kept: n = 4 means terms up to x³ and O(x**4). The series of eˣ starts with 1, which the last option forgets.
In SymPy with x, n = symbols('x n') and no assumptions, what does integrate(x**n, x) return?
- x**(n + 1)/(n + 1)
- Piecewise((x**(n + 1)/(n + 1), Ne(n, -1)), (log(x), True))
- n*x**(n - 1)
- log(x)
The usual formula xⁿ⁺¹/(n + 1) breaks down for n = −1 (division by zero), where the antiderivative is log x. Because n is a free symbol, SymPy returns both cases in a Piecewise. The bare power formula is the textbook answer that forgets this case; n·xⁿ⁻¹ is the derivative.
Differential equations10
In Mathematica, what does the following input return?
DSolve[y'[x] == y[x], y[x], x]- {{y[x] -> E^x}}
- {{y[x] -> x + C[1]}}
- y[x] == E^x C[1]
- {{y[x] -> E^x C[1]}}
The general solution of y' = y is y = C·eˣ. Mathematica names arbitrary constants C[1], C[2], ... and, like Solve, returns the solution as a list of replacement rules. Dropping C[1] gives only one particular solution.
Which Mathematica function solves a differential equation numerically when no closed-form solution is needed or available?
- NDSolve
- NSolve
- DSolve
- NIntegrate
NDSolve integrates an ODE numerically and returns an InterpolatingFunction. DSolve looks for a symbolic solution, NSolve solves algebraic (polynomial) equations numerically, and NIntegrate computes definite integrals, not ODEs.
In Maple, what does the following command return?
dsolve({diff(y(x), x) = 2*y(x), y(0) = 3}, y(x));- y(x) = 2*exp(3*x)
- y(x) = _C1*exp(2*x)
- y(x) = 3*exp(x) + 2
- y(x) = 3*exp(2*x)
y' = 2y gives y = C·e^(2x), and y(0) = 3 gives C = 3. The initial condition goes in the same set as the ODE, so the constant is determined and _C1 disappears. Swapping 2 and 3 confuses the rate with the initial value.
In SymPy with x = symbols('x') and f = Function('f'), what does the following call return?
dsolve(f(x).diff(x) - x*f(x), f(x))- Eq(f(x), C1*exp(x**2/2))
- Eq(f(x), C1*exp(x))
- Eq(f(x), C1*exp(x**2))
- Eq(f(x), x**2/2 + C1)
Separate variables: f'/f = x, so ln f = x²/2 + c and f = C1·e^(x²/2). Forgetting the 1/2 from ∫x dx gives exp(x**2), and x²/2 + C1 integrates the right-hand side while forgetting that the derivative is of ln f.
In Mathematica, why is DSolve[y'[x] == y[x], y, x] (second argument y) often preferred over DSolve[y'[x] == y[x], y[x], x]?
- With y[x] DSolve can only find numerical solutions
- With y the solution has no arbitrary constants
- With y[x] the equation is solved for x instead of y
- With y it returns y -> Function[...], so the rule also replaces y'[x], y[0] and so on; with y[x] the rule only replaces the literal y[x]
DSolve[..., y[x], x] gives {{y[x] -> E^x C[1]}}, so y'[x] /. sol or y[0] /. sol stays unchanged — a common surprise when checking a solution. DSolve[..., y, x] returns a pure function, y -> Function[{x}, E^x C[1]], and replacing y then works for derivatives and other arguments too.
Maple's dsolve(diff(y(x), x) = y(x), y(x)) returns y(x) = _C1*exp(x). What is _C1?
- The value of y at x = 1
- A placeholder that marks an error in the equation
- The first eigenvalue of the equation
- An arbitrary constant of integration in the general solution
Without initial conditions dsolve returns the general solution, and Maple names the free constants _C1, _C2, .... They are fixed only when you add conditions such as y(0) = 3. It has nothing to do with y(1) or eigenvalues.
In SymPy with x = symbols('x') and f = Function('f'), what does the following call return?
dsolve(f(x).diff(x) - f(x), f(x), ics={f(0): 2})- Eq(f(x), C1*exp(x))
- Eq(f(x), exp(x) + 2)
- Eq(f(x), 2*exp(x))
- Eq(f(x), 2*exp(-x))
The ODE f' − f = 0 has general solution C1·eˣ, and f(0) = 2 gives C1 = 2. Passing ics fixes the constant, so C1 no longer appears. eˣ + 2 adds the initial value instead of multiplying, and e⁻ˣ solves f' = −f.
In Mathematica, how do you get the numerical value of the solution at x = 2?
sol = NDSolve[{y'[x] == -y[x], y[0] == 1}, y, {x, 0, 5}];- sol[2]
- y[2]
- y[2] /. sol
- N[sol, 2]
NDSolve returns a list of rules {{y -> InterpolatingFunction[...]}}; the rule must be applied with /. so y becomes the interpolating function, and y[2] /. sol gives {0.135335} (≈ e⁻²). y on its own is still an undefined symbol, and sol[2] is not a function call on the solution.
In SymPy with x = symbols('x') and f = Function('f'), what does the following call return?
dsolve(f(x).diff(x, 2) + f(x), f(x),
ics={f(0): 0, f(x).diff(x).subs(x, 0): 1})- Eq(f(x), cos(x))
- Eq(f(x), C1*sin(x) + C2*cos(x))
- Eq(f(x), exp(x))
- Eq(f(x), sin(x))
f'' + f = 0 has general solution C1·sin x + C2·cos x. f(0) = 0 gives C2 = 0, and f'(0) = 1 gives C1 = 1, so f = sin x. The derivative condition is written as f(x).diff(x).subs(x, 0). cos x satisfies f(0) = 1, f'(0) = 0 — the conditions swapped.
Why is there a quote before diff in this Maxima input?
ode2('diff(y, x) = y, y, x);- It marks y as the unknown function
- It tells ode2 to return a numerical solution
- It is a typo; Maxima ignores the quote
- The quote prevents diff from being evaluated; otherwise diff(y, x) would be 0 because y is just a symbol that does not depend on x
Without the quote Maxima evaluates diff(y, x) immediately, and since y has no declared dependence on x the result is 0, so ode2 would receive 0 = y. The noun form 'diff keeps the derivative symbolic. The result is y = %c*%e^x, where %c is the arbitrary constant.
Linear algebra10
In Mathematica, what does the following input return?
Det[{{1, 2}, {3, 4}}]- -2
- 2
- 10
- -5
For a 2×2 matrix det = ad − bc = 1·4 − 2·3 = −2. Getting 2 is the sign error bc − ad, 10 is just the sum of the entries, and −5 = 1 − 2·3 forgets a factor.
After with(LinearAlgebra), which Maple command computes the eigenvalues of a Matrix A?
- Eigenvalues[A]
- eig(A)
- Eigenvalues(A)
- A.eigenvals()
LinearAlgebra commands are capitalized and called with parentheses: Eigenvalues(A), Determinant(A), MatrixInverse(A). Square brackets are Mathematica's call syntax, eig(A) is MATLAB, and A.eigenvals() is SymPy.
In SymPy, what does A*B return?
A = Matrix([[1, 2], [3, 4]])
B = Matrix([[0, 1], [1, 0]])
A*B- Matrix([[0, 2], [3, 0]])
- Matrix([[3, 4], [1, 2]])
- Matrix([[2, 1], [4, 3]])
- ShapeError
For SymPy Matrix objects * is the true matrix product (row times column); here multiplying by B swaps the columns. The element-wise product is A.multiply_elementwise(B) = [[0, 2], [3, 0]]. Swapping the rows instead corresponds to B*A.
In Mathematica, what does the following input return?
Eigenvalues[{{2, 1}, {1, 2}}]- {3, 1}
- {2, 2}
- {3, -1}
- {{1, 1}, {-1, 1}}
The characteristic polynomial is (2 − λ)² − 1 = λ² − 4λ + 3 = (λ − 3)(λ − 1), so λ = 3, 1 (trace 4, determinant 3 — a quick check). {2, 2} is just the diagonal, and {{1, 1}, {-1, 1}} are eigenvectors, returned by Eigenvectors.
In Maxima, M : matrix([1, 2], [3, 4]). Which input gives the matrix product M·M, i.e. matrix([7, 10], [15, 22])?
- M^2
- M*M
- M**2
- M^^2
In Maxima . is the non-commutative (matrix) product and ^^ the matching power, so M^^2 = M . M. The commutative operators *, ^ and ** act element-wise on matrices and give matrix([1, 4], [9, 16]).
Which input creates the 2×2 matrix with rows (1, 2) and (3, 4) in Maxima?
- Matrix([[1, 2], [3, 4]])
- matrix([1, 2], [3, 4])
- {{1, 2}, {3, 4}}
- [[1, 2], [3, 4]]
Maxima's matrix() takes each row as a separate list argument. Matrix([[1, 2], [3, 4]]) is SymPy, {{1, 2}, {3, 4}} is Mathematica, and [[1, 2], [3, 4]] in Maxima is only a list of lists, not a matrix.
In Mathematica, what does the following input return?
{{1, 2}, {3, 4}} * {{0, 1}, {1, 0}}- {{2, 1}, {4, 3}}
- {{3, 4}, {1, 2}}
- {{0, 2}, {3, 0}}
- 6
In Mathematica * (Times) is element-wise for lists: each entry is multiplied by the entry in the same position. The matrix product needs a dot: A . B = {{2, 1}, {4, 3}}. Using * for matrix multiplication is a very common bug.
In SymPy, what does A.inv() return?
A = Matrix([[1, 2], [3, 4]])
A.inv()- Matrix([[-2.0, 1.0], [1.5, -0.5]])
- Matrix([[4, -2], [-3, 1]])
- Matrix([[1, 1/2], [1/3, 1/4]])
- Matrix([[-2, 1], [3/2, -1/2]])
A⁻¹ = (1/det A)·[[d, −b], [−c, a]] = (1/−2)·[[4, −2], [−3, 1]] = [[−2, 1], [3/2, −1/2]]. SymPy works with exact integer input, so the result has exact rationals, not floats. [[4, −2], [−3, 1]] forgets to divide by the determinant, and inverting each entry is not a matrix inverse.
In SymPy, what does the following call return?
Matrix([[2, 0], [0, 2]]).eigenvals()- {2: 2}
- [2, 2]
- {2: 1}
- {2: 1, 2: 1}
eigenvals() returns a dictionary {eigenvalue: algebraic multiplicity}. The only eigenvalue is 2 and it is a double root of (2 − λ)², hence {2: 2}. A dict cannot hold the key 2 twice, and reading the value as "the eigenvalue" instead of its multiplicity is the usual misunderstanding.
In Mathematica, what does the following input return?
{{1, 2}, {3, 4}}^2- {{1, 4}, {9, 16}}
- {{7, 10}, {15, 22}}
- {{2, 4}, {6, 8}}
- -2
Power, like Times, works element-wise on lists, so every entry is squared. The matrix square needs MatrixPower[m, 2] or m . m, which gives {{7, 10}, {15, 22}}. {{2, 4}, {6, 8}} is 2m.
Plotting10
Which input plots sin x for 0 ≤ x ≤ 2π in Mathematica?
- Plot[Sin[x], {x, 0, 2 Pi}]
- Plot[Sin[x], x, 0, 2 Pi]
- plot(sin(x), x = 0 .. 2*Pi)
- Plot(Sin[x], {x, 0, 2 Pi})
Mathematica's iterator syntax {x, xmin, xmax} groups the variable and its range in braces, and the function is called with square brackets. plot(sin(x), x = 0 .. 2*Pi) is Maple syntax.
What does this Maple command draw?
plot3d(x^2 - y^2, x = -1 .. 1, y = -1 .. 1);- A paraboloid opening upwards
- Two curves y = x² and y = −x² in the plane
- A saddle-shaped surface z = x² − y² over the square [−1, 1] × [−1, 1]
- A circle of radius 1
plot3d draws the graph of a function of two variables. z = x² − y² rises along the x-axis and falls along the y-axis — a hyperbolic paraboloid (saddle). An upward-opening paraboloid would be x² + y².
How do you draw sin x and cos x in the same Mathematica plot?
- Plot[Sin[x], Cos[x], {x, 0, 2 Pi}]
- Plot[Sin[x] + Cos[x], {x, 0, 2 Pi}]
- Plot[Sin[x]; Cos[x], {x, 0, 2 Pi}]
- Plot[{Sin[x], Cos[x]}, {x, 0, 2 Pi}]
Several functions go into the first argument as a list in braces; each becomes its own curve. Plot[Sin[x] + Cos[x], ...] draws one curve, the sum, and Plot expects the iterator {x, xmin, xmax} as its second argument, so Cos[x] in that position is an error.
Which SymPy call plots x² for −2 ≤ x ≤ 2 (with x = symbols('x') and plot imported from sympy)?
- plot(x**2, x = -2 .. 2)
- plot(x**2, (x, -2, 2))
- plot(x**2, {x, -2, 2})
- plot(x^2, (x, -2, 2))
SymPy's plot takes the range as a tuple (symbol, start, end). x = -2 .. 2 is Maple notation and not valid Python, braces would make a Python set, and x^2 raises TypeError because ^ is XOR in Python.
In Maple, what is the difference between these two commands?
plot([cos(t), sin(t), t = 0 .. 2*Pi]);
plot([cos(t), sin(t)], t = 0 .. 2*Pi);- Both draw the unit circle
- Both draw two separate curves
- The first draws two curves, the second draws the unit circle
- The first draws the unit circle (parametric plot), the second draws the graphs of cos t and sin t as two curves
In Maple a parametric plot is recognized when the range is placed inside the list: [x(t), y(t), t = a .. b]. With the range outside, the list is simply a list of functions to plot against t. Misplacing one bracket changes the meaning of the whole plot.
Which input plots sin x for 0 ≤ x ≤ 2π in Maple?
- plot(sin(x), [x, 0, 2*Pi]);
- Plot[Sin[x], {x, 0, 2 Pi}]
- plot(sin(x), x = 0 .. 2*Pi);
- plot(sin(x), x = 0 : 2*Pi);
Maple writes the range as an equation with the .. operator: x = 0 .. 2*Pi. [x, 0, 2*Pi] is the Maxima plot2d style, Plot[...] is Mathematica, and a colon is not a range operator in Maple.
What does this Mathematica input draw?
Plot3D[x^2 + y^2, {x, -1, 1}, {y, -1, 1}]- A bowl-shaped paraboloid with its minimum at the origin
- A saddle surface
- A sphere of radius 1
- A circle in the xy-plane
Plot3D plots z = f(x, y). z = x² + y² is 0 at the origin and grows in every direction, so the surface is an upward bowl (paraboloid). A saddle would be x² − y², and a sphere is not the graph of a single function z = f(x, y).
What curve does this Mathematica input draw?
ParametricPlot[{Cos[t], Sin[t]}, {t, 0, 2 Pi}]- The graphs of cos t and sin t as two separate curves
- A sine wave
- A straight line from (1, 0) to (0, 1)
- The unit circle
ParametricPlot treats the list as the point (x(t), y(t)) = (cos t, sin t). Since cos²t + sin²t = 1 and t runs over a full period, the point traces the unit circle once. Two separate curves would come from Plot[{Cos[t], Sin[t]}, ...].
Which Maxima input plots sin x for 0 ≤ x ≤ 2π?
- plot2d(sin(x), x = 0 .. 2*%pi);
- plot(sin(x), [x, 0, 2*pi]);
- plot2d(sin(x), {x, 0, 2*%pi});
- plot2d(sin(x), [x, 0, 2*%pi]);
Maxima's 2D plotting command is plot2d, the range is a list [variable, min, max], and π is written %pi. The x = 0 .. 2*%pi form is Maple, braces are Mathematica, and plain pi is an unassigned symbol in Maxima.
In Maple, plot(1/(x - 1), x = 0 .. 2) draws a nearly vertical line at x = 1. What fixes it?
- Increasing Digits
- Adding the option discont = true
- Replacing 1/(x - 1) by evalf(1/(x - 1))
- Writing the range as x = 0.0 .. 2.0
plot samples points and connects them with segments, so it joins the huge negative value just left of the pole with the huge positive value just right of it. discont = true makes Maple detect the discontinuity and not connect across it (a view = -10 .. 10 option also helps). Precision and float ranges do not change the sampling logic.
Numerics and pitfalls10
In Mathematica, what does the following input return?
{1/3, 1./3}- {0.333333, 0.333333}
- {1/3, 1/3}
- {0, 0.333333}
- {1/3, 0.333333}
1/3 of two integers is kept as the exact rational 1/3. The decimal point in 1. makes it an approximate number, so 1./3 is computed in floating point. Integer division to 0 is a C/old-Python habit; Mathematica never truncates 1/3.
In Mathematica, what does the following input return?
Sqrt[2.]^2 - 2- 4.44089*10^-16
- 0
- 0.
- Sqrt[2]^2 - 2
2. is a machine float, so the square root is rounded to the nearest double; squaring it gives 2.0000000000000004, and subtracting 2 exposes the rounding error 2⁻⁵¹ ≈ 4.44·10⁻¹⁶. With exact input, Sqrt[2]^2 - 2 gives exactly 0.
In Mathematica, what does the following input return?
Log[-1]- I Pi
- Indeterminate
- -I Pi
- 0
Mathematica uses the principal branch of the complex logarithm, with the imaginary part in (−π, π]. Since e^(iπ) = −1, Log[-1] = iπ. The branch cut lies along the negative real axis, and −iπ is outside the principal range.
In SymPy, what does the following expression return?
(-8)**Rational(1, 3)- -2
- 2*(-1)**(1/3)
- 2
- nan
SymPy (like Mathematica and Maple) uses the principal complex root: (−8)^(1/3) = 2·e^(iπ/3) = 1 + 1.732i, written 2*(-1)**(1/3). The real cube root −2 needs real_root(-8, 3). Expecting −2 is the typical pitfall when plotting x**(1/3) for negative x.
In SymPy with x = symbols('x') (no assumptions), which expression simplifies to x?
- simplify(log(exp(x)))
- simplify(exp(log(x)))
- simplify(sqrt(x**2))
- simplify(asin(sin(x)))
e^(log x) = x holds for every nonzero complex x, so SymPy simplifies it. log(eˣ) = x fails for complex x (e.g. x = 2πi gives log 1 = 0), √(x²) = x fails for negative x, and asin(sin x) = x fails outside [−π/2, π/2] (asin(sin π) = 0), so these stay unsimplified. Assuming every inverse function cancels its function is the trap.
In plain Python (as used with SymPy), what does 0.1 + 0.2 == 0.3 return?
- True
- False
- 0.3
- It raises an error
0.1, 0.2 and 0.3 have no exact binary floating-point representation; 0.1 + 0.2 is 0.30000000000000004, which differs from the float 0.3 in the last bit. Compare floats with a tolerance (math.isclose) or use exact Rational numbers in SymPy.
Why does a CAS such as Mathematica, Maple or SymPy leave sqrt(x^2) unsimplified when x is a symbol without assumptions?
- Because √(x²) = x is false in general, for example for x = −3
- Because simplifying square roots is too slow
- Because √(x²) = −x for all x
- Because the CAS cannot square symbols
Symbols are treated as complex numbers by default. For x = −3, √((−3)²) = √9 = 3 ≠ −3, so the rule √(x²) = x would be wrong. For real x the correct result is |x|, and for positive x it is x — each needs an assumption.
In SymPy, what does the last line return?
r = symbols('r', real=True)
sqrt(r**2)- Abs(r)
- r
- sqrt(r**2)
- -r
Knowing that r is real, SymPy can simplify √(r²) to |r|, but not to r, because r may be negative. With symbols('r', positive=True) the result would be r, and with no assumptions it stays sqrt(r**2).
In SymPy with x = symbols('x'), what does x**(1/3) produce?
- x**(1/3)
- x
- x**0.333333333333333
- x**0
Python evaluates 1/3 to the float 0.333..., so the exponent is a Float and later symbolic work (e.g. cubing) no longer gives exact results. Use x**Rational(1, 3) or cbrt(x) to get the exact cube root x**(1/3).
In Mathematica, 0.1 + 0.2 == 0.3 returns True, while in Python it is False. Why?
- Mathematica stores 0.1 and 0.2 exactly as rationals
- Mathematica uses decimal instead of binary floating point
- Mathematica's Equal treats machine numbers as equal if they differ only in the last few binary digits
- Mathematica rounds every result to 6 digits before comparing
Both systems store the same IEEE doubles, and 0.1 + 0.2 is not bit-for-bit 0.3 in either. Mathematica's == deliberately tolerates a difference in the last 7 bits of approximate numbers, while Python compares exactly. The 6-digit display is only formatting; the stored value keeps full machine precision.
Как проходить тест
- Выберите темы и уровень — лёгкий уровень проверяет определения и задачи в одно действие, средний — стандартные вычисления, сложный — многошаговые задачи и теорию.
- Отвечайте касанием или с клавиатуры: 1–4 или A–D, Enter — следующий вопрос.
- Читайте объяснения — после ошибки разбор открывается сразу, после верного ответа его можно раскрыть кнопкой «Почему».
- Работайте над ошибками — «Повторить ошибки» в конце теста или режим «Только мои ошибки» потом: ответы запоминаются в этом браузере.
Незавершённый тест сохраняется — после перезагрузки страницы можно продолжить с того же вопроса.
Темы теста
- CAS basics 10
- Mathematica syntax 10
- Maple syntax 10
- Maxima and SymPy 10
- Algebra and simplification 10
- Calculus 10
- Differential equations 10
- Linear algebra 10
- Plotting 10
- Numerics and pitfalls 10
Другие тесты
Тест по линейной алгебре160 вопросовТест по дифференциальным уравнениям130 вопросовТест по теории вероятностей и статистике130 вопросовТест по SAS100 вопросовТест по языку R100 вопросовТест по LaTeX100 вопросовТест по Fortran120 вопросовТест по языку C100 вопросовТест по COBOL100 вопросовТест по MATLAB100 вопросовТест по PowerBuilder100 вопросовТест по UNIX100 вопросов
