Re: simple modification of Solve
- To: mathgroup at smc.vnet.net
- Subject: [mg72722] Re: [mg72693] simple modification of Solve
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Tue, 16 Jan 2007 03:43:44 -0500 (EST)
- Reply-to: hanlonr at cox.net
Rather than modify Solve which would make it difficult to subsequently apply Solve's output, I recommend that you define your formatting as a wrapper. formatSolve[soln_]:=TableForm[{First[#],ToString[Length[#]]<>"-ple root"}&/@ (soln//Split)/."1-ple root":>"simple root", TableAlignments\[Rule]Center, TableHeadings->{None,{"root\n","multiplicity\n"}}]; (s=Solve[(x - 1)^2*x*(x - 3)^3*(x + 5)^5*(x + 2) == 0, x])//formatSolve The Solve results are still available s {{x -> -5}, {x -> -5}, {x -> -5}, {x -> -5}, {x -> -5}, {x -> -2}, {x -> 0}, {x -> 1}, {x -> 1}, {x -> 3}, {x -> 3}, {x -> 3}} Bob Hanlon ---- dimitris <dimmechan at yahoo.com> wrote: > I introduce the following trivial modification of (the output of) Solve > > solveMod[eq_Equal, x_] := > ({x -> #1[[1]], If[Length[#1] > 1, StringJoin[ToString[Length[#1]], > "-ple root"], "simple root"]} & ) /@ > Split[x /. Solve[eq, x]]//(TableForm[#1, TableAlignments -> Center, > TableHeadings -> {None, {"root\n", "multiplicity\n"}}] & ) > > Here is a simple application > > solveMod[(x - 1)^2*x*(x - 3)^3*(x + 5)^5*(x + 2) == 0, x] > > I look for other possible similar one-liners. > Any response will be greatly appreciate. > > Dimitris > -- Bob Hanlon hanlonr at cox.net