我在用朱莉娅的方法数值解一个非线性方程组。我在用Newthon方法。我唯一不知道怎么做的,就是计算雅可比矩阵。到目前为止,我还没有找到计算偏导数的函数。
我的系统:
f(x1, x2) = 2*x2^2+x1^2
g(x1, x2) = (x1-1)^2 + (x2-1/2)^2谢谢你的支持,向你问好,斯齐蒙。
发布于 2019-01-21 13:35:45
让我把我在评论中已经提到的写下来作为回答。您可以使用自动微分来计算偏导数:
julia> using ForwardDiff
julia> f(x) = 2*x[2]^2+x[1]^2 # f must take a vector as input
f (generic function with 2 methods)
julia> g = x -> ForwardDiff.gradient(f, x); # g is now a function representing the gradient of f
julia> g([1,2]) # evaluate the partial derivatives (gradient) at some point x
2-element Array{Int64,1}:
2
8https://stackoverflow.com/questions/54277219
复制相似问题