MathGroup Archive 1995

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

Search the Archive

Re: Some Easy (hopefully) Questions

  • To: mathgroup at
  • Subject: [mg2038] Re: Some Easy (hopefully) Questions
  • From: David Harvatin <dtharvat at>
  • Date: Sat, 16 Sep 1995 01:41:41 -0400
  • Organization: University of Colorado at Boulder

Rob Carscadden <carscadd at> wrote:
>I'm trying to run a model using Mathematica. I've scoured all our 
>libraries and all the books are gone. Working with all too basic 
>Mathematica By Example, I haven't been able to find how to do some rather 
>easy things.
>The first thing I want to do is find a max (I need to plug the max and 
>where it occurs into anther equation). I have a function, and I have 
>taken both the first and second derivatives. I solve for f'(x) = 0. But 
>here's where the trouble comes in. I want to plug these points back into 
>my f(x). How can I do this. Look at the following example:
>possmax = Solve[(x - 1)^2 == 0,x] // N
>I get {{x -> 1.},{x ->1.}}
>and when I try 
>I get {x ->1.} 
>but I want the number 1 instead.
>I know this if probably extremely basic, but due to lack of available 
>documentation here, I can not figure it out.
>P.S. another useful trick to know would be how many objects are in a 
>list. My function a bit more complicated (compositions, logs etc.), and I 
>don't exactly how many solutions I will have from the Solve[ ] statement.
>Rob Carscadden                        
>carscadd at                   
>49% of all Statistics are made up on the spot!


To answer your first question, suppose you want to put both solutions into an expression called 
exp1 that is also a function of x :
exp1 = 5 x -3.  The ReplaceAll operator (forward slash then period) will replace all 
occurrences of x in exp1 with the values you obtain for possmax if you do the following :
exp1 /. possmax
Your answer will be in the form of a list, with each element of the list corresponding to one 
of your x values in possmax.  If you want only one solution, then do the following :
exp1 /. possmax[[1]]  or
exp1 /. possmax[[2]] 

To answer your second question, use the Length command :
Length[possmax] gives you an answer of 2.  For a list such as : list = { {1,2},{3,4} }, 
Length[list] also gives an answer of 2.  
Good luck. I had to learn Mathcad without the benefit of the book, so I know how you feel.  
BTW, unlike Mathcad, Stephen Wolfram's MMA book is readily available in most large bookstores 
for around $50. 

Dave Harvatin
dtharvat at

  • Prev by Date: Re: ArcSin[Sin[x]]
  • Next by Date: Mathamatica for Win in OS2/warp
  • Previous by thread: Re: Some Easy (hopefully) Questions
  • Next by thread: Mathamatica for Win in OS2/warp