How to limit fsolve to find solution in Real numbers domain

Suppose, If I have some set of non-linear equations. I want to solve those equations with fsolve, but I want solution only in real values not imaginary ones. Is there any way to restrict fsolve in this way?
Thanks in advance

 Accepted Answer

Matt J
Matt J on 24 Aug 2022
Edited: Matt J on 24 Aug 2022
That will automatically be the case, as long as the equation functions you have provided are real-valued.

3 Comments

what I mean is, let us consider a cubic equation. It has one real root and two imaginary roots. If solve the equation it will give real root and imaginary root for different intial values.
I don't want like that.
my need is, for any intial value it should return a real solution only (if the eqn has real solution)
If solve the equation it will give real root and imaginary root for different intial values.
No, that shouldn't happen.
There is no guarantee that fsolve will succeeed in finding a root, but the value it returns should always be real, assuming the cubic polynomial coefficients and the initial guess x0 are real.

Sign in to comment.

More Answers (0)

Categories

Find more on Mathematics in Help Center and File Exchange

Products

Release

R2022a

Asked:

on 24 Aug 2022

Edited:

on 24 Aug 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!