[Haskell-beginners] numerical integration over lists
Thomas Engel
thomas.engel1 at gmx.net
Sun Feb 5 09:19:02 CET 2012
Hello,
I have two list (one with x values, the other with y values)
What I want to do is a numercial integration according the following formula:
Result x2 = Result x1 + ((y(x1) + y(x2))/2) * (x2 -x1)
and put the result in another list.
below my first try:
integriereListe::(a)->(a)->(a)
integriereListe [][] = [0.0]
integriereListe (x:xs) (y:ys) = ((y - y2) /2) * (x2 -x)
where
x2 = head xs
y2 = head ys
but I got the failure
Couldn't match type `[t0]' with `[[t0]]'
In the pattern: y : ys
In an equation for `integriereListe':
integriereListe (x : xs) (y : ys)
= ((y - y2) / 2) * (x2 - x)
where
x2 = head xs
y2 = head ys
another problem is how get the result x1 (see above)
any hints are welcome.
Thomas
More information about the Beginners
mailing list