equation-solving

Grouping like terms in MATLAB

左心房为你撑大大i 提交于 2019-12-23 03:06:59
问题 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. 回答1: 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

Finding real roots of quartic equation using ferrari's method

非 Y 不嫁゛ 提交于 2019-12-21 21:10:52
问题 I am currently trying to solve a quartic equation using Ferrari's method from Wikipedia. I want to retrieve only the real roots, discarding the imaginary one. My implementation does not return the good value for real roots. I can't find the mistakes in the formula. My CubicEquation works as expected, and my bi-quadratic solving either. Now, I am only missing the Ferrari's method to be done but I can't make it work! Here's my class: public class QuarticFunction { private final double a;

Find positive solutions to underdetermined linear system of equations

大城市里の小女人 提交于 2019-12-19 03:31:14
问题 I'm a bit new to matlab so sorry if this is horribly simple. Consider a problem of the following: Find x_1, x_2, x_3 > 0 such that 67.5 = 60*x_1 + 90*x_2 + 120*x_3 and 60 = 30*x_1 + 120*x_2 + 90*x_3 In this case I want the solution 0 < x_3 < 3/7, x_2 = 7/20 - 4/10*x_3, and x_1 = 2/5 - 7/5*x_3 Is there a easy way to make Matlab solve such a problem for me? 回答1: The easy answer, since you just need non-negativity constraints on the parameters, is to use lsqnonneg. lsqlin is not needed at all

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 = (

MATLAB: MEX matrix division gives different result than m-file

陌路散爱 提交于 2019-12-12 18:41:43
问题 I've used MATLAB's coder tool to create a MEX version of the matrix exponential function, to be used in another set of functions. The issue is, the MEX version gives different results than the original m-file. After debugging it, I believe that the reason this is, is because the MEX file and the m-file do not do matrix division (\) the same. Or the MEX file has issues with it in the first place. All the variables leading up to the line where the matrix division occurs are equivalent on both

Solving linear equations w. three variables using numpy [duplicate]

只愿长相守 提交于 2019-12-11 13:09:39
问题 This question already has answers here : Is there a python module to solve linear equations? (6 answers) Closed 3 years ago . I'm currently in need of a class, which must be able to display and solve an equation system like this one: | 2x-4y+4z=8 | | 34x+3y-z=30 | | x+y+z=108 | I thought it would be a good idea to write a class to transform the left-side things of the eqation system into a matrix-like object, here is the self-made-matrix for this system: /2 -4 4\ |34 3 -1| \1 1 1/ I have

Solving two non-linear equations in Octave

烈酒焚心 提交于 2019-12-11 10:17:30
问题 I am trying to solve the following two equations using Octave: eqn1 = (wp/Cwc)^(2*N) - (1/10^(0.1*Ap))-1 == 0; eqn2 = (ws/Cwc)^(2*N) - (1/10^(0.1*As))-1 == 0; I used the following code: syms Cwc N eqn1 = (wp/Cwc)^(2*N) - (1/10^(0.1*Ap))-1 == 0; eqn2 = (ws/Cwc)^(2*N) - (1/10^(0.1*As))-1 == 0; sol = solve(eqn1 ,eqn2, Cwc, N) ws , wp , As , and Ap are given as 1.5708 , 0.31416 , 0.5 , 45 respectively. But I am getting the following error: error: Python exception: NotImplementedError: could not

Plot solution of second order equation in MATLAB

故事扮演 提交于 2019-12-11 07:28:31
问题 Could you please help me with the following question: I want to solve a second order equation with two unknowns and use the results to plot an ellipse. Here is my function: fun = @(x) [x(1) x(2)]*V*[x(1) x(2)]'-c V is 2x2 symmetric matrix, c is a positive constant and there are two unknowns, x1 and x2 . If I solve the equation using fsolve, I notice that the solution is very sensitive to the initial values fsolve(fun, [1 1]) Is it possible to get the solution to this equation without

How to solve a symbolic system of equations in Matlab

☆樱花仙子☆ 提交于 2019-12-11 04:47:19
问题 I know it has to be a stupid error,but I really can't solve a system of this type: b = a2*cos(q1 + q2) + a1*cos(q1) a2*sin(q1 + q2) + a1*sin(q1) d1 + d4 + q3 >> solve(b,[q1,q2,q3,q4]) Warning: The solutions are parametrized by the symbols: z1 = C_ > In solve at 190 ans = a1: [1x1 sym] d1: [1x1 sym] d4: [1x1 sym] q1: [1x1 sym] q2: [1x1 sym] q3: [1x1 sym] q4: [1x1 sym] basically I want my program to see a1,d1,d4 as parameters and q1,q2,q3,q4 as variables. that's why I call solve(b,[q1,q2,q3,q4]

Scipy - Non-linear Equations System with linear constraints (beginner)

别等时光非礼了梦想. 提交于 2019-12-10 12:02:11
问题 I have seen this amazing example. But I need to solve system with boundaries on X and F, for example: f1 = x+y^2 = 0 f2 = e^x+ xy = 0 -5.5< x <0.18 2.1< y < 10.6 # 0.15< f1 <20.5 - not useful for this example # -10.5< f2 < -0.16 - not useful for this example How could I set this boundary constrains to fsolve() of scipy? Or may be there is some other method? Would You give me a Simple code example? 回答1: It depends on the system, but here you can simply check the constraints afterwards. First