Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1999
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1999

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

Search the Archive

Re: questions about delayed expression.

  • To: mathgroup at smc.vnet.net
  • Subject: [mg19889] Re: [mg19862] questions about delayed expression.
  • From: BobHanlon at aol.com
  • Date: Sun, 19 Sep 1999 18:47:36 -0400
  • Sender: owner-wri-mathgroup at wolfram.com

a[x_] := x + 4;
b[x_] := -3x + 8;
sol[func_, c_] := Module[{x}, x /. Flatten[Solve[func[x] == c, x]]];
inter[c_] := Interval[{sol[a, c], sol[b, c]}];

inter[c]

Interval[{-4 + c, (8 - c)/3}]

inter[.3]

Interval[{-3.7, 2.56667}]

inter[.4]

Interval[{-3.6, 2.53333}]

Alternate approach:

Needs["Algebra`InequalitySolve`"]

intvl[c_] := Module[{x, temp}, 
    temp = InequalitySolve[a[x]  >= c && b[x] >= c, x];
    Interval[{First[temp], Last[temp]}]]

intvl[c]

Interval[{-4 + c, 8/3 - c/3}]

intvl[.3]

Interval[{-3.7, 2.56667}]

intvl[.4]

Interval[{-3.6, 2.53333}]

Bob Hanlon

In a message dated 9/19/1999 5:26:07 AM, d8442803 at student.nsysu.edu.tw writes:

>   The following is the process that I run in my notebook.
>
>In[1]:=
>a[x_] := x + 4
>b[x_] := -3 x + 8
>
>In[2]:=
>sola = x /. Solve[{a[x] == c}, x];
>solb = x /. Solve[{b[x] == c}, x];
>
>In[3]:=
>Inter[c_] := Interval[{sola[[1]], solb[[1]]}]        
>
>In[4]:=
>Inter[.3]
>Inter[.4]
>
>Out[4]=
>\!\(Interval[{\(-4\) + c, \(8 - c\)\/3}]\)
>
>Out[5]=
>\!\(Interval[{\(-4\) + c, \(8 - c\)\/3}]\)
>
>My questions are: 
>1. Why Inter[.3] and Inter[.4] cannot be evaluated? Their results should
>
>not be the same. This is not my intention.
>
>2. I don't know if there is any better way to extract the 'root(s)' from
>
>the output of 'Solve' command. The output form is {{x->root1}, {x-
>>root2}, ...{}}. If I use 'ReplaceAll'(/.) command, it will remain a list
>
>of solutions of x. It seems I can only use element operation to extract
>
>the root(s) from the solution list? In my case, I use sola[[1]] and 
>solb[[1]].
> 
>Please give me suggestions. Thanks for your help.
>


  • Prev by Date: Re: questions about delayed expression.
  • Next by Date: Re: Coordinate Transformations
  • Previous by thread: Re: questions about delayed expression.
  • Next by thread: Re: questions about delayed expression.