That was the way I used to do it when I discovered the solution_dict
param.

So, I started using the dictionaries to do substitution even in
complex expressions... The result was to wait so much time!

On the contrary, I found that the subs(expr, x=<value>) was SOOOO much
faster (are the dictionaries so slow to deal with?).

So, I implemented a subList function, where I can pass an expression,
and a list of substitution, in the very same way that the solve()
function returns the results.

So, now I put all my subsets of numerical values in list like this:
set = [x == 10, y == 20, z == 30, ...]
and do the substitution like this:
result = subList(expr, set)

Within the function, I just iterate the subs(expr, x = <value>) on the
number of list elements.

This seems to me much faster than using dictionaries, especially for
complex expressions.

Maurizio

> I'd do something like this:
>
> sage: var('x y')
> (x, y)
> sage: d, = solve([x+y==6, x-y==4], x, y, solution_dict=True)
> sage: d
> {y: 1, x: 5}
> sage: f = 2*x+y
> sage: f.subs(d)
> 11
>
> --Mike
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to