MathGroup Archive 2002

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

Search the Archive

RE: RE: Re: Is it possible to access internal variables?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg34741] RE: [mg34725] RE: [mg34709] Re: [mg34705] Is it possible to access internal variables?
  • From: "DrBob" <majort at cox-internet.com>
  • Date: Tue, 4 Jun 2002 03:41:54 -0400 (EDT)
  • Reply-to: <drbob at bigfoot.com>
  • Sender: owner-wri-mathgroup at wolfram.com

Thanks, Dave!

Rebounding off that, here's a solution that puts off formatting until
time to display the table:

ClearAll[f, mem]
f[x_] := (x - 3)(x - 4);
mem[func_] := mem[func] = {};
mem[x_, func_] := Module[{t = func[x]},
      AppendTo[mem[func], {x, t, func'[x]}];
      t];
FindMinimum[mem[x, f], {x, 2}]
x - 7/2 /. %[[-1]]
formRule = {a_Real, b_Real, c_Real} -> {NumberForm[a, {12, 11}],
        NumberForm[b, {3, 2}], ScientificForm[c, {3, 2}]};
TableForm[mem[f] /. formRule, TableHeadings -> {None, {"x", "f[x]",
"f'[x]"}}]

Bobby Treat

-----Original Message-----
From: David Park [mailto:djmp at earthlink.net] 
To: mathgroup at smc.vnet.net
Subject: [mg34741] RE: [mg34725] RE: [mg34709] Re: [mg34705] Is it possible to
access internal variables?

This is one method to obtain individual column formatting in your Table.
The
formatting has to go in mem.

SetOptions[NumberForm,
    ExponentFunction -> (Null &),
    NumberSigns -> {"-", " "},
    NumberPadding -> {" ", "0"}];

ClearAll[f, mem]
f[x_] := (x - 3)(x - 4);
mem[func_] := mem[func] = {};
mem[x_, func_] := Module[{t = func[x]},
      AppendTo[
        mem[func], {NumberForm[x, {12, 11}], NumberForm[t, {3, 2}],
          ScientificForm[func'[x], {3, 2},
            NumberSigns -> {"-", " "},
            NumberPadding -> {" ", "0"}]}];
      t];
FindMinimum[mem[x, f], {x, 2}]
 TableForm[mem[f], TableHeadings -> {Automatic, {"x", "f[x]",
"f'[x]"}}]

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/

> From: DrBob [mailto:majort at cox-internet.com]
To: mathgroup at smc.vnet.net

>
> For a bit more insight and flexibility, try this:
>
> ClearAll[f, mem]
> f[x_] := (x - 3)(x - 4);
> mem[func_] := mem[func] = {};
> mem[x_, func_] := Module[{t = func[x]},
>       AppendTo[mem[func], {x, t, func'[x]}];
>       t];
> FindMinimum[mem[x, f], {x, 2}]
> NumberForm[
>   TableForm[mem[f], TableHeadings -> {Automatic, {"x", "f[x]",
> "f'[x]"}}], 12]
>
> ODDLY ENOUGH, when I tried to use NumberForm within TableForm, the
> result didn't display as a table, so I don't know how to show
different
> columns of the table at different display precisions.
>
> QUESTION: Does anybody know how to do that?
>
>
> Bobby Treat
>





  • Prev by Date: RE: Help with Select[]
  • Next by Date: Re: Encapsulated submissions
  • Previous by thread: RE: RE: Re: Is it possible to access internal variables?
  • Next by thread: RE: RE: Re: Is it possible to access internal variables?