[Date Index]
[Thread Index]
[Author Index]
Re: problem evaluating a function on a list
*To*: mathgroup at smc.vnet.net
*Subject*: [mg69905] Re: [mg69867] problem evaluating a function on a list
*From*: Bob Hanlon <hanlonr at cox.net>
*Date*: Wed, 27 Sep 2006 06:04:32 -0400 (EDT)
*Reply-to*: hanlonr at cox.net
When the condition failed there was no operation on the list so a single result was returned. In the function definition, map your function onto the list.
H[x_List,om_,or_,H0_]:=If[Im[
om-4*om^(2/3)*or^(
1/3)+2*or+2*Sqrt[or]*Sqrt[om+or]]==0&&-1+om-4*om^(2/
3)*or^(1/3)+2*or+2*Sqrt[or]*Sqrt[
om+or]<0,H0*((1-om-2*or-2*Sqrt[or]*Sqrt[
om+or])*(1+#)^2+(Sqrt[or]+Sqrt[or+om*(1+#)^3])^2),I]&/@x;
xlist={0.09,0.17,0.27,0.4,0.88,1.3,1.43,1.53,1.75};
H[xlist,0.4,0.1,70]
{81.138,92.4217,108.473,132.803,261.891,435.859,503.238,559.829,699.774}
H[xlist,-0.4,0.1,70]
{I, I, I, I, I, I, I, I, I}
Bob Hanlon
---- wtplasar at ehu.es wrote:
> Hi everyone,
>
> I have to ask for your advise once again.
>
> I have this function
>
> H[x_, om_,
> or_, H0_] := If[Im[om - 4*om^(2/3)*or^(1/3) + 2*
> or + 2*Sqrt[or]*Sqrt[om + or]] == 0. && -1 + om - 4*om^(2/3)
> *or^(1/
> 3) + 2*or + 2*Sqrt[or]*Sqrt[om + or] < 0, H0*((1 - om -
> 2*or - 2*
> Sqrt[or]*Sqrt[om + or])*(1 + x)^2 + (Sqrt[or] + Sqrt[or + om*(1
> +
> x)^3])^2), I]
>
> and I want to evaluate it at a list
>
> xlist = {0.09, 0.17, 0.27, 0.4, 0.88, 1.3, 1.43, 1.53, 1.75};
>
> When I choose parameters so that a list of real values should be
> obtained everything seems to be fine as one can see if for instance we
> evaluate
>
> H[xlist, 0.4, 0.1, 70]
>
> (my result is {81.138, 92.4217, 108.473, 132.803, 261.891, 435.859,
> 503.238, 559.829, 699.774})
>
> whereas in the cases I would expect the result to be
> {I,I,I,I,I,I,I,I,I}
>
> I get simply one single
>
> I
>
> instead, as one can see from evaluation of
>
> H[xlist, -0.4, 0.1, 70].
>
> Can someone indicate why this happens, and how I can get the
> desired list which looks like {I,I,I,I,I,I,I,I,I}?
>
> Thanks in advance for your time,
>
> Ruth
>
>
Prev by Date:
** Re: Copying cell contents?**
Next by Date:
**Re: Program to calculate rational function with imbedded continued fraction**
Previous by thread:
** Re: problem evaluating a function on a list**
Next by thread:
**Mapping Functions That Take More Than One Argument**
| |