[Haskell-beginners] Antiderivative (indefinite integral)?
Twan van Laarhoven
twanvl at gmail.com
Mon Jan 21 16:30:26 CET 2013
If you don't care about efficiency, you can define
antideriv :: (Int -> Int) -> Int -> Int
antideriv f x
| x >= 0 = sum [ f y | y <- [0..x-1] ]
| x < 0 = - sum [ f y | y <- [x..-1] ]
which has the property that
antideriv f x1 - antideriv f x0 == sum [f x | x <- [x0..x1-1]]
Twan
On 19/01/13 19:55, Martin Drautzburg wrote:
> Hello all,
>
> not strictly a Haskell question, but anyways ...
>
> is it possible to compute the antiderivative of a function f::Int->Int ?
>
> I understand that you can compute the definite integral by simply summing up
> the values of f within a given interval.
>
> My first guess would be: no this is not possible. The antiderivative F of a
> function f::Int->Int needs to have the property that F(b) - F(a) must be the
> sum of f within [a,b]. To do this I must know all values withib [a,b]. But at
> the time I compute the antiderivative I do not know this interval yet.
>
> What is striking me is that in calculus I can often symbolically compute the
> antiderivative and I get a simple function, and I can get the value of F for a
> given x and I get a simple number. Why is that so?
>
More information about the Beginners
mailing list