Using SymPy
module, is there a method to tell me if the equation is linear or non-linear? If not what's your recommendation to implement such a method. I noticed from documentation that solve()
returned values change according to the coefficients.
I just need it as a simple introduction to high school students. to answer a question I found to label whether the function is linear or not.
thank you very much.
The answer depends on what you want to do next. To just get a True/False answer try Poly(expr, x).is_linear
. This will expand the expression and tell you if it is linear in x
.
linear_coeffs
will either raise an error if non-linear terms are encountered or else give you the linear coefficients of the given variables, solveset.linear_coeffs(2*x+3*y+z**2,x,y) -> [2, 3, z**2]
(where the last element is the constant term in the expression).
linear_eq_to_matrix
and solve_linear
are also possibilities.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.