1 | initial version |

Here an example where you don't have to rewrite the code. I do not distinguish between minima and maxima. Controlling behavior for x to infinity: set some additional points.

```
L_roots = [-1,0]
L_min_max = [(1,1),(5,1)]
L_other = [(10,10)]
N = len(L_roots)+2*len(L_min_max)+len(L_other) -1
param_str = reduce(lambda x,y:x+y,['a%s,'%(k) for k in [0..N]])
params = var(param_str[:-1])
f(x) = sum([ params[k]*x^k for k in [0..N]])
df = diff(f,x)
show(f)
eqns = [ f(x0)==0 for x0 in L_roots ]
eqns += [ f(P[0])==P[1] for P in L_min_max ]
eqns += [ df(P[0])==0 for P in L_min_max ]
eqns += [ f(P[0])==P[1] for P in L_other ]
sol=solve(eqns,params,solution_dict=True)
show(f.substitute(sol[0]))
```

2 | No.2 Revision |

Here an example where you don't have to rewrite the code. I do not distinguish between minima and maxima. Controlling behavior for x to infinity: set some additional points.

```
L_roots = [-1,0]
L_min_max = [(1,1),(5,1)]
L_other = [(10,10)]
N = len(L_roots)+2*len(L_min_max)+len(L_other) -1
param_str = reduce(lambda x,y:x+y,['a%s,'%(k) for k in [0..N]])
```~~params ~~param_list = var(param_str[:-1])
f(x) = sum([ ~~params[k]*x^k ~~param_list[k]*x^k for k in [0..N]])
df = diff(f,x)
show(f)
eqns = [ f(x0)==0 for x0 in L_roots ]
eqns += [ f(P[0])==P[1] for P in L_min_max ]
eqns += [ df(P[0])==0 for P in L_min_max ]
eqns += [ f(P[0])==P[1] for P in L_other ]
~~sol=solve(eqns,params,solution_dict=True)
~~sol=solve(eqns,param_list,solution_dict=True)
show(f.substitute(sol[0]))

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.