# deeve: Event Detection in ODE solution In pracma: Practical Numerical Math Functions

## Description

Detect events in solutions of a differential equation.

## Usage

 `1` ```deeve(x, y, yv = 0, idx = NULL) ```

## Arguments

 `x` vector of (time) points at which the differential equation has been solved. `y` values of the function(s) that have been computed for the given (time) points. `yv` point or numeric vector at which the solution is wanted. `idx` index of functions whose vales shall be returned.

## Details

Determines when (in `x` coordinates) the `idx`-th solution function will take on the value `yv`.

The interpolation is linear for the moment. For points outside the `x` interval `NA` is returned.

## Value

A (time) point `x0` at which the event happens.

## Note

The interpolation is linear only for the moment.

`deval`

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11``` ```## Damped pendulum: y'' = -0.3 y' - sin(y) # y1 = y, y2 = y': y1' = y2, y2' = -0.3*y2 - sin(y1) f <- function(t, y) { dy1 <- y[2] dy2 <- -0.3*y[2] - sin(y[1]) return(c(dy1, dy2)) } sol <- rk4sys(f, 0, 10, c(pi/2, 0), 100) deeve(sol\$x, sol\$y[,1]) # y1 = 0 : elongation in [sec] # [1] 2.073507 5.414753 8.650250 # matplot(sol\$x, sol\$y); grid() ```

### Example output

```[1] 2.073507 5.414753 8.650250
```

pracma documentation built on Jan. 30, 2018, 3:01 a.m.