       Re: Want to 'Solve' a piecewise equation for a common term

• To: mathgroup at smc.vnet.net
• Subject: [mg79778] Re: Want to 'Solve' a piecewise equation for a common term
• From: dimitris <dimmechan at yahoo.com>
• Date: Sat, 4 Aug 2007 05:53:16 -0400 (EDT)
• References: <f8v16h\$d96\$1@smc.vnet.net>

```On 3    , 13:48, "misno... at gmail.com" <misno... at gmail.com> wrote:
> I've been battling to try to get a solution to my equation, but it
> requires solving of a piecewise function, which I cannot work out how
> to do. Say I have a piecewise function of the form
>
> temp = Piecewise[{
>      { 2*N*x, x < 0},
>      { N*x,    x >= 0}
>
> }]
>
> I want to either solve this via
> Solve[1==temp, N]
> and either get, with the inequalities,
>
> N -> Piecewise[{
>     {1/(2*x), x < 0},
>     {1/x, x >= 0}
>
> }]
>
> or just get mathematica to realise that there is a common term - N,
> and factor it out to, say,
> N * Piecewise[{
>      {2*x, x < 0},
>      {x, x >= 0}}]
>
> from where solve can handle it perfectly well.
>
> Is this type of operation possible, or am I stuck editing them by hand?

Do not use symbols that already are used as built in symbols.

In:=
Information[N]

>From In:=
"N[expr] gives the numerical value of expr. N[expr, n] attempts to
give a result with n-digit precision."

>From In:=
Attributes[N] = {Protected}

N /: Default[N, 2] := {MachinePrecision, Infinity}

In:=
temp = Piecewise[{{2*n*x, x < 0}, {n*x, x >= 0}}]

Out=
Piecewise[{{2*n*x, x < 0}, {n*x, x >= 0}}]

In:=
Reduce[temp == 1, n]

Out=
(x > 0 && n == 1/x) || (x < 0 && n == 1/(2*x))

Cheers
Dimitris

```

• Prev by Date: Nested Dialogs
• Next by Date: Re: Convective diffusion equation in 2D
• Previous by thread: Re: Want to 'Solve' a piecewise equation for a common term
• Next by thread: Re: Want to 'Solve' a piecewise equation for a common term