how to find the root of function?

3 ビュー (過去 30 日間)
Ani Asoyan
Ani Asoyan 2021 年 9 月 20 日
回答済み: John D'Errico 2021 年 9 月 20 日
Hi , I want to find the root of nonlinear function, without giving initial point.
here is my .m file for parameters
alpha=0.74
g =0.5
gamma=1.2
sigma=1
phi=0.8
epsilon_1=1.5
w_r= (epsilon_1-1)/epsilon_1
then I made a function like this
function a=n_h_fun(n_h)
a= n_h-(alpha*(w_r/ ((n_h-1)/(g*(1-gamma)))^sigma)^(1/phi))
end
and saved that file as n_h_fun.m
I want to find the value of n_h where a gets the value 0. I used fzero command but it shows errors.
  2 件のコメント
Rik
Rik 2021 年 9 月 20 日
Why don't you want to provide an initial estimate?
Ani Asoyan
Ani Asoyan 2021 年 9 月 20 日
I don't know the exact point

サインインしてコメントする。

採用された回答

Alan Stevens
Alan Stevens 2021 年 9 月 20 日
Like this?
n_h0 = 0.1; %initial guess
n_h = fzero(@n_h_fun, n_h0);
disp(n_h)
0.0107
function a=n_h_fun(n_h)
alpha=0.74;
g =0.5;
gamma = 1.2;
sigma=1;
phi=0.8;
epsilon_1=1.5;
w_r= (epsilon_1-1)/epsilon_1;
a= n_h-(alpha*(w_r/ ((n_h-1)/(g*(1-gamma)))^sigma)^(1/phi));
end
  1 件のコメント
Ani Asoyan
Ani Asoyan 2021 年 9 月 20 日
thank you so much

サインインしてコメントする。

その他の回答 (1 件)

John D'Errico
John D'Errico 2021 年 9 月 20 日
Or do this:
alpha=0.74;
g =0.5;
gamma=1.2;
sigma=1;
phi=0.8;
epsilon_1=1.5;
w_r= (epsilon_1-1)/epsilon_1;
syms n_h
a = n_h-(alpha*(w_r/ ((n_h-1)/(g*(1-gamma)))^sigma)^(1/phi));
pretty(a)
/ 1 \5/4 | - --------------- | 37 \ (10 n_h - 10) 3 / n_h - --------------------------- 50
So a is a simple nonlinear function of n_h.
% first, plot it. ALWAYS PLOT EVERYTHING
fplot(a,[-20,20])
grid on
vpasolve(a,n_h)
ans = 
0.010682191712647594755165531568215
So vpasolve found the root near zero for n_h. There may be other solutions, but when n_h is negative, it looks like that curve goes to -inf almost linearly. We can probably show that to be true. And for positive values of n_h, above some point, it looks like a becomes complex. So the only real solution is probably the one found by vpasolve.

カテゴリ

Help Center および File ExchangeChemistry についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by