ASKSAGE: Sage Q&A Forum - Latest question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 04 Jan 2016 12:36:40 -0600curve fitting coefficients.http://ask.sagemath.org/question/32057/curve-fitting-coefficients/get the model coefficients, but I can not use them to plot the graph. How to solve?
see the code:
dados = [(0, -0.183440428023042),
(0.200000000000000, -0.131101157495126),
(0.400000000000000, 0.0268875670852843),
(0.800000000000000, 0.110532679260319),
(1.00000000000000, 0.253944632998395),
(1.20000000000000, 0.257190123748649),
(1.40000000000000, 0.531888837111346),
(1.60000000000000, 0.579048247883555),
(2.00000000000000, 0.935180993484717),
(2.20000000000000, 0.916600344376623),
(2.60000000000000, 1.13328608090532),
(2.80000000000000, 1.26893326843583),
(3.00000000000000, 1.10202945535186),
(3.40000000000000, 1.13391615491257)]
point(dados,color = "red",size=20,legend_label="pontos coletados")
modelo(x) = a*x+b;modelo
a,b = find_fit(dados, modelo);a;b
modelo(x) = a*x+b
point(dados,color = "red",size=20,legend_label="pontos coletados") + plot(modelo(x),(x,0,3))
Traceback (click to the left of this block for traceback)
...
ValueError: Variable 'x' not foundjmarcellopereiraMon, 04 Jan 2016 12:36:40 -0600http://ask.sagemath.org/question/32057/How to fit data to an arrhenius equationhttp://ask.sagemath.org/question/23690/how-to-fit-data-to-an-arrhenius-equation/Hi,
I'm pretty new to sage and am currently trying it out with cloud.sagemath and sage on ubuntu.
I'm trying to fit some data to an [arrhenius equation](https://en.wikipedia.org/wiki/Arrhenius_equation) of a [continuous stirred tank reactor](https://en.wikipedia.org/wiki/Continuous_stirred-tank_reactor)-model.
So far, I've managed to import data from a .csv-file and convert it into a matrix:
import numpy as np
import csv
R = 8.314462 [J/mol/K]
yield = []
temp = []
t_res = [] #residence time
conc_init = [] #initial concentration
data2 = list(csv.reader(file('manuel2.csv'), delimiter=';'))
m = matrix([[ float(_) for _ in line] for line in data2])
n = np.vstack(m)
##now I'm converting the matrix into single numpy-arrays:
yield = n[:,0]
temp = n[:,1]
t_res = n[:,2]
conc_init = n[:,4]
conc = conc_init - yield/100*conc_init #calculate actual concentrations
from [here](http://www.sagemath.org/doc/reference/numerical/sage/numerical/optimize.html) I tried to use the find_fit function to fit my data to the [arrhenius-equation](https://en.wikipedia.org/wiki/Arrhenius_equation)
var('E_A,A')
model(conc)=conc_init - A*exp(-E_A/(R*temp))*conc*t_res
data=(conc,conc_init,temp,t_res)
fit=find_fit(data,model)
when I finally evaluate I get this error:
> (E_A, k_inf)
Error in lines 36-36
Traceback (most recent call last):
File "/projects/b9085414-cff2-4e5a-9c3b-872f47d41a7c/.sagemathcloud/sage_server.py", line 736, in execute
exec compile(block+'\n', '', 'single') in namespace, locals
File "", line 1, in <module>
File "/usr/local/sage/sage-6.3.beta6/local/lib/python2.7/site-packages/sage/calculus/all.py", line 96, in symbolic_expression
return SR(x)
File "parent.pyx", line 1083, in sage.structure.parent.Parent.__call__ (build/cythonized/sage/structure/parent.c:8902)
File "coerce_maps.pyx", line 95, in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (build/cythonized/sage/structure/coerce_maps.c:4203)
File "coerce_maps.pyx", line 90, in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (build/cythonized/sage/structure/coerce_maps.c:4110)
File "ring.pyx", line 289, in sage.symbolic.ring.SymbolicRing._element_constructor_ (build/cythonized/sage/symbolic/ring.cpp:5332)
TypeError
I actually don't have a clue what that means or how I can get this to work.jonijonesMon, 04 Aug 2014 08:20:33 -0500http://ask.sagemath.org/question/23690/find best fit for implicit equation.http://ask.sagemath.org/question/10588/find-best-fit-for-implicit-equation/Hi,
I have to fit numerical data to an analytic model in the same way that is done by the find_fit command of sage.
The problem is that my model is an implicit function which can't be simplified. It's the solution of a differential equation and it's quite messy.
Any ideas about how could I solve this with sage.ZardozThu, 03 Oct 2013 12:35:34 -0500http://ask.sagemath.org/question/10588/Piecewise curve fitting polynomial datahttp://ask.sagemath.org/question/9989/piecewise-curve-fitting-polynomial-data/Hello all. I am curve fitting time series data using polyfit() and it works well for most of my data sets. I have noticed, however, that some data sets begin hyperbolic and move to exponential so as to best fit to two separate equations. What is simple way to fit my data to two different curve equations using Sage? Is there a good mathematical or programmatic method of determining when a data set is best served by piecewise curve fitting? Currently, I can only determine that empirically once the curve is plotted along with the data points.
NatashaNatashaThu, 04 Apr 2013 11:49:56 -0500http://ask.sagemath.org/question/9989/