반응형

Excel for scientists and engineer - numerical method by E. Joseph Billo

의 미분방정식의 풀이 입니다.

 

first derivative function
first derivative function

Option Explicit
Function FirstDerivDemo(expression, variable) As Double
'Custom function to return the first derivative of a formula in a cell

Dim OldX As Double, OldY As Double, NewX As Double, NewY As Double
Dim Formulastring As String, XAddress As String

Formulastring = expression.Formula
OldY = expression.Value
XAddress = variable.Address 'Default is absolute reference
OldX = variable.Value
NewX = OldX * 1.00000001
Formulastring = Application.ConvertFormula(Formulastring, xlA1, xlA1, xlAbsolute) 'Convert all references in formula to absolute
Formulastring = Application.Substitute(Formulastring, XAddress, NewX)
NewY = Evaluate(Formulastring)
FirstDerivDemo = (NewY - OldY) / (NewX - OldX)
End Function

 

 

반응형

+ Recent posts