Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

solve solution change after cell evaluation

Hello everyone,

I wanted to fit some data and I found a strange behaviour of solve(). After evaluating cell 1,2 and 3 and further evaluations of cell 2,3,2,3,2,3,... the solution for kf changes and gets smaller and smaller. I use Sage 5.9 in a VM in Win7Prof

cell1

# data=[another list]
data=((0.004,34.915),(0.018,34.665),(0.040,34.254),(0.071,33.695),(0.159,32.146),(0.282,30.323))
p1=list_plot(data,plotjoined=True,xmin=0,xmax=1,ymin=20,ymax=35)

cell2

# modell for fitting
lg=20
lm=35
A=(lm-lg)/(1-exp(-k))
c=lm-A
var('kf')
testmodel(t)=c+A*exp(-kf*t)

best_fit_par=find_fit(data,testmodel(t),initial_guess=[0.5],parameter=[kf],variables=[t],solution_dict=True)
print 'best_fit_par'
print best_fit_par

cell3

k=best_fit_par[kf]
lg=20
lm=35
A=(lm-lg)/(1-exp(-k))
c=lm-A
p2=plot(A*exp(-k*t)+c,(t,0,1),xmin=0,xmax=1,ymin=20,ymax=35)
show(p1*p2)

The values for kf started at 0.49 and are wandering towards 0.35

Thanks in advance