Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

What kind of function do you want? Here a basic example for beginners. (http://www.hr.shuttle.de:9000/home/pub/31)

# Minima / Maxima
A = (-1 , 1)
B = ( 3 , 3)

# Root
C = (1 , 0)

var("a0 a1 a2 a3 a4 a5 a6")

# f(x) = a5*x^5+ a4*x^4+a3*x^3 + a2*x^2+ a1*x + a0
f(x) = a4*x^4+a3*x^3 + a2*x^2+ a1*x + a0
# f(x) = a3*x^3 + a2*x^2+ a1*x + a0

df = diff(f,x); 
ddf = diff(df,x); 

xa,ya = A; xb,yb = B; xc,yc = C
# equations   
eq1 = ( f(xa) == ya )
eq2 = ( df(xa) == 0 )
eq3 = ( f(xb) == yb )
eq4 = ( df(xb) == 0 )
eq5 = ( f(xc) == yc )
sol = solve([eq1,eq2,eq3,eq4,eq5],a0,a1,a2,a3,a4, solution_dict=True)
show(sol)
g = f.substitute(sol[0])
show(g)
plot(g,-4,4,ymin=-5,ymax=5)