-1
$\begingroup$

I have this problem: calculate the integral of:

-1+Sqrt[2*d+1]

with d being a distance of two points in a 60$\times$60 box (inside or on the boundaries).

I know nothing of Mathematica.

I realize who to define functions with two variables and then calculate the integral in a specific interval for each variable (in this case [0,60]). But I do not know how to define a function with two vectors and then calculate the integral giving interval for each vector.

Well instead of using two vectors I can use 4 variables. The function seams to be defined correctly, but when I Integrate I don't get a result.

f[x_, y_, z_, w_] := Sqrt[(x - y)^2 + (z - w)^2]
f[1, 2, 3, 4]

(* Sqrt[2] *)

h[x_, y_, z_, w_] := -1 + Sqrt[1 + 2*f[x, y, z, w]]
h[1, 2, 3, 4]

(* -1 + Sqrt[1 + 2 Sqrt[2]] *)

Integrate[
h[x, y, z, w], {x, 0, 60}, {y, 0, 60}, {z, 0, 60}, {w, 0, 60}]

Any help will be greatly appreciated. I am stuck.

Thanks in advance John

$\endgroup$
2
  • $\begingroup$ Welcome to Mathematica.SE! Please provide a minimal example of what you tried so far, using proper formatting (note the "help"-menu on the top of this site). Did you already take a look at the Mathematica online documentation (at all)? $\endgroup$
    – Jinxed
    Apr 9 '15 at 18:35
  • 1
    $\begingroup$ take a stab at writing some mathematica code. I can't tell where you are stuck, and the problem isn't clearly posed. $\endgroup$
    – george2079
    Apr 9 '15 at 18:35
3
$\begingroup$

I think this is what you're seeking:

$\int _0^{60}\int _0^{60}\int _0^{60}\int _0^{60}\left(-1+\sqrt{2 \sqrt{(\text{ax}-\text{bx})^2+(\text{ay}-\text{by})^2}+1}\right) d\text{by}\ d\text{bx}\ d\text{ay}\ d\text{ax}$

NIntegrate[
  -1 + Sqrt[2 Sqrt[(ax - bx)^2 + (ay - by)^2] + 1], 
  {ax, 0, 60}, {ay, 0, 60}, {bx, 0, 60}, {by, 0, 60}] // Quiet

(* $8.70647\times 10^7$ *)

$\endgroup$
9
  • $\begingroup$ However, the error estimate of this integral is quite huge... $\endgroup$
    – Jinxed
    Apr 9 '15 at 18:58
  • $\begingroup$ @Jinxed Huge... and yet correct. I suspect you've mis-stated your problem. Please revisit your problem carefully. Perhaps you want to compute an average... but nobody can tell from your question. $\endgroup$ Apr 9 '15 at 19:01
  • $\begingroup$ Me? Are you sure? $\endgroup$
    – Jinxed
    Apr 9 '15 at 19:05
  • 1
    $\begingroup$ I suppose you meant the OP, not me. $\endgroup$
    – Jinxed
    Apr 9 '15 at 19:17
  • 2
    $\begingroup$ @Jinxed David has been exercising this for a while mathematica.stackexchange.com/q/79334/193 :) $\endgroup$ Apr 9 '15 at 19:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.