Skip to main content
Tweeted twitter.com/#!/StackMma/status/324340415572611072
edited my code once more...
Source Link
Verde
  • 85
  • 5

Struggled for a while on this problem and hopefully you can help... I have a mathematical expression that currently has a symbol where I used to have a function variable. How do I make the symbol back into a variable, so that my expression becomes a function again? My function became an expression when I saved it in a matrix, and so now I'm trying to make the different matrix elements back into functions after having constructed the matrix. Thanks in advance.

INCLUDING SOME CODE (my first time contributing on this website...)

Imagine a For loop sum (I've removed a substantial amount of code that's irrelevant for now)

Pstatesalpha[λ_]=0;
RankMatrix={};
elecdipole (*some vector of numbers*numbers delem*)
SumPstatesalpha[λ_, Alpharank_]  (*a predefined function of λ, Alpharank*)

For[fsumFor[Alpharank = 1, fsumAlpharank <= 3, fsum++Alpharank++,(
   For[jsum = 1, jsum <=Length[elecdipole], jsum++,(
Pstatesalpha[λ_] = (delem*a0)^2*SumPstatesalpha[λ,Alpharank] + Pstatesalpha[λ];
   )]
AppendTo[RankMatrix, {Alpharank,Pstatesalpha[λ]}]
)]

Note that I've saved Pstatesalpha[λ] as a function into RankMatrix. When I want to access (for instance)

RankMatrix[[1,2]]

Mathematica returns an expression that includes $\lambda$, but I can't use it as a function anymore.

Struggled for a while on this problem and hopefully you can help... I have a mathematical expression that currently has a symbol where I used to have a function variable. How do I make the symbol back into a variable, so that my expression becomes a function again? My function became an expression when I saved it in a matrix, and so now I'm trying to make the different matrix elements back into functions after having constructed the matrix. Thanks in advance.

INCLUDING SOME CODE (my first time contributing on this website...)

Imagine a For loop sum (I've removed a substantial amount of code that's irrelevant for now)

Pstatesalpha[λ_]=0;
RankMatrix={};
elecdipole (*some vector of numbers*)
SumPstatesalpha[λ_, Alpharank_]  (*a predefined function of λ, Alpharank*)

For[fsum = 1, fsum <= 3, fsum++,(
   For[jsum = 1, jsum <=Length[elecdipole], jsum++,(
Pstatesalpha[λ_] = (delem*a0)^2*SumPstatesalpha[λ,Alpharank] + Pstatesalpha[λ];
   )]
AppendTo[RankMatrix, {Alpharank,Pstatesalpha[λ]}]
)]

Note that I've saved Pstatesalpha[λ] as a function into RankMatrix. When I want to access (for instance)

RankMatrix[[1,2]]

Mathematica returns an expression that includes $\lambda$, but I can't use it as a function anymore.

Struggled for a while on this problem and hopefully you can help... I have a mathematical expression that currently has a symbol where I used to have a function variable. How do I make the symbol back into a variable, so that my expression becomes a function again? My function became an expression when I saved it in a matrix, and so now I'm trying to make the different matrix elements back into functions after having constructed the matrix. Thanks in advance.

INCLUDING SOME CODE (my first time contributing on this website...)

Imagine a For loop sum (I've removed a substantial amount of code that's irrelevant for now)

Pstatesalpha[λ_]=0;
RankMatrix={};
elecdipole (*some vector of numbers delem*)
SumPstatesalpha[λ_, Alpharank_]  (*a predefined function of λ, Alpharank*)

For[Alpharank = 1, Alpharank <= 3, Alpharank++,(
   For[jsum = 1, jsum <=Length[elecdipole], jsum++,(
Pstatesalpha[λ_] = (delem*a0)^2*SumPstatesalpha[λ,Alpharank] + Pstatesalpha[λ];
   )]
AppendTo[RankMatrix, {Alpharank,Pstatesalpha[λ]}]
)]

Note that I've saved Pstatesalpha[λ] as a function into RankMatrix. When I want to access (for instance)

RankMatrix[[1,2]]

Mathematica returns an expression that includes $\lambda$, but I can't use it as a function anymore.

edited body
Source Link
Mr.Wizard
  • 273.1k
  • 34
  • 595
  • 1.4k

Struggled for a while on this problem and hopefully you can help... I have a mathematical expression that currently has a symbol where I used to have a function variable. How do I make the symbol back into a variable, so that my expression becomes a function again? My function became an expression when I saved it in a matrix, and so now I'm trying to make the different matrix elements back into functions after having constructed the matrix. Thanks in advance.

INCLUDING SOME CODE (my first time contributing on this website...)

Imagine a For loop sum (I've removed a substantial amount of code that's irrelevant for now)

Pstatesalpha[λ_]=0;
RankMatrix={};
elecdipole /(*some vector of numbers*/)
SumPstatesalpha[λ_, Alpharank_]  /(*a predefined function of λ, Alpharank*/)

For[fsum = 1, fsum <= 3, fsum++,(
   For[jsum = 1, jsum <=Length[elecdipole], jsum++,(
Pstatesalpha[λ_] = (delem*a0)^2*SumPstatesalpha[λ,Alpharank] + Pstatesalpha[λ];
   )]
AppendTo[RankMatrix, {Alpharank,Pstatesalpha[λ]}]
)]

Note that I've saved Pstatesalpha[λ] as a function into RankMatrix. When I want to access (for instance)

RankMatrix[[1,2]]

Mathematica returns an expression that includes $\lambda$, but I can't use it as a function anymore.

Struggled for a while on this problem and hopefully you can help... I have a mathematical expression that currently has a symbol where I used to have a function variable. How do I make the symbol back into a variable, so that my expression becomes a function again? My function became an expression when I saved it in a matrix, and so now I'm trying to make the different matrix elements back into functions after having constructed the matrix. Thanks in advance.

INCLUDING SOME CODE (my first time contributing on this website...)

Imagine a For loop sum (I've removed a substantial amount of code that's irrelevant for now)

Pstatesalpha[λ_]=0;
RankMatrix={};
elecdipole /*some vector of numbers*/
SumPstatesalpha[λ_, Alpharank_]  /*a predefined function of λ, Alpharank*/

For[fsum = 1, fsum <= 3, fsum++,(
   For[jsum = 1, jsum <=Length[elecdipole], jsum++,(
Pstatesalpha[λ_] = (delem*a0)^2*SumPstatesalpha[λ,Alpharank] + Pstatesalpha[λ];
   )]
AppendTo[RankMatrix, {Alpharank,Pstatesalpha[λ]}]
)]

Note that I've saved Pstatesalpha[λ] as a function into RankMatrix. When I want to access (for instance)

RankMatrix[[1,2]]

Mathematica returns an expression that includes $\lambda$, but I can't use it as a function anymore.

Struggled for a while on this problem and hopefully you can help... I have a mathematical expression that currently has a symbol where I used to have a function variable. How do I make the symbol back into a variable, so that my expression becomes a function again? My function became an expression when I saved it in a matrix, and so now I'm trying to make the different matrix elements back into functions after having constructed the matrix. Thanks in advance.

INCLUDING SOME CODE (my first time contributing on this website...)

Imagine a For loop sum (I've removed a substantial amount of code that's irrelevant for now)

Pstatesalpha[λ_]=0;
RankMatrix={};
elecdipole (*some vector of numbers*)
SumPstatesalpha[λ_, Alpharank_]  (*a predefined function of λ, Alpharank*)

For[fsum = 1, fsum <= 3, fsum++,(
   For[jsum = 1, jsum <=Length[elecdipole], jsum++,(
Pstatesalpha[λ_] = (delem*a0)^2*SumPstatesalpha[λ,Alpharank] + Pstatesalpha[λ];
   )]
AppendTo[RankMatrix, {Alpharank,Pstatesalpha[λ]}]
)]

Note that I've saved Pstatesalpha[λ] as a function into RankMatrix. When I want to access (for instance)

RankMatrix[[1,2]]

Mathematica returns an expression that includes $\lambda$, but I can't use it as a function anymore.

edited my code some more...
Source Link
Verde
  • 85
  • 5

Struggled for a while on this problem and hopefully you can help... I have a mathematical expression that currently has a symbol where I used to have a function variable. How do I make the symbol back into a variable, so that my expression becomes a function again? My function became an expression when I saved it in a matrix, and so now I'm trying to make the different matrix elements back into functions after having constructed the matrix. Thanks in advance.

INCLUDING SOME CODE (my first time contributing on this website...)

Imagine a For loop sum (I've removed a substantial amount of code that's irrelevant for now)

Pstatesalpha[λ_]=0;
RankMatrix={};
For[jsumelecdipole /*some vector of numbers*/
SumPstatesalpha[λ_, Alpharank_]  /*a predefined function of λ, Alpharank*/

For[fsum = 1, jsumfsum <= 3, fsum++,(
   For[jsum = 1, jsum <=Length[elecdipole], jsum++,(
Pstatesalpha[λ_] = (delem*a0)^2*SumPstatesalpha[λ]^2*SumPstatesalpha[λ,Alpharank] + Pstatesalpha[λ];
   )]
AppendTo[RankMatrix, {Alpharank,Pstatesalpha[λ]}] 
)]

Note that I've saved Pstatesalpha[λ] as a function into RankMatrix. When I want to access (for instance)

RankMatrix[[1,2]]

Mathematica returns an expression that includes $\lambda$, but I can't use it as a function anymore.

Struggled for a while on this problem and hopefully you can help... I have a mathematical expression that currently has a symbol where I used to have a function variable. How do I make the symbol back into a variable, so that my expression becomes a function again? My function became an expression when I saved it in a matrix, and so now I'm trying to make the different matrix elements back into functions after having constructed the matrix. Thanks in advance.

INCLUDING SOME CODE (my first time contributing on this website...)

Imagine a For loop sum (I've removed a substantial amount of code that's irrelevant for now)

Pstatesalpha[λ_]=0;
RankMatrix={};
For[jsum = 1, jsum <= 3, jsum++,(
Pstatesalpha[λ_] = (delem*a0)^2*SumPstatesalpha[λ] + Pstatesalpha[λ];
AppendTo[RankMatrix, {Alpharank,Pstatesalpha[λ]}])

Note that I've saved Pstatesalpha[λ] as a function into RankMatrix. When I want to access (for instance)

RankMatrix[[1,2]]

Mathematica returns an expression that includes $\lambda$, but I can't use it as a function anymore.

Struggled for a while on this problem and hopefully you can help... I have a mathematical expression that currently has a symbol where I used to have a function variable. How do I make the symbol back into a variable, so that my expression becomes a function again? My function became an expression when I saved it in a matrix, and so now I'm trying to make the different matrix elements back into functions after having constructed the matrix. Thanks in advance.

INCLUDING SOME CODE (my first time contributing on this website...)

Imagine a For loop sum (I've removed a substantial amount of code that's irrelevant for now)

Pstatesalpha[λ_]=0;
RankMatrix={};
elecdipole /*some vector of numbers*/
SumPstatesalpha[λ_, Alpharank_]  /*a predefined function of λ, Alpharank*/

For[fsum = 1, fsum <= 3, fsum++,(
   For[jsum = 1, jsum <=Length[elecdipole], jsum++,(
Pstatesalpha[λ_] = (delem*a0)^2*SumPstatesalpha[λ,Alpharank] + Pstatesalpha[λ];
   )]
AppendTo[RankMatrix, {Alpharank,Pstatesalpha[λ]}] 
)]

Note that I've saved Pstatesalpha[λ] as a function into RankMatrix. When I want to access (for instance)

RankMatrix[[1,2]]

Mathematica returns an expression that includes $\lambda$, but I can't use it as a function anymore.

modified my code
Source Link
Verde
  • 85
  • 5
Loading
added an example
Source Link
Verde
  • 85
  • 5
Loading
Source Link
Verde
  • 85
  • 5
Loading