nonlinear-functions

Finding complex roots from set of non-linear equations in python

旧街凉风 提交于 2019-12-06 01:30:06
问题 I have been testing an algorithm that has been published in literature that involves solving a set of 'm' non-linear equations in both Matlab and Python. The set of non-linear equations involves input variables that contain complex numbers, and therefore the resulting solutions should also be complex. As of now, I have been able to get pretty good results in Matlab by using the following lines of code: lambdas0 = ones(1,m)*1e-5; options = optimset('Algorithm','levenberg-marquardt',...

Error in optim: function cannot be evaluated at initial parameters [closed]

心不动则不痛 提交于 2019-12-05 10:32:01
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center . Closed 6 years ago . So I've run into this weird error in R. I have a simple function which returns an error term when comparing real and simulated prices, called hestondifferences() . when I try to find the local minima via: res<-optim(fn=hestondifferences, par = c(vT=vT,

Constrained optimization for nonlinear multivariable function in Java

拟墨画扇 提交于 2019-12-05 02:50:26
I am looking for an open source implementation of a method doing constrained optimization for nonlinear multivariable function in Java . There are several open source java implementations that can do this, such as: OptaPlanner (apache license, 100% java, lots of examples and documentation) jacop choco ... IPOPT is the most robust solver I know of. It has a Java interface although I have no idea how good that is, I only use the C++ API. I recently ported Michael Powells' COBYLA2 derivative-free optimizer for nonlinear objective functions and constraints to Java. You'll find the source code here

Finding complex roots from set of non-linear equations in python

北城以北 提交于 2019-12-04 06:11:43
I have been testing an algorithm that has been published in literature that involves solving a set of 'm' non-linear equations in both Matlab and Python. The set of non-linear equations involves input variables that contain complex numbers, and therefore the resulting solutions should also be complex. As of now, I have been able to get pretty good results in Matlab by using the following lines of code: lambdas0 = ones(1,m)*1e-5; options = optimset('Algorithm','levenberg-marquardt',... 'MaxFunEvals',1000000,'MaxIter',10000,'TolX',1e-20,... 'TolFun',1e-20); Eq = @(lambda)maxentfun(lambda,m,h,g);

How to enumerate x^2 + y^2 = z^2 - 1 (with additional constraints)

笑着哭i 提交于 2019-12-03 09:19:01
问题 Lets N be a number (10<=N<=10^5) . I have to break it into 3 numbers (x,y,z) such that it validates the following conditions. 1. x<=y<=z 2. x^2+y^2=z^2-1; 3. x+y+z<=N I have to find how many combinations I can get from the given numbers in a method. I have tried as follows but it's taking so much time for a higher number and resulting in a timeout.. int N= Int32.Parse(Console.ReadLine()); List<String> res = new List<string>(); //x<=y<=z int mxSqrt = N - 2; int a = 0, b = 0; for (int z = 1; z

Python AttributeError:cos

无人久伴 提交于 2019-12-01 06:20:51
I'm trying to solve numerically an equation using Python2.7. This is the whole code: from sympy import * from sympy import Symbol from sympy.solvers import nsolve from scipy import * from pylab import * import numpy as np # Symbols theta = Symbol('theta') phi = Symbol('phi') phi0 = Symbol('phi0') H0 = Symbol('H0') # Constants a = 0.05 b = 0.05**2/(8*pi*1e-7) c= 0.001/(4*pi*1e-7) phi0 = 60*pi/180 H0 = -0.03/(4*pi*1e-7) def m(theta,phi): return np.array([sin(theta)*cos(phi), sin(theta)*cos(phi), cos(phi)]) def h(phi0): return np.array([cos(phi0), sin(phi0), 0]) def k(theta,phi,phi0): return np

Python AttributeError:cos

故事扮演 提交于 2019-12-01 04:53:24
问题 I'm trying to solve numerically an equation using Python2.7. This is the whole code: from sympy import * from sympy import Symbol from sympy.solvers import nsolve from scipy import * from pylab import * import numpy as np # Symbols theta = Symbol('theta') phi = Symbol('phi') phi0 = Symbol('phi0') H0 = Symbol('H0') # Constants a = 0.05 b = 0.05**2/(8*pi*1e-7) c= 0.001/(4*pi*1e-7) phi0 = 60*pi/180 H0 = -0.03/(4*pi*1e-7) def m(theta,phi): return np.array([sin(theta)*cos(phi), sin(theta)*cos(phi)

How to solve a non-linear equation using nleqslv package in R?

不想你离开。 提交于 2019-11-30 20:41:40
问题 I have this equation to solve (e.g. f(x,y) = 0): library(nleqslv) target <- function(x) { z = x[1]/(x[1]+x[2]) y = numeric(2) y[1] <- z*exp(-x[2]*(x[2]+z*(1-exp(-x[1]/z))))-0.00680 y[2] <- z/x[2]*(1-exp(-x[2]))-exp(-x[2])*z/x[1]*(1-exp(-x[1]))-3.43164 y } # Usage xstart <- c(1,1) target(xstart) nleqslv(xstart, target, control=list(ftol=.0001, allowSingular=TRUE),jacobian=TRUE,method="Newton") using R with nleqslv or another you have others :) Thanks 回答1: I have been experimenting with your

using python to solve a nonlinear equation

送分小仙女□ 提交于 2019-11-30 16:08:50
I have never used python but Mathematica can't handle the equation I am trying to solve. I am trying to solve for the variable "a" of the following equations where s, c, mu, and delta t are known parameters. I tried doing NSolve, Solve, etc in Mathematica but it has been running for an hour with no luck. Since I am not familiar with Python, is there a way I can use Python to solve this equation for a? You're not going to find an analytic solution to these equations because they're transcendental, containing a both inside and outside of a trigonometric function. I think the trouble you're

using python to solve a nonlinear equation

穿精又带淫゛_ 提交于 2019-11-29 23:21:49
问题 I have never used python but Mathematica can't handle the equation I am trying to solve. I am trying to solve for the variable "a" of the following equations where s, c, mu, and delta t are known parameters. I tried doing NSolve, Solve, etc in Mathematica but it has been running for an hour with no luck. Since I am not familiar with Python, is there a way I can use Python to solve this equation for a? 回答1: You're not going to find an analytic solution to these equations because they're