# [R] integrate and quadratic forms

rdporto1 rdporto1 at terra.com.br
Fri Jan 19 17:30:47 CET 2007

```Thanks Jim. But a narrower problem still remains.
Please, look at this new code:

lambda=c(.6,.3)
integral = function(u) {
theta = (atan(.6*u) + atan(.3*u))/2 - .1*u/2
rho = (1+.6^2*u^2)^(1/4) * (1+.3^2*u^2)^(1/4)
integrand = sin(theta)/(u*rho)
}

> integrate(integral,0,Inf)\$value
 1.222688

If I replace
theta = sum(atan(lambda*u))/2 - .1*u/2
I get
> integrate(integral,0,Inf)\$value
 1.517134

It seems there is a problem between the sum() and integrate()
functions.

Is there a way to solve this problem?

Rogerio.

---------- Part of the Original Message -----------

> They do give the same answer, unfortunately the examples you sent  were not
> the same.  Integral2 was missing a 'sin'.  So I would assume there might be
> something else wrong with your functions.  You might want to try breaking it
> down into smaller steps so you can see what you are doing.  It definitely is
> hard to read in both cases.
>
> Jim Holtman
> Cincinnati, OH
> +1 513 646 9390
>
> What is the problem you are trying to solve?

```