## Numerical solution of a matlab function.

### HINA (view profile)

on 8 Apr 2019
Latest activity Commented on by HINA

on 8 Apr 2019

### Alex Mcaulley (view profile)

Hello everyone,
I am trying to solve the following function for the variable P by using ''feval'' , ''fsolve'' and ''fzero'' but unable to get the root or if get the solution it is zero while I am looking for a non-zero solution to this function. Are there better methods available?
I will highly appreciate if anyone guide me how to solve this function for a non-zero solution. (Important to note that function is of type F(P)=0). and P>0
F =
function_handle with value:
@(P)sin(sqrt(2.0).*sqrt(-P./(P.*1.34217728e+8-2.863311530666667e+15)).*4.096e+5).*cosh(sqrt(P).*1.0./sqrt(P.*6.7108864e+7-2.796202666666667e+15).*4.096e+5).*sqrt(-P./(P.*6.7108864e+7-2.796202666666667e+15)).*-8.192e+3+sqrt(2.0).*cosh(sqrt(2.0).*sqrt(P).*1.0./sqrt(P.*1.34217728e+8-2.863311530666667e+15).*4.096e+5).*sin(sqrt(-P./(P.*6.7108864e+7-2.796202666666667e+15)).*4.096e+5).*sqrt(-P./(P.*1.34217728e+8-2.863311530666667e+15)).*8.192e+3

on 8 Apr 2019
Isn't this similar to your previous question?
John D'Errico

### John D'Errico (view profile)

on 8 Apr 2019
Identical. with only the plaintive complaint that HINA does not want to need to pose a starting value, and that the solver should magically know which of infinitely many solutions it should find, when some of those solutions lie extremely far out.

on 8 Apr 2019
Ah , thank you John’s D’Errico.

R2019a

### Alex Mcaulley (view profile)

on 8 Apr 2019

Try changing the interval
fplot(F,[0,1e7])
Then, you can use:
fzero(F,1e5)
ans =
9.6575e+05

### John D'Errico (view profile)

on 8 Apr 2019

This is just a continuation of the last time the same question was asked, and answered.
There are other roots, but they lie out very far, on the order of 1e6 or 3e6. In fact, there are probably infinitely many roots as a guess, based on the plots I did.
A numerical rootfinder (like vpasolve, or fzero, for that matter) requires an initial guess at the solution. No guess, no answer. Since there are infinitely many solutions to this problem, if you give no guess at all, then a tool like vpasolve is at least nice enough to guess zero to start at. (I think that is the default.) This means it will find the solution at P==0, since that just happens to be a solution.
Other solvers, thus if you convert the expression to a function using matlabFunction, then you can use fzero or fsolve? These solvers REQUIRE a starting value. They will fail if none is provided. Sorry, but that is how things work.
Anyway, if you want to find other solutions than that at P==0, you need to tell the code where to start looking. The example I give is if you set a blind man down on the surface of the earth, and told him to find the lowest point in elevation. If you start him out in the vicinity of the Dead Sea, do you seriously expect him to wander around until he finds the bottom of the Marianas trench? In fact, he will find the bottom of the Dead Sea. Or, how about if you start him out in the Himalayas?
A solver NEEDS an intelligent start point. If you don't give it that, expect arbitrary garbage. What do you expect when you have a function with infinitely many solutions? Which one should it give you, since it will give you only one?
It is often a good idea to plot your function to gain some intelligence. But that is EXACTLY what I did the last time I answered your question.

HINA

### HINA (view profile)

on 8 Apr 2019
Thanking alot for all this description and I am highly grateful for all the suggestons given here. Yes, It is the same question which you answered me for the last time and I tried with vpasolve alot by using diffrent initial guess. The problem that I am facing here is that I have to change different initial parameters to get different plots but everytime with different initial guess I am unable to get the appropriate solutions. Thats the reason I switch from vpasolve to some function solver.