Mathematica:Having problem with my calculation(numerical)

  • Context: Mathematica 
  • Thread starter Thread starter shafieza_garl
  • Start date Start date
Click For Summary
SUMMARY

The forum discussion addresses a calculation issue encountered while using Mathematica's NMinimize function. The user received an error indicating that the function value is not a number due to missing variable definitions. Specifically, the user must define all variables, including Y, for NMinimize to function correctly. The discussion highlights the sensitivity of results to small changes in coefficients and recommends further study of machine precision mathematics in Mathematica.

PREREQUISITES
  • Understanding of Mathematica syntax and functions
  • Familiarity with NMinimize function in Mathematica
  • Knowledge of numerical optimization techniques
  • Concept of machine precision in numerical calculations
NEXT STEPS
  • Study the documentation for Mathematica's NMinimize function
  • Learn about machine precision and its implications in Mathematica
  • Explore the use of Integrate function in Mathematica for numerical calculations
  • Investigate the effects of coefficient changes on optimization results
USEFUL FOR

Mathematica users, mathematicians, data scientists, and anyone involved in numerical optimization and precision mathematics.

shafieza_garl
Messages
20
Reaction score
0
What wrong with my calculation.the problem is from the attachment.
It keeps saying

NMinimize::nnum:The function value ...is not a number at {x1,x2}=...

given x0=0 and x3=5
 

Attachments

  • Untitled-2.jpg
    Untitled-2.jpg
    21.3 KB · Views: 640
Last edited:
Physics news on Phys.org
Did you tell it what Y (capital Y) is? If so, you didn't tell us. NMinimize needs to know all of the values, it can't deal with variables.
 
In[1]:=x0=0;x3=5;
F[x_,y_]:=0.25`(4044.44444444445`-66.66666666666667`x+E^(-0.015x+0.015y)(-4044.44444444445`+66.66666666666667`y))^2;
H[x_,y_]:=Integrate[0.25`(E^(-0.015`t)(E^(0.015`t)(4044.44444444445`-66.66666666666667`t)+E^(0.015`y)(-4044.44444444445`+66.66666666666667`y)))^2,{t,x,y}];
NMinimize[{27+3*(F[x0,x1]+F[x1,x2]+F[x2,x3])+0.2*(H[x0,x1]+H[x1,x2]+H[x2,x3]),x0≤x1&&x1≤x2&&x2≤x3},{x1,x2}]

Out[4]={4.457054464608864`*10^8, {x1 -> 0.06690213249753463`, x2 -> 1.1629357790698616`}}

If I did not make an error typing this all back in again then I cannot explain what your problem is. But I believe you have larger problems than this. Quit kernel and restart

In[1]:=a=1/4;b=4044+4/9;c=66+2/3;d=15/1000;x0=0;x3=5;
F[x_,y_]:=a*(b-c*x+E^(-d*x+d*y)*(-b+c*y))^2;
H[x_,y_]:=Integrate[a*(E^(-d*t)*(E^(d*t)*(b-c*t)+ E^(a*y)*(-b+c*y)))^2,{t,x,y}];
NMinimize[{27+3*(F[x0,x1]+F[x1,x2]+F[x2,x3])+ 1/5*(H[x0,x1]+H[x1,x2]+H[x2,x3]),x0≤x1&&x1≤x2&&x2≤x3},{x1,x2}]

Out[4]={7.388367735069655`*10^6, {x1 -> 2.4650125379662637`, x2 -> 3.9306108222644514`}}

So very tiny changes in your coefficients give very different results.

I would suggest you spend a few days reading about the details of approximate and exact and machine precision mathematics as provided by Mathematica. Much of that is probably not what you would expect it to be.
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 4 ·
Replies
4
Views
1K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 3 ·
Replies
3
Views
3K