Ask Your Question
0

how to find root of a spline

asked 2012-09-18 04:41:52 +0200

wizulis gravatar image

Basicaly the title says it: I have data points for which i need to find the x value where y is a known value. I tried it like this, but it seems that it should be done differently:

from sage.gsl.all import spline
data=[[0,1],[1,2],[2,2.2],[3,2.4],[4,0.4],[5,0.1],[6,-0.5]]
func=spline(data)
x=var('x')
find_root(func(x),0,6)
..[Error message with main idea - TypeError: unable to simplify to float approximation]
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2012-09-18 05:48:58 +0200

achrzesz gravatar image
sage: find_root(func,0,6)   
5.3157137464283455
sage: plot(func,[x,0,6])
edit flag offensive delete link more

Comments

Just to elaborate, when you did `func(x)`, you wanted Sage to evaluate the spline at the symbolic variable `x`. But our splines aren't (yet) symbolic, so it raised an error because it wanted an actual numeric input.

kcrisman gravatar imagekcrisman ( 2012-09-18 09:27:06 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2012-09-18 04:41:52 +0200

Seen: 543 times

Last updated: Sep 18 '12