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

MathGroup Archive 2010

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

Search the Archive

Re: Mathematica- Use a previous equation into the function Function

  • To: mathgroup at smc.vnet.net
  • Subject: [mg111537] Re: Mathematica- Use a previous equation into the function Function
  • From: David Bailey <dave at removedbailey.co.uk>
  • Date: Wed, 4 Aug 2010 05:56:53 -0400 (EDT)
  • References: <i33cvi$87q$1@smc.vnet.net>

On 01/08/10 09:58, Camille wrote:
> Dear All,
>
> I am fairly new to mathematica. I am stuck with a problem I cannot solve. I would like to call a previous equation into the function Function. If a type directly the expression or copy paste it, it works. However, when I call the expression by its name it does not.
> Here is the code for a more precise explanation:
>
> In: ll
> Out: d + a x + h x^2 + b y + e x y + c z + j z^2
>
> In: Function[##, a x + b y + c z + d + e x y + h x^2 + j z^2]&  @@ {Listp}
> Out: Function[{a, b, c, d, e, h, j},
>   a x + b y + c z + d + e x y + h x^2 + j z^2]
>
> It works well and I can use it to generate as many equations I want by replacing the variables a,b,c,d,e,h,j.
> But if I do:
>
> In:Function[##, ll]&  @@ {Listp}
> Out:Function[{a, b, c, d, e, h, j}, ll]
>
> And I cannot use it.
>
> Any suggestions?
>
> Thanks in advance. Do not hesitate to post if you need some further information. Sorry for my bad english.
>
> Camille
>
Since you say you are fairly new to Mathematica, I am wondering if you 
are adopting the above, rather obscure style from choice. I would simply 
define a named function to do what you want:

In[2]:= buildExpression[a_,b_,c_,d_,e_,h_,j_]:=a x+b y+c z+d+e x y+h 
x^2+j z^2;

In[5]:= buildExpression[1,2,3,4,5,6,7]

Out[5]= 4+x+6 x^2+2 y+5 x y+3 z+7 z^2

In[6]:= buildExpression[q+1,q+2,q+3,q+4,q+5,q+6,q+7]

Out[6]= 4+q+(1+q) x+(6+q) x^2+(2+q) y+(5+q) x y+(3+q) z+(7+q) z^2

David Bailey

http://www.dbaileyconsultancy.co.uk


  • Prev by Date: Re: automatically include automatic numbering in a cell style
  • Next by Date: Re: Issuing Function Calls within a Plot command
  • Previous by thread: Re: Mathematica- Use a previous equation into the function Function
  • Next by thread: Re: importing 3D-data from STEP file