MathGroup Archive 2005

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

Search the Archive

Re: solve for a squared variable


Ruth Lazkoz wrote:
> Hi everyone,
> 
> Why does 
> 
> Solve[x^2 + y == 1, x^2] 
> 
> give and error message? How can I solve for x^2?
> 
> Thanks,
> 
> Ruth 
> 
Hi Ruth,

Since the error message is

_General::ivar : x^2 is not a valid variable. More..._

so we must do a change of variable as in the following example:

In[1]:=
expr = x^2 + y == 1

Out[1]=
x^2 + y == 1

In[2]:=
Solve[expr /. x^2 -> X, X]

Out[2]=
{{X -> 1 - y}}

In[3]:=
x -> Sqrt[X /. %[[1]]]

Out[3]=
x -> Sqrt[1 - y]

In[4]:=
expr /. %

Out[4]=
True

Regards,
/J.M.


  • Prev by Date: Integration problem
  • Next by Date: Re: Mathematica: access serial port?
  • Previous by thread: Re: solve for a squared variable
  • Next by thread: Re: Why this function does not return a single value