Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

That's a solve idiosyncrasy :

Each solution of a(n) (system of) equation(s) for n>1 variables is either a list of n equations (default) or a dictionary with n keys (when using solution_dict=True). solve returns a list of such solutions, i. e. either a list of n-long lists or a list of n-long dictionaries.

However, when solving a(n) (system of) equation(s) for one variable and not using solution_dict=True, solve "simplifies" what should be a list of 1-long lists in a list of equations, each of them being a solution for this variable.

This (disputable) simplification has been baked in Sage since Sage early developers decoded to follow Maxima's conventions (dating from the early 1960's...). Complain fiercely...

Workaround : use solution_dict=True, whose return values are more consistent (and usually easier to use, anyway...).

HTH,

That's a solve idiosyncrasy :

Each solution of a(n) (system of) equation(s) for n>1 variables is either a list of n equations (default) or a dictionary with n keys (when using solution_dict=True). solve returns a list of such solutions, i. e. either a list of n-long lists or a list of n-long dictionaries.

However, when solving a(n) (system of) equation(s) for one variable and not using solution_dict=True, solve "simplifies" what should be a list of 1-long lists in a list of equations, each of them being a solution for this variable.

This (disputable) simplification has been baked in Sage since Sage Sage's early developers decoded to follow Maxima's conventions (dating from the early 1960's...). 1960's...) and is now a geological axiom. Complain fiercely...

Workaround : use solution_dict=True, whose return values are more consistent (and usually easier to use, anyway...).

HTH,

It seems that the output has length only 1, so s[0] does not work.

That's a solve idiosyncrasy :

Each solution of a(n) (system of) equation(s) for n>1 variables is either a list of n equations (default) or a dictionary with n keys (when using solution_dict=True). solve returns a list of such solutions, i. e. either a list of n-long lists or a list of n-long dictionaries.

However, when solving a(n) (system of) equation(s) for one variable and not using solution_dict=True, solve "simplifies" what should be a list of 1-long lists in a list of equations, each of them being a solution for this variable.

This (disputable) simplification has been baked in Sage since Sage's early developers decoded to follow Maxima's conventions (dating from the early 1960's...) and is now a geological axiom. Complain fiercely...

Workaround : use solution_dict=True, whose return values are more consistent (and usually easier to use, anyway...).

HTH,