MathGroup Archive 2002

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

Search the Archive

Re: function defining including solve command

  • To: mathgroup at smc.vnet.net
  • Subject: [mg32978] Re: [mg32956] function defining including solve command
  • From: Tomas Garza <tgarza01 at prodigy.net.mx>
  • Date: Fri, 22 Feb 2002 01:49:08 -0500 (EST)
  • References: <200202210707.CAA02201@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

I'm afraid I can't reproduce the problem you allude to. I give a simple
example:

In[1]:=
Fn[x_, y_] := Module[{formulae},
   formulae = k + x^2 + y^2 - 1; solution =
     Solve[formulae == 0, k]; solution[[1]]]
In[2]:=
y = 7; Do[Print[Table[Fn[x, y], {x, 1, 3, 0.5}]], {i, 4}]
{{k -> -49}, {k -> -50.25}, {k -> -52.}, {k -> -54.25},
  {k -> -57.}}
{{k -> -49}, {k -> -50.25}, {k -> -52.}, {k -> -54.25},
  {k -> -57.}}
{{k -> -49}, {k -> -50.25}, {k -> -52.}, {k -> -54.25},
  {k -> -57.}}
{{k -> -49}, {k -> -50.25}, {k -> -52.}, {k -> -54.25},
  {k -> -57.}}

It seems to work as it should.

Tomas Garza
Mexico City

----- Original Message -----
From: "Takayuki MAKINO" <tmakino at spectro.ujf-grenoble.fr>
To: mathgroup at smc.vnet.net
Subject: [mg32978] [mg32956] function defining including solve command


> bonjour
>
> I am very sad because the code which I am trying now cannot
> work. I wrote a function, the definition of which includes
> "solve" command. If simplified, this is as follows.
>
> Fn[x_,y_] := Module[{formulae},formulae=........, solution=Solve
> [formulae==0,K];.........;solution[[1]]]
>
> If I do not use the loop structure (for example, Table etc),
> it works. But, if this function is located inside the loop,
> for example,
>
> y = 7;
> Do[Table[N[Fn[x,y],{x,1,3,0.1}]],{i,4}];   (* Bang!!! *)
>
> Always execution of such kind of loop produces an error message,
> like "imcomplete! It needs more input". How should I do in such
> case? MapThread command? If one writes the code with the
> same content without using Function (:=) only with Assignment
> (=), one can successfully rotate the loop.
>
> regards best.
>
>



  • Prev by Date: Re: Getting Coordinates from plot
  • Next by Date: Re: Position within a list[2]
  • Previous by thread: function defining including solve command
  • Next by thread: complexity of AppendTo