Message Boards Message Boards

0
|
2667 Views
|
1 Reply
|
2 Total Likes
View groups...
Share
Share this post:

Syntax for obtaining a list of function values

Posted 10 years ago

"Suppose we have a given data set {(x(i),y(i)), i= 0 to N } and

expressions a(i)=(x(i)-x(i-1))/(x(N)-x(0))

         b(i)=(y(i)-y(i-1))/(x(N)-x(0)) -0.5* (y(N)-y(0))/(x(N)-x(0))

How to calculate a(i),b(i) for i=1 to N using Mathematica?"

You can take N=2

POSTED BY: nasim.iitm
Posted 10 years ago

In Mathematica N is the name of a Mathematica function. Using that for a variable name will cause you great problems. Use n instead.

Subscripts in Mathematica are from 1..n+1, not from 0..n. Using 0 as a subscript will cause you great problems.

Study the documentation for RandomReal until you can write a single line of code which will create an example dataset {{xi,yi}}.

Study the documentation for Part until you can write a single line of code which will extract all the {xi} from your example dataset.

Study the documentation for Partition until you can write a single line of code which will extract all the {xi,xi-1} pairs from all your {xi}.

Study the tutorial for DefiningFunctions until you can write a single line function that will do your calculation given a single pair.

Study the documentation for Map until you can write a single line of code that will do the calculation on all pairs.

Use all you have learned to repeat this for your {yi}

Make and keep careful notes about all you have learned doing this because you will use these again and again.

I apologize for the lack of formatting of this, after six tries I simply gave up. If there was a NeverMindJustDeleteMyPost button I would have used it.

POSTED BY: Bill Simpson
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract