0
$\begingroup$

I am trying to create a function that takes in an input $\mu$ and place that input into the replace rule for a numerical integration, as seen in the code below:

Clear["Global`*"]
x = r/R;
Subscript[U, T] = \[CapitalOmega] R (x + \[Mu] Sin[\[Psi]]);
Subscript[U, R] = \[CapitalOmega] R \[Mu] Cos[\[Psi]];
U = Sqrt[Subscript[U, T]^2 + Subscript[U, R]^2];
NIntegrate[
   NIntegrate[
    1/2 \[Rho] U^3 Subscript[C, Subscript[d, 0]] /. #, {r, 0, 
      R} /. #], {\[Psi], 0, 2 Pi} /. #] & @{R -> 1, \[CapitalOmega] ->
    1, Subscript[C, Subscript[d, 0]] -> 1, \[Rho] -> 1, \[Mu] -> 1}
Subscript[P, 0][\[Mu]_] = 
 NIntegrate[
    NIntegrate[
     1/2 \[Rho] U^3 Subscript[C, Subscript[d, 0]] /. #, {r, 0, 
       R} /. #], {\[Psi], 0, 2 Pi} /. #] & @{R -> 
    1, \[CapitalOmega] -> 1, 
   Subscript[C, Subscript[d, 0]] -> 1, \[Rho] -> 1, \[Mu] -> \[Mu]}
Subscript[P, 0][1]

Running this code has the following result:

As you can see, simply subbing in for $\mu$ using $\mu \rightarrow 1$ works fine, but it does not work when attempted as a function. How would I set up this function to correctly send the input to the replace rule?

$\endgroup$

1 Answer 1

1
$\begingroup$
Clear["Global`*"]
x = r/R;
Subscript[U, T] = Ω R (x + μ Sin[ψ]);
Subscript[U, R] = Ω R μ Cos[ψ];
U = Sqrt[Subscript[U, T]^2 + Subscript[U, R]^2];

Subscript[P, 0][mu_] := 
 NIntegrate @@
  ({1/2 ρ U^3 Subscript[C, 
       Subscript[d, 0]], {ψ, 0, 2 Pi}, {r, 0, R}} /.
    {R -> 1, Ω -> 1, 
     Subscript[C, Subscript[d, 0]] -> 1, ρ -> 1, μ -> mu})

Subscript[P, 0][1]

(* 5.58815 *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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