Trying to use Table to iterate a Part specification
- To: mathgroup at smc.vnet.net
- Subject: [mg42542] Trying to use Table to iterate a Part specification
- From: pi314159 at hotmail.com (pi314159)
- Date: Mon, 14 Jul 2003 05:42:11 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
I'm trying to write a small program that will identify critical points of functions with two independent variables. I'm using the discriminant test to generate a list of the value of the discriminant at each point; since If isn't listable (I think), and I couldn't get Map to cooperate, I'm using Table to run the if-loop over each item in the list of discriminant values ("signs"). However, I have to use a Part specification to tell If which element in the list I want it to use, and Part doesn't like Table's iterations. Is there a way around this? Thanks! pi314159 --- criticalpoints[expr_] := Solve[{D[expr, x] == 0, D[expr, y] == 0}, {x, y}]; discriminant[expr_] := D[expr, x, x]*D[expr, y, y] - D[expr, x, y]^2; identifycriticalpoints[expr_] := Module[{signs, length1, points, points2}, signs = discriminant[expr] /. criticalpoints[expr]; length1 = Length[signs]; points = criticalpoints[expr]; points2 = Partition[DeleteCases[Flatten[List @@@ Flatten[points]], _Symbol], 2] Table[ If[Positive[Part[signs, i]] == True, If[D[expr, x, x] > 0, Print["Minimum", Part[points2, i]], Print["Maximum", Part[points2, i]]], Print["Saddle point", Part[points2, i] ], {i, 1, length1}] ]; ]