Message Boards Message Boards

0
|
7823 Views
|
4 Replies
|
5 Total Likes
View groups...
Share
Share this post:

Doesn't want to plot!

Posted 10 years ago
hi guys,
tell me why doesn't it want to plot ?

ClearAll["Global'*"];

k = 8.617332478*10^-5; (*eV K^-1*)

solution = {};
For[T = 250, T <= 280, AppendTo[solution, Solve[2/3*4.6 == Integrate[\[Epsilon]^(1/2)/Exp[(\[Epsilon] - \[Mu][T])/(k*T)],
{\[Epsilon], 0,Infinity}], \[Mu][T]]], T++]
ListPlot[solution]
POSTED BY: Mateusz Tyrk
4 Replies
Posted 10 years ago
I think mathematica does not understand you trig nomenclature, so it is not resolving to the numerical value required by ListPlot.
In[19]:= (Sin^2)[1.]

Out[19]= (Sin^2)[1.]

In[16]:= Sin[1.]^2

Out[16]= 0.708073
POSTED BY: David Keith
Posted 10 years ago
thanks guys.
as far as I've got the previous one solved, I managed to get another problem (similiar though).
Seems like it's almost the same thing, but it doesn't want to plot ;) !!! aaa!!
 ClearAll["Global'*"]
 ClearAll[a, b, \[Alpha], \[Phi], r, odp];
 b = 0.98;
 odp = {};
 a = 1;
 \[Phi] = 30 Degree;
 r = 0.02;
 \[Chi][\[Alpha]_] := -(1/4) a Sin[
      2 \[Alpha]] Sin[\[Phi]] (Cos[\[Phi]] + (Sin^2)[\[Phi]]) r +
   Sqrt[2]/2 a (Cos^2)[\[Alpha]] (Sin^2)[\[Phi]/
     2] (r (Sin^2)[\[Phi]] + (Cos^2)[\[Phi]]) -
   Sqrt[2]/4 a b Cos[\[Phi]] (
     Sin^2)[\[Phi]] (1 - 1/2 (Cos^2)[\[Alpha]]) +
   1/4 a Sin[2 \[Alpha]] Sin[2 \[Phi]] (Sin^2)[\[Phi]/2];
For[\[Alpha] = 0, \[Alpha] <= 2 \[Pi],
  AppendTo[odp, {\[Alpha], \[Chi][\[Alpha]]}], \[Alpha] = \[Alpha] +
    1 Degree];

ListPlot[odp]

what's wrong with that now?
POSTED BY: Mateusz Tyrk
Posted 10 years ago
I post this answer to illustrate alternatives to  For loops; As David Keith has answered:
  • the object returned by Solve is a list of rules
  • in this parrticular case, \mu (T) can be simplified
  • in the following I have avoided capital letter variables (to avoid potential conflicts from internal symbols) and I have just eliminated special characters for simplicity
k = 8.617332478*10^-5;
fun[temp_] :=  m /. First[Quiet@Solve[2/3*4.6 ==Integrate[eps^(1/2)/Exp[(eps - m)/(k*temp)], {eps, 0, Infinity}], m]]
ListPlot[Table[{t, fun[t]}, {t, 250, 280, 1}]]
Visualizing:

or
Plot[fun[t], {t, 250, 280}]
(a little slow on my machine):

The same effect could have been played by simply adding Joined->True to the ListPlot.
POSTED BY: Mark Dooris
Posted 10 years ago
In your code, Solve produces a rule, not a value. In the code below I modified this to extract the rule, apply it to obtain a value, and append to solution the pair {T,value}, so Listplot would have values for the independent variable.

Two side notes:
  mu(T) is a symbol, the bracket-T-bracket is not necessary.
  Also, it is best to use symbol names that begin with small case because Mathematica built-in symbols begin with capitals. T is actually OK, but as an example, E is the natural log base.

Best regards,
David
 ClearAll["Global'*"];
 k = 8.617332478*10^-5;(*eV K^-1*)
 
 solution = {};
 
 For[T = 250, T <= 280,
   AppendTo[solution, {T, \[Mu][T] /.
      Solve[2/3*4.6 ==
         Integrate[\[Epsilon]^(1/2)/
          Exp[(\[Epsilon] - \[Mu][T])/(k*T)], {\[Epsilon], 0,
          Infinity}], \[Mu][T]][[1, 1]]}
   ],
  T++];

ListPlot[solution]

POSTED BY: David Keith
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract