nonlinear-functions

Solve system of non-linear equations

ε祈祈猫儿з 提交于 2021-02-10 10:54:30
问题 I am trying to solve the following system of four equations. I have tried using the "rootSolve" package but it does not seem like I can find a solution this way. The code I am using is the following: model <- function(x) { F1 <- sqrt(x[1]^2 + x[3]^2) -1 F2 <- sqrt(x[2]^2 + x[4]^2) -1 F3 <- x[1]*x[2] + x[3]*x[4] F4 <- -0.58*x[2] - 0.19*x[3] c(F1 = F1, F2 = F2, F3 = F3, F4 = F4) } (ss <- multiroot(f = model, start = c(0,0,0,0))) But it gives me the following error: Warning messages: 1: In stode

How to solve nonlinear equations using a for loop in python?

最后都变了- 提交于 2021-02-08 11:45:27
问题 I am trying to solve for non linear equations in python. I have tried using the solver of the Sympy but it doesn't seem to work in a for loop statement. I am tyring to solve for the variable x over a range of inputs [N] . I have attached my code below import numpy as np import matplotlib.pyplot as plt from sympy import * f_curve_coefficients = [-7.14285714e-02, 1.96333333e+01, 6.85130952e+03] S = [0.2122, 0, 0] a2 = f_curve_coefficients[0] a1 = f_curve_coefficients[1] a0 = f_curve

solving colebrook (nonlinear) equation in python

爱⌒轻易说出口 提交于 2020-12-06 04:21:10
问题 I want to do in python what this guy did in MATLAB. I have installed anaconda, so i have numpy and sympy libraries. So far I have tried with numpy nsolve, but that doesn't work. I should say I'm new with python, and also that I konw how to do it in MATLAB :P. The equation: -2*log(( 2.51/(331428*sqrt(x)) ) + ( 0.0002 /(3.71*0.26)) ) = 1/sqrt(x) Normally, I would solve this iteratively, simply guessing x on the left and than solving for the x on the right. Put solution on the left, solve again.

I don't know hot to plot this nonlp's feasible reagion in matlab

非 Y 不嫁゛ 提交于 2020-01-02 07:40:16
问题 I searched and watched how to plot the 3 dimensions of nonlp program's but I still don't know how to plot these constraints. x^2+y^2+z^2=1 x>=2*y 2*y>=3*z x>=3*z I programmed like this but it doesn't work and I think this is wrong program for upper constraints. func1 = @(x,y,z) sqrt(1-x.^2-y.^2); func2 = @(x,y,z) max(x-2*y,0); func3 = @(x,z) max(x-3*z,0); ezsurf(func1,[0 1 0 1]); hold on; ezsurf(func2,[0 1 0 1]); hold on; ezsurf(func3,[0 1 0 1]); axis([0 1 0 1 0 1]); 回答1: A way of doing that

Cobb-Douglas functions slows running tremendously. How to expedite a non-linear calculation in Python?

ぃ、小莉子 提交于 2019-12-25 01:09:00
问题 I have a working microeconomic model running with 10 modules 2000 agents, for up to 10 years. The program was running fast, providing results, output and graphics in a matter of seconds. However, when I implemented a non-linear Cobb-Douglas production function to update the quantity to be produced in the firms, the program slowed to produce results in 3 minutes, depending on the parameters. Does anybody know how I could expedite the calculation and get back to fast results? Here is the code

Fitting non-linear Langmuir Isotherm in R

◇◆丶佛笑我妖孽 提交于 2019-12-21 21:33:58
问题 I want to fit Isotherm models for the following data in R. The simplest isotherm model is Langmuir model given here model is given in the bottom of the page. My MWE is given below which throw the error. I wonder if there is any R package for Isotherm models. X <- c(10, 30, 50, 70, 100, 125) Y <- c(155, 250, 270, 330, 320, 323) Data <- data.frame(X, Y) LangIMfm2 <- nls(formula = Y ~ Q*b*X/(1+b*X), data = Data, start = list(Q = 1, b = 0.5), algorith = "port") Error in nls(formula = Y ~ Q * b *

Splines inside nonlinear least squares in R

自闭症网瘾萝莉.ら 提交于 2019-12-21 05:12:07
问题 Consider a nonlinear least squares model in R, for example of the following form): y ~ theta / ( 1 + exp( -( alpha + beta * x) ) ) (my real problem has several variables and the outer function is not logistic but a bit more involved; this one is simpler but I think if I can do this my case should follow almost immediately) I'd like to replace the term "alpha + beta * x" with (say) a natural cubic spline. here's some code to create some example data with a nonlinear function inside the

Solve this equation with fixed point iteration

╄→尐↘猪︶ㄣ 提交于 2019-12-21 04:04:15
问题 How can I solve this equation x 3 + x - 1 = 0 using fixed point iteration? Is there any fixed-point iteration code (especially in Python) I can find online? 回答1: Using scipy.optimize.fixed_point: import scipy.optimize as optimize def func(x): return -x**3+1 # This finds the value of x such that func(x) = x, that is, where # -x**3 + 1 = x print(optimize.fixed_point(func,0)) # 0.682327803828 The Python code defining fixed_point is in scipy/optimize/minpack.py. The exact location depends on

Use Matlab/Maple to find roots of a nonlinear equation

本小妞迷上赌 提交于 2019-12-13 20:15:13
问题 I am having difficulty in finding roots of a nonlinear equation. I have tried Matlab and Maple both, and both give me the same error which is Error, (in RootFinding:-NextZero) can only handle isolated zeros The equation goes like -100 + 0.1335600000e-5*H + (1/20)*H*arcsinh(2003.40/H) The variable is H in the equation. How do I find the roots (or the approximate roots) of this equation? Matlab Code: The function file: function hor_force = horizontal(XY, XZ, Lo, EAo, qc, VA) syms H equation = (

plotting lrc in SSasymp in R

╄→гoц情女王★ 提交于 2019-12-13 03:39:55
问题 My question is similar to the unanswered here: working with SSasymp in r For a simple SSmicmen: x1 = seq (0,10,1) y1 = SSmicmen(x1, Vm=10, K=0.5) plot(y1 ~ x1, type="l") the value of K is easily identified in the point (5, 0.5), the value of half the maximum growth. Given a simple SSasympOrig: x2 = seq (0,10,1) y2 = SSasympOrig(x2, Asym=10, lrc=0.1) # Asym*(1 - exp(-exp(lrc)*input)) plot(y2 ~ x2, type="l") is there a way to represent and/or identify the meaning and/or effect of the parameter