       • To: mathgroup at smc.vnet.net
• Subject: [mg19884] Re: [mg19862] questions about delayed expression.
• From: "Andrzej Kozlowski" <andrzej at tuins.ac.jp>
• Date: Sun, 19 Sep 1999 18:47:34 -0400
• Sender: owner-wri-mathgroup at wolfram.com

```The answer to the first question is easy. You need to use
Inter[c_] = Interval[{sola[], solb[]}]
and not :=. If you use := the right hand side is not evaluated until you
evaluate Int[.3] but then of course Mathematica treats the c on the right
hand side just as a symbol and  does not substitute 0.3 for it.

I can't think of any significantly simpler way of doing what you are asking
about in your second question. The following approach is an alternative but
is not really preferable.

In:=
a[x_] := x + 4
In:=
b[x_] := -3 x + 8
In:=
sola = Roots[a[x] == c, x][];
In:=
solb = Roots[b[x] == c, x][];
In:=
Inter[c_] = Interval[{sola, solb}] ;
In:=
Inter[0.3]
Out=
Interval[{-3.7, 2.56667}]
In:=
Inter[0.4]
Out=
Interval[{-3.6, 2.53333}]
--
Andrzej Kozlowski
Toyama International University
JAPAN
http://sigma.tuins.ac.jp
http://eri2.tuins.ac.jp

----------
>From: d8442803 at student.nsysu.edu.tw (Wen-Feng Hsiao)
>To: mathgroup at smc.vnet.net
>Subject: [mg19884] [mg19862] questions about delayed expression.
>Date: Sun, Sep 19, 1999, 2:20 PM
>

> Hi,
>
>    The following is the process that I run in my notebook.
>
> In:=
> a[x_] := x + 4
> b[x_] := -3 x + 8
>
> In:=
> sola = x /. Solve[{a[x] == c}, x];
> solb = x /. Solve[{b[x] == c}, x];
>
> In:=
> Inter[c_] := Interval[{sola[], solb[]}]
>
> In:=
> Inter[.3]
> Inter[.4]
>
> Out=
> \!\(Interval[{\(-4\) + c, \(8 - c\)\/3}]\)
>
> Out=
> \!\(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[] and
> solb[].
>