• Support PF! Buy your school textbooks, materials and every day products Here!

Mathematica returns non-numerical integrand while minimizing

  • #1

Homework Statement


I need to minimize the function Etrial[a]
trial[x_] := E^(-a*x^2)
Etrial[a_] :=
NIntegrate[1/2*D[trial[x], x]^2 + x^4*trial[x]^2, {x, -\[Infinity], \[Infinity]}]/
NIntegrate[trial[x]^2, {x, -\[Infinity], \[Infinity]}]


Homework Equations





The Attempt at a Solution


I have used NMinimize[Etrial[a],a] and Minimize[Etrial[a],a], as well as FindMiminum[Etrial[a],{a,.5}], since when I plot it, the minimum is pretty obviously around .7, so I arbitrarily chose .5 as a close starting point.
 

Answers and Replies

  • #2
vela
Staff Emeritus
Science Advisor
Homework Helper
Education Advisor
14,620
1,254
Use Integrate instead of NIntegrate. Also, you can actually do the integrals and write the expressions down in closed form. If you define Etrial using those results, it'll be a lot faster since Mathematica won't have to repeatedly perform the integrations.
 
  • #3
I ended up just writing a separate loop that found the minimum. I discovered if I had written my trial function as a function of both x and a, then used partial derivatives, Mathematica can handle that easier. Thanks anyway though!
 

Related Threads on Mathematica returns non-numerical integrand while minimizing

Replies
7
Views
5K
  • Last Post
Replies
3
Views
1K
  • Last Post
Replies
2
Views
3K
  • Last Post
Replies
6
Views
3K
  • Last Post
Replies
1
Views
2K
  • Last Post
Replies
1
Views
2K
  • Last Post
Replies
1
Views
3K
  • Last Post
Replies
7
Views
3K
  • Last Post
Replies
1
Views
545
  • Last Post
Replies
11
Views
2K
Top