Home > Archive > Mathematica > June 2005 > Viewing algebraic results
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Viewing algebraic results
|
|
| Milind Gupta 2005-06-05, 8:57 am |
|
Hello,
Is there a way to view the algebraic formulae for any variable defined
previously even if the variables in the formulae have been assigned a
numerical value?
Milind
| |
| David Bailey 2005-06-06, 8:59 am |
| Milind Gupta wrote:
> Hello,
> Is there a way to view the algebraic formulae for any variable defined
> previously even if the variables in the formulae have been assigned a
> numerical value?
>
> Milind
>
>
Hello,
Your question is a bit vague, but I will try to answer it.
In general, I advise people not to make assignments to simple algebraic
variables except inside Module (and similar) constructs. Suppose you
have something like:
myQuadratic=x^2+2x+3;
You could give x a numeric value and then myQuadratic would become a
number and you would have lost any other information about it.
Alternatively, you could make a substitution for x:
myQuadratic /. x->7.4
Working that way you don't lose any information. If this does not help,
I suggest you post a again with some actual examples of what you are doing.
David Bailey
http://www.dbaileyconsultancy.co.uk
| |
| David Park 2005-06-06, 8:59 am |
| Milind,
You could use ??, OwnValues or Information.
f = x^2;
x = 2;
f
4
?? f
Global`f
f = x^2
OwnValues[f]
{HoldPattern[f] :> x^2}
Information[f]
Global`f
f = x^2
But, frankly, this is not terribly useful. You can't easily manipulate these
expressions. I would not assign a value to x if I wanted it also to be used
as a symbolic variable. In fact, I hardly ever assign values to single
letter symbols. It is just a cause of trouble and complication. Define
functions with arguments and then you can evaluate when necessary by filling
in a specific argument and still have the symbolic formula available.
Clear[f,x]
f[x_] := x^2
f[2]
f[x]
4
x^2
Or else use rules to substitute values.
f = x^2;
f /. x -> 2
4
and the general formula is still available. But I much prefer the f[x_]
definition to the f definition without arguments.
So my practice would be:
1) Use definitions with arguments and avoid argumentless definitions.
2) Never assign values to single character symbols.
3) Stay exact and symbolic as long as possible.
4) Use argument filling or rules to supply specific values, which usually
comes at or toward the end of a calculation.
It isn't absolutely necessary to follow these rules. It just saves a lot of
trouble. Other people on MathGroup may have their comments on this.
David Park
djmp@earthlink.net
http://home.earthlink.net/~djmp/
From: Milind Gupta [mailto:milind.gupta@gmail.com]
Hello,
Is there a way to view the algebraic formulae for any variable defined
previously even if the variables in the formulae have been assigned a
numerical value?
Milind
| |
| Bhuvanesh Bhatt 2005-06-06, 8:59 am |
| One way would be to use OwnValues:
In[1]:= f = x^2;
In[2]:= g := Sin[x]
In[3]:= x = 3;
In[4]:= OwnValues[f]
2
Out[4]= {HoldPattern[f] :> x }
In[5]:= OwnValues[g]
Out[5]= {HoldPattern[g] :> Sin[x]}
There may very well be a simpler way.
Bhuvanesh,
Wolfram Research.
| |
| Pratik Desai 2005-06-07, 3:59 am |
| Milind Gupta wrote:
>Hello,
> Is there a way to view the algebraic formulae for any variable defined
>previously even if the variables in the formulae have been assigned a
>numerical value?
>
>Milind
>
>
>
>
If you have explicitly defined the variable by Set or SetDelayed why not try
??f
for
f[x_]=x^2+3*x+2
f[3][color=darkred]
??f[color=darkred]
Best regards
Pratik Desai
--
Pratik Desai
Graduate Student
UMBC
Department of Mechanical Engineering
Phone: 410 455 8134
|
|
|
|
|