equation-solving

Grouping like terms in MATLAB

坚强是说给别人听的谎言 提交于 2019-12-07 08:00:30
I'm trying to code a program that solves systems of equations in MATLAB. I was wondering if there is a way to get MATLAB to group like terms and put their coefficients into a matrix? I realize that I can just enter the coefficients in by hand but I want to hopefully repurpose this small program to perform nodal analysis. You could always use my sympoly tools to do much of the work for you. Since this set of tools will give you direct access to the parsed result, this will make your life easier, as well as do much symbolic manipulation of an expression. For example... >>sympoly x y z >> P = 3*x

Solve indeterminate equation system in R

柔情痞子 提交于 2019-12-06 08:47:43
问题 I have a equation system and I want to solve it using numerical methods. I want to get a close solution given a starting seed. Let me explain. I have a vector of constants , X , of values: X <- (c(1,-2,3,4)) and a vector W of weights: W <- (c(0.25,0.25,0.25,0.25)) I want that the sum of the components of W will be ( sum(W)=1 ), and the sum of the multiplication of X and W element by element will be a given number N ( sum(W*X)=N ). Is there a easy way to do this in R? I have it in Excel, using

Solving a system of transcendental equations with python

情到浓时终转凉″ 提交于 2019-12-06 07:01:42
问题 Assuming I have the following four equations: cos(x)/x = a cos(y)/y = b a + b = 1 c sinc(x) = d sinc(y) for unknown variables x, y, a and b . Note that cos(x)/x=a has multiple solutions. Similar goes for variable y . I am only interested in x and y values, which are first positive roots (if that matters). You can safely assume a, b, c and d are known real constants, all positive. In Mathematica the code to solve this would look something like: FindRoot[{Cos[x]/x == 0.2 a + 0.1, Cos[y]/y == 0

Equation Threading: Why the default behavior?

会有一股神秘感。 提交于 2019-12-05 12:52:34
问题 I recently rediscovered a small package by Roman Maeder that tells Mathematica to automatically thread arithmetic and similar functions over expressions such as x == y. Link to Maeder's package. First, to demonstrate, here's an example given by Maeder: In[1]:= Needs["EqualThread`"] Now proceed to use the threading behavior to solve the following equation for x 'by hand': In[7]:= a == b Log[2 x] In[8]:= %/b Out[8]:= a/b == Log[2 x] Now exponentiate: In[9]:= Exp[%] Out[9]= E^(a/b) == 2 x And

Fastest method to solve multiple nonlinear independent equations in MATLAB? [closed]

谁说胖子不能爱 提交于 2019-12-05 02:55:47
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 12 months ago . MATLAB has two methods to solve a nonlinear equation: fzero: solves a single nonlinear equation fsolve: solves a system of nonlinear equations Therefore, one can use the following methods to solve a system of n nonlinear independent equations: Use a loop to solve the equations

Matlab Solve System of Equations with Quantized Variables

拟墨画扇 提交于 2019-12-04 18:38:18
I am trying to use solve() to solve a system of equations of the following form eq1=a1x+a2y; eq2=b1x+b2y; where a1 = .05 for values of x<5 , .1 for values of 5 Is there a way to solve for this using solve? As in sol = solve(eq1,eq2); I'm not sure what you're trying to do here. Can you please post a real example (with numbers) and what you would like the output to be? I think you're trying to solve linear simultaeneous equations. Assuming that is what you are trying to do: I would suggest multiplying all of your equations by 20, so that your minimum quanta size of 0.05 becomes 1.00 . Your

Solving a system of transcendental equations with python

久未见 提交于 2019-12-04 12:03:15
Assuming I have the following four equations: cos(x)/x = a cos(y)/y = b a + b = 1 c sinc(x) = d sinc(y) for unknown variables x, y, a and b . Note that cos(x)/x=a has multiple solutions. Similar goes for variable y . I am only interested in x and y values, which are first positive roots (if that matters). You can safely assume a, b, c and d are known real constants, all positive. In Mathematica the code to solve this would look something like: FindRoot[{Cos[x]/x == 0.2 a + 0.1, Cos[y]/y == 0.2 b + 0.1, a + b == 1.0, 1.03*Sinc[x] == Sinc[y]*1.02}, {{x, .1}, {y, .1}, {a, .3}, {b, .1}}] which as

Solve indeterminate equation system in R

心已入冬 提交于 2019-12-04 11:49:16
I have a equation system and I want to solve it using numerical methods. I want to get a close solution given a starting seed. Let me explain. I have a vector of constants , X , of values: X <- (c(1,-2,3,4)) and a vector W of weights: W <- (c(0.25,0.25,0.25,0.25)) I want that the sum of the components of W will be ( sum(W)=1 ), and the sum of the multiplication of X and W element by element will be a given number N ( sum(W*X)=N ). Is there a easy way to do this in R? I have it in Excel, using Solver, but I need to automatize it. Here is your constant and your target value: x <- c(1, -2, 3, 4)

Equation Threading: Why the default behavior?

喜你入骨 提交于 2019-12-03 23:39:55
I recently rediscovered a small package by Roman Maeder that tells Mathematica to automatically thread arithmetic and similar functions over expressions such as x == y. Link to Maeder's package. First, to demonstrate, here's an example given by Maeder: In[1]:= Needs["EqualThread`"] Now proceed to use the threading behavior to solve the following equation for x 'by hand': In[7]:= a == b Log[2 x] In[8]:= %/b Out[8]:= a/b == Log[2 x] Now exponentiate: In[9]:= Exp[%] Out[9]= E^(a/b) == 2 x And divide through by 2: In[10]:= %/2 Out[10]= (E^(a/b))/2 == x Q: From a design perspective, can someone

What good libraries are there for solving a system of non-linear equations in C++?

﹥>﹥吖頭↗ 提交于 2019-12-03 12:34:38
问题 In a C++ application I'm coding, I need to solve a system of non -linear equations (N equations, N unknowns). The systems I'm solving will be rather small (up to 10 equations/unknowns), so performance is not going to be a real issue. I've searched the web a bit for a non-linear solver library, and I couldn't get to something which looks easy to use (got to NOX and C/C++ Minpack, but both seem to be an overkill for my need). Any thoughts and ideas of easy-to-use libraries for this purpose? 回答1