MathGroup Archive 2012

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Solve::ivar: 0 is not a valid variable.

  • To: mathgroup at smc.vnet.net
  • Subject: [mg129085] Re: Solve::ivar: 0 is not a valid variable.
  • From: daniel.lichtblau0 at gmail.com
  • Date: Fri, 14 Dec 2012 02:59:01 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-newout@smc.vnet.net
  • Delivered-to: mathgroup-newsend@smc.vnet.net
  • References: <kac5t6$sna$1@smc.vnet.net>

On Thursday, December 13, 2012 3:07:50 AM UTC-6, Ding Yuan wrote:
> Hello,
> 
> 
> 
> I am fresh in Mathematica. Can anyone explain what is happening in this code?
> 
> 
> 
> Cheers
> 
> 
> 
> Ding 
> 
> 
> 
> 
> 
> ------------
> 
> gamma = 1.5; m = 0;
> 
> C0 = 1.; CA = 2;
> 
> CF = (C0^2 + CA^2)^0.5; CT = (C0 CA)/CF;
> 
> Ce = 0.5; CAe = 5 ;
> 
> CFe = (Ce^2 + CAe^2)^0.5; CTe = (Ce CAe)/CFe;
> 
> delta = (2 C0^2 + gamma CA^2)/(2 Ce^2 + gamma CAe^2);
> 
> kza = 1.;
> 
> k0[x_] := (-(((x^2 - C0^2) (x^2 - CA^2) )/((C0^2 + CA^2) (x^2 - 
> 
>       CT^2))))^0.5
> 
> ke[x_] := (-(((x^2 - Ce^2) (x^2 - CAe^2))/((Ce^2 + CAe^2) (x^2 - 
> 
>       CTe^2))))^0.5
> 
> NSolve[(delta (x^2 - CAe^2) k0[x] BesselI[m + 1, k0[x] kza])/
> 
>    BesselI[m, 
> 
>     k0[x] kza] + ((x^2 - CA^2) ke[x] BesselK[m + 1, ke[x] kza])/
> 
>    BesselK[m, ke[x] kza] == 0, {x, 0, 10}, Reals]
> 
> 
> 
> NSolve::ivar: 0 is not a valid variable. >>
> 
> NSolve[(0.0941502 (-25 + 
> 
>       x^2) (-(((-4 + x^2) (-1. + x^2))/(-0.8 + x^2)))^0.5 BesselI[1, 
> 
>      0.447214 (-(((-4 + x^2) (-1. + x^2))/(-0.8 + x^2)))^0.5])/
> 
>    BesselI[0, 
> 
>     0.447214 (-(((-4 + x^2) (-1. + x^2))/(-0.8 + x^2)))^0.5] + (
> 
>    0.199007 (-4 + 
> 
>       x^2) (-(((-25 + x^2) (-0.25 + x^2))/(-0.247525 + 
> 
>        x^2)))^0.5 BesselK[1, 
> 
>      0.199007 (-(((-25 + x^2) (-0.25 + x^2))/(-0.247525 + 
> 
>          x^2)))^0.5])/
> 
>    BesselK[0, 
> 
>     0.199007 (-(((-25 + x^2) (-0.25 + x^2))/(-0.247525 + 
> 
>         x^2)))^0.5] == 0, {x, 0, 10}, Reals]

(1) Look at the documentation bfor NSolve. It does not support ranges for variables in the way you had thought. Moreover the error message is quite informative here-- it is telling you that 0 was being passed as a "variable".

(2) it can be done as below, adding an explicit inequality to demarcate the range of the variable. This works, albeit it takes a bit of time (might have been a minute or so).

NSolve[{(delta (x^2 - CAe^2) k0[x] BesselI[m + 1, k0[x] kza])/
     BesselI[m, 
      k0[x] kza] + ((x^2 - CA^2) ke[x] BesselK[m + 1, ke[x] kza])/
     BesselK[m, ke[x] kza] == 0, 0 <= x <= 10}, x, Reals]

During evaluation of In[156]:= Solve::ratnz: Solve was unable to solve the system with inexact coefficients. The answer was obtained by solving a corresponding exact system and numericizing the result. >>

Out[165]= {{x -> 0.898603}, {x -> 0.928239}}

(3) See (1). One should always check docs before sending up a flare to a mailing list.

Daniel Lichtblau
Wolfram Research



  • Prev by Date: Re: Mathematica 9 does not read mathematica 8 ".mx" files
  • Next by Date: Re: Solve::ivar: 0 is not a valid variable.
  • Previous by thread: Re: Solve::ivar: 0 is not a valid variable.
  • Next by thread: Strange behaviour of Solve