## Calculating integral but weird result :S

### Serhat (view profile)

on 30 Jan 2013
Accepted Answer by Teja Muppirala

### Teja Muppirala (view profile)

Hi,

I am trying to calculate this integral.

sigmaZ= -0.1464*eye(4);

f = @(x)(arrayfun(@(x)(1./(det(sigmaZ./sin(x).^2 + eye(4)))),x))

but it gives this result 3e+10. It must not have been that high. Is my integral wrong?

Thanks:)

## Products

No products are associated with this question.

### Teja Muppirala (view profile)

Answer by Teja Muppirala

### Teja Muppirala (view profile)

on 30 Jan 2013

When sigmaZ is negative, the integrand blows up around x = 0.3 and x = 2.7 and you have a singularity which you cannot integrate.

For example, just plot it:

```sigmaZ= -0.1464*eye(4);
f = @(x)(arrayfun(@(x)(1./(det(sigmaZ./sin(x).^2 + eye(4)))),x))
ezplot(f)
```

When sigmaZ is positive, the integrand is always finite for x in [0 pi] and so you don't get any problem.

Serhat

### Serhat (view profile)

on 30 Jan 2013

Hımm, Isee. Then the problem is sigmaZ. Thanks for help:)

### Jan Simon (view profile)

Answer by Jan Simon

### Jan Simon (view profile)

on 30 Jan 2013

Is there any chance that we can guess what you want to calculate?

Jan Simon

### Jan Simon (view profile)

on 30 Jan 2013

@Serhat: All you have shown us is the code and you explain, that it could be wrong. But we cannot suggest an improvement, when you do not explain, which equation this code should solve. And if this is still not clear, a simplified version:

` I have c = a + b, where a is 2 and b is 3. I get the result 5, but I want 6. Where is the error?`

Without a magic crystal ball it is impossible to find an answer.

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi test

### Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.