Mathematica:Having problem with my calculation(numerical)

  • Mathematica
  • Thread starter shafieza_garl
  • Start date
In summary, the conversation discusses a problem with a calculation involving NMinimize and variables x0, x1, x2, and x3. The output keeps showing an error and the user suggests that the problem may be with the Y variable. The conversation also includes a code and its output, which shows different results when small changes are made in the coefficients. Finally, the user suggests spending time learning about approximate and exact mathematics using Mathematica.
  • #1
shafieza_garl
20
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: 579
Last edited:
Physics news on Phys.org
  • #2
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.
 
  • #3
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.
 

1. What is Mathematica and what is it used for?

Mathematica is a software program used for mathematical and scientific calculations. It is a powerful tool that allows users to perform complex mathematical operations, create visualizations, and analyze data.

2. Why am I getting an error message when trying to perform a calculation in Mathematica?

There could be several reasons for an error message in Mathematica. Some common causes include syntax errors, incorrect use of functions, or using undefined variables. It is important to carefully check your code for any mistakes or consult the documentation for proper usage.

3. How can I improve the accuracy of my numerical calculations in Mathematica?

There are a few ways to improve the accuracy of numerical calculations in Mathematica. One method is to increase the working precision, which can be done by using the "WorkingPrecision" option or the SetPrecision function. Another approach is to use high-precision functions, such as N, to perform the calculations.

4. What is the difference between exact and numerical calculations in Mathematica?

Exact calculations in Mathematica use symbolic representation and can provide precise results, while numerical calculations use approximations and are subject to rounding errors. Exact calculations are generally slower but can be more accurate, while numerical calculations are faster but may have a loss of precision.

5. How can I plot my numerical results in Mathematica?

To plot numerical results in Mathematica, you can use the ListPlot or Plot functions. These allow you to visualize your data in various ways, such as line graphs, scatter plots, and histograms. You can also customize the appearance of your plot by adjusting options such as color, axis labels, and plot style.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
795
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • Calculus and Beyond Homework Help
Replies
23
Views
1K
  • Calculus and Beyond Homework Help
Replies
13
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
6
Views
836
  • Precalculus Mathematics Homework Help
Replies
3
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
14
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
2K
  • Precalculus Mathematics Homework Help
Replies
2
Views
967
Back
Top