0
$\begingroup$
Clear[cn, hy, v, n0];

cn[q1_?NumericQ, q2_?NumericQ, n0_?NumericQ,Ut_?NumericQ] := ((Ut*n0)/(1 - Cos[2*Pi*q1] - Cos[2*Pi*q2])); 
hy[q1_?NumericQ, q2_?NumericQ, n0_?NumericQ, Ut_?NumericQ] :=  0.25*((1 + cn[q1, q2, n0])^(-1/2) + (1 - cn[q1, q2, n0])^(1/2) - 2);
v[n0_?NumericQ, Ut_?NumericQ] := n0 + NIntegrate[hy[q1, q2, n0, Ut], {q1,-0.5, 0.5}, {q2, -0.5, 0.5}] - 1;

sols = Solve[v[n0, Ut] == 0, n0]
Plot[Evaluate[n0 /. sols], {Ut, 0, 20}, PlotRange ->Full]

I am unable to plot(shows nothing after running). Is there any better way to get the plot? Any help is appreciated. Thanks.

$\endgroup$
1
  • 1
    $\begingroup$ I recommend that you check your equations. cn is defined with four arguments; however, both calls to cn in the definition of hy have only three arguments. $\endgroup$
    – Bob Hanlon
    Commented May 8, 2015 at 1:13

1 Answer 1

1
$\begingroup$

Assuming we can rule out problems relating to multiple statements in the same cell (so that the Plot is being "multipled" by the results of the Solve), you

In[3]:= sols = Solve[v[n0, Ut] == 0, n0] 

During evaluation of In[3]:= Solve::ifun: Inverse functions are being used by Solve, 
so some solutions may not be found; use Reduce for complete solution information. >>

Out[3]= {{n0 -> InverseFunction[v, 1, 2][0, Ut]}}

This is what you're trying to plot. It's not a numerical function, which is why you are getting no line on your plot.

Tip: It's good practice to look at an expression before trying to plot it.

Even Reduce doesn't work:

In[22]:= Reduce[v[n0, Ut] == 0, n0] 

During evaluation of In[22]:= Reduce::nsmet: 
This system cannot be solved with the methods available to Reduce. >>

Out[22]= Reduce[v[n0, Ut] == 0, n0]

Neither does this, which demonstrates that the input you are giving to Plot simply isn't numerical.

In[16]:= newf[u_] := First@Evaluate[n0 /. sols] /. Ut -> u

In[20]:= N@newf[0.1]

Out[20]= InverseFunction[v, 1, 2][0., 0.1]

The solution to your problem is to respecify your equations (if indeed they can be) into a format that can be expressed as a numerical quantity for given values of the parameters. Brute-force use of Solve won't do it.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.