Hi David,

On Thu, Nov 4, 2010 at 12:59 AM, David Kirkby <[email protected]> wrote:
> It there anyway to fit a curve to some data, but force the fit to go
> through the point (0,0)?

The function find_fit() should produce a curve that goes through your
data points, even if you have the point (0,0). For example:

sage: version()
'Sage Version 4.6, Release Date: 2010-10-30'
sage: X = [0, 10, 20, 30, 40]
sage: Y = [0, 50, 100, 149, 195]
sage: var("a, b, c");
sage: f(x) = a*x^2 + b*x + c
sage: find_fit(zip(X,Y), f)
[a == -0.0064285714307663611, b == 5.1471428571518949, c ==
-0.28571428571698987]
sage: f = -0.0064285714307663611*x^2 + 5.1471428571518949*x -
0.28571428571698987
sage: data_plot = scatter_plot(zip(X,Y))
sage: model_plot = plot(f, (x,-10,100))
sage: show(data_plot + model_plot)

Of course, I may have misread what you were asking.

-- 
Regards
Minh Van Nguyen

-- 
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to