MathGroup Archive 2008

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

Search the Archive

Re: Any body can help me solve the equation with piecewise function

On 3/31/08 at 2:04 AM, loveinla at wrote:

>I have a problem to solve, but it seems not easy because of the
>piecewise function involved. I am wondering how we should deal with
>piecewise function when solving an equation or doing optimization.

>To give you an simple example, the piecewise function is f(x)= 3x if
>x<0; f(x)= 0 if x>=0. And I want to solve the equation f(x)+6=0.

>I actually define the piecewise function at first using "Which" and
>then try to use "NSolve" to solve it. However, NSolve doesn't work

>Anybody know how should I solve this kind of problem generally in

How about using Reduce? For example,

In[1]:= f[x_] = Piecewise[{{3 x, x < 0}, {0, x >= 0}}];

In[2]:= Reduce[f[x] + 6 == 0, x]

Out[2]= x == -2

  • Prev by Date: Re: Legend with ListDensityPlot
  • Next by Date: Something very simple.....
  • Previous by thread: Re: Legend with ListDensityPlot
  • Next by thread: Something very simple.....