Re: How to find solutions for conditioned equations?
- To: mathgroup at smc.vnet.net
- Subject: [mg19920] Re: [mg19861] How to find solutions for conditioned equations?
- From: "Allan Hayes" <hay at haystack.demon.co.uk>
- Date: Tue, 21 Sep 1999 02:22:51 -0400
- References: <7s3pia$cna@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Bob, Your solution to this particular problem does not need InequalitySolve (but, of course, using it in other situations would give the real solutions and more information) soln[a_ /; 0 <= a <= 1] := Module[{x}, x /. Solve[(x + 1)/2 == a || (3 - x)/2 == a, x]] Table[soln[a], {a, 0, 1, .2}] {{-1, 3}, {-0.6, 2.6}, {-0.2, 2.2}, {0.2, 1.8}, {0.6, 1.4}, {1., 1.}} and at a = 0 we should have 3, since x is restricted to be >-1. We can use Inequality solve do do more of the work: Needs["Algebra`InequalitySolve`"]; is = InequalitySolve[ ((x + 1)/2 == a && -1 < x <= 1 || (3 - x)/2 == a && 1 < x <= 3), {a, x}] a == 0 && x == 3 || 0 < a < 1 && (x == -1 + 2 a || x == 3 - 2 a) || a == 1 && x == 1 Now we can define the multi-valued inverse function Apply[Set[s[a_ /; #1], x /. {ToRules[#2]}] &, sol, {1}]; s[a_/;-Infinity<a<Infinity] = {}; Table[s[a], {a, -.2, 1.2, .2}] {{}, {3}, {-0.6, 2.6}, {-0.2, 2.2}, {0.2, 1.8}, {0.6, 1.4}, {1}, {}} Allan --------------------- Allan Hayes Mathematica Training and Consulting Leicester UK www.haystack.demon.co.uk hay at haystack.demon.co.uk Voice: +44 (0)116 271 4198 Fax: +44 (0)870 164 0565 <BobHanlon at aol.com> wrote in message news:7s3pia$cna at smc.vnet.net... > A[x_ /; -1 < x <= 1] := (x + 1)/2; > A[x_ /; 1 < x <= 3] := (3 - x)/2; > A[x_] = 0; > > Plot[A[x], {x, -1.2, 3.2}]; > > Needs["Algebra`InequalitySolve`"]; > > soln[a_ /; 0 <= a <= 1] := Module[{x}, x /. > {ToRules[InequalitySolve[(x + 1)/2 == a || (3 - x)/2 == a, x]]}]; > > Table[soln[a], {a, 0, 1, .2}] > > {{-1, 3}, {-0.6, 2.6}, {-0.2, 2.2}, {0.2, 1.8}, {0.6, 1.4}, {1.}} > > Bob Hanlon > > In a message dated 9/19/1999 5:43:39 AM, d8442803 at student.nsysu.edu.tw writes: > > >Suppose I have an equation > > > >A(x)= (x+1)/2, for -1<x<=1 > > = (3-x)/2, for 1<x<=3 > > = 0 , otherwise > > > >Now if I want to find solutions for A(x)==a, how can I otain the > >solutions simultaneously (i.e., represented as (2a-1, 3-2a))? I always > > > >use the stupid method to solve them separately, but I found it's laborous > > > >when I have B(x), C(x) needed to be solved together. (I am trying to use > > > >alpha-cut to proceed the interval operations) Any suggestions? > > >