#12834: Modify subs so that it can accept multiple equations just like subs_expr
-------------------------------------+-------------------------------------
Reporter: JoalHeagney | Owner: AlexGhitza
Type: enhancement | Status: needs_review
Priority: minor | Milestone: sage-6.4
Component: algebra | Resolution:
Keywords: subs algebra | Merged in:
solving | Reviewers:
Authors: Michael Orlitzky | Work issues:
Report Upstream: N/A | Commit:
Branch: public/12384 | 045eebfd67858405c6665acfa1eea5f22ca7fc6f
Dependencies: | Stopgaps:
-------------------------------------+-------------------------------------
Description changed by vdelecroix:
Old description:
> This came up as a method of passing solutions from solve back into
> symbolic equations:
>
> {{{
> f(x,y) = (1-x)^2 + 100*(y - x^2)^2
>
> solution = solve([f.diff(ar) for ar in f.args()],f.args())[0]
>
> Gives me a list of solutions as:
>
> [x=1;y=1]
>
> Is there any way to programatically substitute this list of equalities
> back into f?
> }}}
>
> The solution provided by Michael Orlitzky was
>
> {{{
> f(x,y).subs_expr(*solution)
> }}}
>
> Anycase, as noted by Michael, it would be nice if subs had the same
> behaviour:
>
> {{{
> Passing it one equation does work,
>
> sage: f.subs(x == 1)
> y + z + 1
>
> But more than one doesn't,
>
> sage: f.subs(x == 1, y == 2)
> ...
> TypeError: substitute() takes at most 1 positional argument (2 given)
>
> I guess all that's missing is the ability to pass it multiple equations,
> like `subs_expr`. It would probably be easy to add that ability to
> `subs` if you want to create a ticket for something.
> }}}
>
> Apply sage-trac_12834.2.patch
New description:
This came up as a method of passing solutions from solve back into
symbolic equations:
{{{
f(x,y) = (1-x)^2 + 100*(y - x^2)^2
solution = solve([f.diff(ar) for ar in f.args()],f.args())[0]
Gives me a list of solutions as:
[x=1;y=1]
Is there any way to programatically substitute this list of equalities
back into f?
}}}
The solution provided by Michael Orlitzky was
{{{
f(x,y).subs_expr(*solution)
}}}
Anycase, as noted by Michael, it would be nice if subs had the same
behaviour:
{{{
Passing it one equation does work,
sage: f.subs(x == 1)
y + z + 1
But more than one doesn't,
sage: f.subs(x == 1, y == 2)
...
TypeError: substitute() takes at most 1 positional argument (2 given)
I guess all that's missing is the ability to pass it multiple equations,
like `subs_expr`. It would probably be easy to add that ability to
`subs` if you want to create a ticket for something.
}}}
With the branch applied we have:
{{{
sage: f(x,y) = (1-x)^2 + 100*(y - x^2)^2
sage: solution = solve([f.diff(ar) for ar in f.args()],f.args())
sage: solution
[[x == 1, y == 1]]
sage: f.subs(solution[0])
(x, y) |--> 0
}}}
--
--
Ticket URL: <http://trac.sagemath.org/ticket/12834#comment:13>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.