All published worksheets from http://sagenb.org
Image: ubuntu2004
This is a modified (higher degree) version Harald's example. We solve a pair of equations in a pair of unknowns:
We wish to apply a function f of two variables to each of these solutions:
Here's one approach, using Python's built-in map() function and a lambda, or "anonymous," function. We note that this depends on the two values being in a specific order (first x, then y) for all solutions in sol:
However, we do not need to know the number of variables in advance. Let's use Python's * operator, which converts a list into an argument list, and nested list comprehensions (why not?), to define another higher-order function:
Again, we obtain the value of f "on" each of the solutions in sol:
Finally, we simplify the recipe to get the same result:
That was spectacular.