Fw: How to operate on strictly numerical functions ?
- To: mathgroup at smc.vnet.net
- Subject: [mg24105] Fw: How to operate on strictly numerical functions ?
- From: "Mark Harder" <harderm at ucs.orst.edu>
- Date: Tue, 27 Jun 2000 00:51:58 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
-----Original Message----- From: Mark Harder <harderm at ucs.orst.edu> To: mathgroup at smc.vnet.net Subject: [mg24105] How to operate on strictly numerical functions ? Some of the Mathematica functions made for numerical procedures appear to actually evaluate by substitution of symbolic variables with replacement rules. An example of this, which has blocked me for more than a week now, is NonlinearRegress, which seems to evaluate the user-supplied model function symbolically, then evaluate the resulting expression through replacement of the independent variables and the current set of adjustable parameters through replacement rules that it constructs. My model function requires evaluation of the SVD (with SingularValues ) of a matrix computed from the independent variables and the parameters of the model, and so NonlinearRegress fails, since SingularValues can't accept a non-numeric matrix. A simpler example I have encountered is the numeric derivative function, which I'll use to illustrate my problem. First, construct a simple test function which, through an If test, won't evaluate for non-numeric arguments: In:= ClearAll[x, tstFn1] tstFn1[x_] := If[NumericQ[x ], Return[x^2];, Print["NonNumeric x and/or y."];] In:=tstFn1 Out=4 In:=tstFn1[u] & try to use ND on this function: <<NumericalMath`NLimit` In:=ClearAll[u, v] ND[tstFn1[u ], u, 1.] Out= 0 So, I'm looking for some means of modifying testFn1 to cause ND to evaluate it only after numeric substitution for u. Is there some way of Hold-ing evaluation until numeric values are assigned to arguments of a function? Is this sort of thing impossible in Mathematica? Do I have to write my own numeric routines for finding derivatives, gradients, Jacobians, least-squares fits, etc. by procedural routines ala FORTRAN? Thanks for any help you can offer. mark e. harder harderm at ucs.orst.edu