2

I'm very new to mathematica (I just started using it today), I was wondering if someone could explain to me what is wrong with the following piece of code:

NIntegrate[A*(eta^3)*(Exp[-3 N]/H)*gamma, {N, 0, 60}]

eta = 3.21+Erfi[Sqrt[N + 1/2]] - Erfi[Sqrt[1/2]] H = Sqrt[1 + (2*N)] and gamma = e^K for some unknown variable K

A, eta, H, and gamma (eta, gamma and H are all functions of N) have all been defined previously. eta contains the Erfi function, and mathematica doesn't seem to beable to solve this analytically, so i used the NIntegrate function instead.

However i get the following errors:

1: Nonatomic expression expected at position 1 in Append[NIntegrateStrategiesDumpprepOption,Method->GlobalAdaptive].

2: Append called with 3 arguments; 1 or 2 arguments are expected.

3: NIntegrate: Append[NIntegrateSymbolicPreprocessing,NIntegrateStrategiesDump`prepOption,Method->GlobalAdaptive] is not a valid specification of an integration strategy or rule.

I was wondering if someone could explain to me why this doesn't work?

thanks.

Jason Ran
  • 21
  • 3

1 Answers1

2
Clear["Global`*"]

User-defined names should not start with capital letters to avoid potential conflicts with built-in names. For example,

?N

enter image description here

eta[n_] = 321/100 + Erfi[Sqrt[n + 1/2]] - Erfi[Sqrt[1/2]];
h[n_] = Sqrt[2 n + 1];

A numeric technique such as NIntegrate cannot evaluate with any undefined values (e.g, a, gamma). You must assign numeric values prior to calling NIntegrate

int[a_?NumericQ, gamma_?NumericQ] := 
 NIntegrate[a*(eta[n]^3)*(Exp[-3 n]/h[n])*gamma, {n, 0, 60}]

For a bounded range the min and max values are

#[{int[a, gamma], -2 <= a <= 2, -2 <= gamma <= 2}, {a, gamma}] & /@ 
   {NMinimize, NMaximize}

(* {{-56.1441, {a -> -2., gamma -> 2.}}, {56.1441, {a -> 2., gamma -> 2.}}} *)

Plotting over a range of values

Plot3D[int[a, gamma], {a, -2, 2}, {gamma, -2, 2},
 AxesLabel -> (Style[#, 14, Bold] & /@
    {"a", "gamma", "int"})]

enter image description here

Bob Hanlon
  • 157,611
  • 7
  • 77
  • 198