Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2001

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

Search the Archive

Re: variables versus functions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg28806] Re: [mg28797] variables versus functions
  • From: BobHanlon at aol.com
  • Date: Mon, 14 May 2001 01:32:58 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Clear[a, b, x, af, bf];
a = Cos[x];
b = ArcTan[x];
af[x_] := Cos[x];
bf[x_] := ArcTan[x];

Plot[a, {x, 0, 2Pi}];

FindRoot[a == b, {x, Pi/2}] == 
  FindRoot[af[x] == bf[x], {x, Pi/2}]

True

However, if x has a definition prior to defining the variables

x = Pi/4;
a = Cos[x];
b = ArcTan[x];

{a, b}

{1/Sqrt[2], ArcTan[Pi/4]}

Plot[a, {x, 0, 2Pi}];

FindRoot[a == b, {x, Pi/2}]

\!\(\*FormBox[
  RowBox[{\(FindRoot::"jsing"\), \(\(:\)\(\ \)\), "\<\"Encountered a singular 
\
Jacobian at the point \\!\\(TraditionalForm\\`x\\) = \
\\!\\(TraditionalForm\\`1.5707963267948966`\\). Try perturbing the initial \
point(s).\"\>"}], TraditionalForm]\)

FindRoot[a == b, {x, Pi/2}]


Bob Hanlon

In a message dated 2001/5/13 3:34:17 AM, jsweet at engineering.ucsb.edu writes:

>How is it different to define a variable such as A=Cos[x]
>versus a function  A[x_]:=Cos[x] ?  
>
>Furthermore, what If I define two functions  A[x_]:=Cos[x] and
>B[x_]=ArcTan[x]?  How would FindRoot[A==B,{x,pi/2}]  treat this
>differently than if I just used variable definitions for A & B?
>


  • Prev by Date: Re: Mandrake 8.0 and Mathematica 4.01
  • Next by Date: Re: Problem overriding simple built-in functions
  • Previous by thread: Re: variables versus functions
  • Next by thread: Re: variables versus functions