Skip to main content
Added reference
Source Link
Jens
  • 97.9k
  • 7
  • 215
  • 510

Edit 4

To capture what I said in some additional comments: if you do decide to use the lowest singular value as a merit function for further root finding or minimization, as a function of the parameter κ, then you may run into the problem that SingularValueList will omit the lowest singular values if they are too small relative to the largest singular value. This can lead to jumps if you plot the lowest singular value versus κ, because you aren't tracking the same singular value at all times. To insure that no singular values are omitted, one has to use

SingularValueList[m, Tolerance -> 0]

I can't answer the question of whether this is physically the best procedure, because I don't know what the physical problem is.

A very good mathematical discussion of the singular value decomposition is in Numerical Recipes in C on page 59.

Edit 4

To capture what I said in some additional comments: if you do decide to use the lowest singular value as a merit function for further root finding or minimization, as a function of the parameter κ, then you may run into the problem that SingularValueList will omit the lowest singular values if they are too small relative to the largest singular value. This can lead to jumps if you plot the lowest singular value versus κ, because you aren't tracking the same singular value at all times. To insure that no singular values are omitted, one has to use

SingularValueList[m, Tolerance -> 0]

I can't answer the question of whether this is physically the best procedure, because I don't know what the physical problem is.

A very good mathematical discussion of the singular value decomposition is in Numerical Recipes in C on page 59.

Added explanation how to do replacement; added 1 characters in body; edited body
Source Link
Jens
  • 97.9k
  • 7
  • 215
  • 510

The pattern f[κ_?NumericQ] insures that the function will return a value only if it is called with a numerical argument κ. Any minimization or root finding routine will by default attempt to simplify f[κ] symbolically, but since f is defined_only_defined only for numerical arguments that attempt will fail. This is good because the automatic evaluator then chooses a purely numerical method, which in our case is faster.

So there's still some work to do to get rid of the warning message, but in principle we got somewhere.

Edit 3

In order to make a pre-existing matrix mat (containing a parameter κ) into a function that you can use for root finding etc., you have to watch out for the difference between the global variable κ and the pattern instance κ that is passed to the function in place of the "dummy variable" in the pattern f[κ_?NumericQ].

The dummy variable could have equally well been named x_ or b_, so how do we make sure that it gets substituted into the matrix wherever the global variable κ appears?

Here is a way to do that. Assume the matrix is externally given as

Clear[κ]; mat = {{-892.33`, 973.21`, 44.306` + κ, -81.103`, 
    0}, {446.12`, -557.94`, 0, -682.54`, -314.89`}, {0, 
    893.37`, -506.68` κ, -391.457`, 0}, {0, 429.78`, 
    0, -210.47`, 342.85`}, {278.32` κ, 0, 963.41`, 
    217.71`, -342.68` + κ}};

Then change your function definition to

f[x_?NumericQ] := Last[SingularValueList[mat /. κ -> x]]

What this does is to replace the global κ (which you must make sure is unassigned, hence the Clear for safety) by the value of the dummy variable in the function. I have to change its name to something other than κ, so I chose x.

The pattern f[κ_?NumericQ] insures that the function will return a value only if it is called with a numerical argument κ. Any minimization or root finding routine will by default attempt to simplify f[κ] symbolically, but since f is defined_only_ for numerical arguments that attempt will fail. This is good because the automatic evaluator then chooses a purely numerical method, which in our case is faster.

So there's still some work to do to get rid of the warning message, but in principle we got somewhere.

The pattern f[κ_?NumericQ] insures that the function will return a value only if it is called with a numerical argument κ. Any minimization or root finding routine will by default attempt to simplify f[κ] symbolically, but since f is defined only for numerical arguments that attempt will fail. This is good because the automatic evaluator then chooses a purely numerical method, which in our case is faster.

So there's still some work to do to get rid of the warning message, but in principle we got somewhere.

Edit 3

In order to make a pre-existing matrix mat (containing a parameter κ) into a function that you can use for root finding etc., you have to watch out for the difference between the global variable κ and the pattern instance κ that is passed to the function in place of the "dummy variable" in the pattern f[κ_?NumericQ].

The dummy variable could have equally well been named x_ or b_, so how do we make sure that it gets substituted into the matrix wherever the global variable κ appears?

Here is a way to do that. Assume the matrix is externally given as

Clear[κ]; mat = {{-892.33`, 973.21`, 44.306` + κ, -81.103`, 
    0}, {446.12`, -557.94`, 0, -682.54`, -314.89`}, {0, 
    893.37`, -506.68` κ, -391.457`, 0}, {0, 429.78`, 
    0, -210.47`, 342.85`}, {278.32` κ, 0, 963.41`, 
    217.71`, -342.68` + κ}};

Then change your function definition to

f[x_?NumericQ] := Last[SingularValueList[mat /. κ -> x]]

What this does is to replace the global κ (which you must make sure is unassigned, hence the Clear for safety) by the value of the dummy variable in the function. I have to change its name to something other than κ, so I chose x.

deleted 1 characters in body
Source Link
Last@DSingularValueList[m]Last@SingularValueList[m]
Last@DSingularValueList[m]
Last@SingularValueList[m]
Several typos removed. Simplified to SingularValueList; deleted 43 characters in body; deleted 1 characters in body
Source Link
Jens
  • 97.9k
  • 7
  • 215
  • 510
Loading
Added explanations and further example
Source Link
Jens
  • 97.9k
  • 7
  • 215
  • 510
Loading
Added: make function numerical; deleted 171 characters in body
Source Link
Jens
  • 97.9k
  • 7
  • 215
  • 510
Loading
Source Link
Jens
  • 97.9k
  • 7
  • 215
  • 510
Loading