Message Boards Message Boards

4 Replies
5 Total Likes
View groups...
Share this post:

Doesn't want to plot!

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


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++]
POSTED BY: Mateusz Tyrk
4 Replies
Posted 11 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}]]

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 11 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,
 k = 8.617332478*10^-5;(*eV K^-1*)
 solution = {};
 For[T = 250, T <= 280,
   AppendTo[solution, {T, \[Mu][T] /.
      Solve[2/3*4.6 ==
          Exp[(\[Epsilon] - \[Mu][T])/(k*T)], {\[Epsilon], 0,
          Infinity}], \[Mu][T]][[1, 1]]}


POSTED BY: David Keith
Posted 11 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[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];


what's wrong with that now?
POSTED BY: Mateusz Tyrk
Posted 11 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
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract