Any body can help me solve the equation with piecewise function

• To: mathgroup at smc.vnet.net
• Subject: [mg87082] Any body can help me solve the equation with piecewise function
• From: "loveinla at gmail.com" <loveinla at gmail.com>
• Date: Mon, 31 Mar 2008 02:04:52 -0500 (EST)

```Hi,

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 through.

Anybody know how should I solve this kind of problem generally in Mathematica? Of course, for this simple example, we can divide it into two cases and then compare the solutions after solving the two cases. Yet my problem is more general and involves more than 3 piecewise functions, thus a lot of possible cases to deal with. So any command or function to deal with this kind of general problem?