Loading [MathJax]/jax/output/HTML-CSS/jax.js

First time here? Check out the FAQ!

Ask Your Question
1

How to define finite difference approximation for first order derivative

asked 9 years ago

Orange gravatar image

updated 2 years ago

FrédéricC gravatar image

I need to define y1(k)=yk+1yk12h

in sage so that sage can differ between symbolic yk+1 and yk.

Would somebody please help?

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
0

answered 9 years ago

tmonteil gravatar image

The question is not clear to me, why not simply do:

sage: Y = [1,2,4,3,7,2,1]
sage: h = 0.1
sage: [(Y[k+1]-Y[k-1])/h for k in  range(1,len(Y)-1)]
[30.0000000000000,
 10.0000000000000,
 30.0000000000000,
 -10.0000000000000,
 -60.0000000000000]
Preview: (hide)
link

Comments

yk+1 and yk needs to remain unknown till the formation of equation, so that they can act as variables in the linear system. My interest is to automate the finite difference method in sage. Should I need to define some new data structure. Thanks for responding though!!!

Orange gravatar imageOrange ( 9 years ago )

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: 9 years ago

Seen: 444 times

Last updated: Jan 26 '16