Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

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

Search the Archive

Re: Import polynomial from file and define function from

  • To: mathgroup at smc.vnet.net
  • Subject: [mg112157] Re: Import polynomial from file and define function from
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Thu, 2 Sep 2010 02:32:48 -0400 (EDT)
  • Reply-to: hanlonr at cox.net

Use Set rather than SetDelayed

F[q_, x_] = poly;


Bob Hanlon

---- nick_twisp <niels.kurz at googlemail.com> wrote: 

=============
Hello Mathematica community,

I am looking for a solution of the following problem:

I have some quite long polynomial in q and x stored in a file and
with

test = Import["this_file_containing_the_polynomial"];

I import the string and with

poly = ToExpression[test];

I convert it to an expression. If I usually would like to define a
function (like in this case in x and q) from it, I would write

F[q_, x_] := poly;

Unfortunately this doesn't work at all. Strange enough if I just paste
the huge expression behind F[q_, x_]:=, then it works and I have a
function in q and x, which is evaluated when I put a concrete number
e.g. for q (then becoming a polynomial in x).

Does someone have an idea, how I could define a function from an
expression?

Thanks in advance,





  • Prev by Date: Re: coordinates in LogLogPlots
  • Next by Date: Re: coordinates in LogLogPlots
  • Previous by thread: Re: Another question on ParallelDo
  • Next by thread: Difficult constrained optimization problem