The basics of fsolve

  Рет қаралды 19,813

Dr Gregory Reeves

Dr Gregory Reeves

5 жыл бұрын

In this screencast, we discuss the basics of Matlab's function fsolve, which can be used to solve systems of non-linear equations.

Пікірлер: 29
@vjdipchan6436
@vjdipchan6436 5 жыл бұрын
Thank you for your in-depth demonstration of the fsolve function. Much appreciated!
@danielgladstone1789
@danielgladstone1789 3 жыл бұрын
Interesting haha
@LaraxWarrior3
@LaraxWarrior3 3 жыл бұрын
Thank you
@danielt.plazas5401
@danielt.plazas5401 4 жыл бұрын
Thank you Dr Gregory Reeves! Do you know if there is any way to find all the roots of a system in which there is, for example, an equation with two unknowns? Of course in a finite range.
@drgregoryreeves
@drgregoryreeves 4 жыл бұрын
Sorry for the slow reply. In general, there is no way to do that, as far as I know. For some kinds of equations, you can be sure about all the roots (if the equations are polynomials, for example). But non-linear equations might not have any roots, and you wouldn't know that. Also, within a finite range that you specify, you might not be in the right range. For one equation with two unknowns, though, then you have an underspecified system. You'd need either another equation, or you'd need to specify one of your unknowns. If you have enough computing power, and you want to be very sure, you can always plot the equation for many values of your unknown within your finite range, and see how many times it crosses the x-axis. You can usually be pretty sure your equation is "smooth", so that you won't be missing any roots as long as you have a high enough density of points. This is a very brute force method, so it's very slow.
@jabbamafmgeneralenterprise499
@jabbamafmgeneralenterprise499 2 жыл бұрын
Up dad's ok Sid 😜 don't mind 😊😊 dude do dinner 🍽️🍽️🍽️🍽️🍽️🍽️ I can 😂😂😂😂😂😂😂😂 up 😜🐱🐱🐱🐱 I can I can help
@jabbamafmgeneralenterprise499
@jabbamafmgeneralenterprise499 2 жыл бұрын
U dey up for me up 😅☺️ up in my head is not 🚫🚫
@jabbamafmgeneralenterprise499
@jabbamafmgeneralenterprise499 2 жыл бұрын
U dey up for me up 😅☺️ up in my head is not 🚫🚫
@jabbamafmgeneralenterprise499
@jabbamafmgeneralenterprise499 2 жыл бұрын
U dey e for
@sefaarslan1488
@sefaarslan1488 2 жыл бұрын
I have a system with 10 equations and 8 unknowns, how can I solve these equation sets?
@GregReeves1520
@GregReeves1520 2 жыл бұрын
If you have an overdetermined system, fsolve can still work with it, but it will try to do some sort of optimization to get the best fit values of your unknown that minimizes your 10 equations in some way. I am not 100% sure how that works, since I've only tried to use fsolve with square systems. Are you trying to do an optimization problem?
@sefaarslan1488
@sefaarslan1488 2 жыл бұрын
@@GregReeves1520 no, I'm dealing with trim analysis of an aircraft in forward flight and trying to find the unknowns from dynamic equations. Thanks for your reply I will try f solve first
@saddamhussainsoomro2810
@saddamhussainsoomro2810 4 жыл бұрын
Sir can you help me for 12 non linear equations with 12 variables, or guide anything please. Thanks
@GregReeves1520
@GregReeves1520 4 жыл бұрын
Hi, happy to help. Can you clarify? Are you running into problems that are not helped by this video? fsolve can, in principle, handle a 12x12 system, but it may be difficult and you might need to use a very good initial guess. Have you already tried to program a script and function to use fsolve on your system? What did you find? Was there a particular error?
@saddamhussainsoomro2810
@saddamhussainsoomro2810 4 жыл бұрын
@@GregReeves1520 yes sir I tried using fsolve. That shows error. The equation not solved! I also tried Newton raphson method but the roots are coming to be same as my initial guesses.
@GregReeves1520
@GregReeves1520 4 жыл бұрын
@@saddamhussainsoomro2810 If you have already taken the time to write a Newton's method code to solve the problem, I would focus on that. So you wrote a while loop that quits when either "f" or "delta_x" (or both) become small (say, 1e-6). In each iteration of the loop, you need to evaluate "f", calculate the Jacobian "J", then take a newton step of "delta_x = -J \ f; x = x + delta_x;" Correct? How many iterations are happening in the while loop? If your solution is the same as your initial guess, then my guess is that either you are not entering the while loop correctly, or within the while loop, you are not updating your value of x. Thoughts?
@saddamhussainsoomro2810
@saddamhussainsoomro2810 4 жыл бұрын
@@GregReeves1520 sir can you send me email I will send you my code
@drgregoryreeves
@drgregoryreeves 4 жыл бұрын
@@saddamhussainsoomro2810 I am not planning on posting my email publicly here, but you can google me, and you can probably find me on an NC State website.
@criccenter9619
@criccenter9619 3 жыл бұрын
How can I plot (X,Y) When X=-3:0.1:3; Y=X² + 3*Y - exp(X-2*Y);
@drgregoryreeves
@drgregoryreeves 3 жыл бұрын
You can convert your equation to the form f(X) = 0 by moving the lone Y on the LHS to the RHS. Then, in that form, you can run a for loop to use fzero to solve for Y for every X in your mesh. Alternatively, you could use fsolve once instead of fzero in a for loop...that might work too. Let me know if you have other questions. Once you have a value of Y for every value of X, you can plot(X,Y).
@criccenter9619
@criccenter9619 3 жыл бұрын
@@drgregoryreeves x=[-3:0.05:3]; n = size(x,1); yy=zeros(n,1); for i=1:n yy(i)=fsolve(@(y) fun(x(i),y),0); end plot(x,yy) function S=fun(x,y) S=X²+3*Y-exp(X-2*Y) end I used still unable to get answer please suggest your code more precisely
@drgregoryreeves
@drgregoryreeves 3 жыл бұрын
​@@criccenter9619, when you say "unable to get answer", does that mean you can't get any kind of solution? Or is it that you are not getting the solution you expect? Because your code looks good, syntax-wise. The only thing is that in your first post, you had a "Y" on the LHS of your equation, but that "Y" is gone in your second post. If the first post is correct, you should move that "Y" from the LHS to the RHS, so it appears as a "-Y" in the RHS of the "S" equation in your function. Did that help? Let me know!
@criccenter9619
@criccenter9619 3 жыл бұрын
@@drgregoryreeves I am sorry I made mistake in editing there S=Y-(X² + 3*Y - exp(X-2*Y)); I wasn't able to get anything on plot .Nothing except the axis. Please provide your solution if u don't mind.
@drgregoryreeves
@drgregoryreeves 3 жыл бұрын
@@criccenter9619 It sounds like your equation didn't converge, and you got a bunch of NaN's for your elements in the "yy" vector. Can you double check that?
Using fsolve to solve non-linear equations
11:38
Dr Gregory Reeves
Рет қаралды 47 М.
Solving Equations with MATLAB using fsolve
21:17
purdueMET
Рет қаралды 7 М.
3M❤️ #thankyou #shorts
00:16
ウエスP -Mr Uekusa- Wes-P
Рет қаралды 15 МЛН
Scary Teacher 3D Nick Troll Squid Game in Brush Teeth White or Black Challenge #shorts
00:47
Survival skills: A great idea with duct tape #survival #lifehacks #camping
00:27
Smart Sigma Kid #funny #sigma #comedy
00:25
CRAZY GREAPA
Рет қаралды 27 МЛН
Basics of Matlab's ode suite
10:42
Dr Gregory Reeves
Рет қаралды 948
Using fsolve with parameters
8:32
Dr Gregory Reeves
Рет қаралды 14 М.
MATLAB Solvers
8:25
LearnChemE
Рет қаралды 95 М.
Model Predictive Control
12:13
Steve Brunton
Рет қаралды 249 М.
MATLAB Nonlinear Optimization with fmincon
14:26
APMonitor.com
Рет қаралды 238 М.
Solving Heat equation PDE using Explicit method in Python
15:38
Shameel Abdulla
Рет қаралды 45 М.
Learn To Code Like a GENIUS and Not Waste Time
9:41
The Coding Sloth
Рет қаралды 1,3 МЛН
3M❤️ #thankyou #shorts
00:16
ウエスP -Mr Uekusa- Wes-P
Рет қаралды 15 МЛН