# Solving nonlinear function using fzero, Error Function values at the interval endpoints must differ in sign.

3 ビュー (過去 30 日間)
Miraboreasu 2022 年 6 月 4 日
コメント済み: Sam Chak 2022 年 6 月 5 日
```
Imp=100;
t0=1e-6;
P=204000000;
Tf=2e-3;
x = fzero( @(x) myfunction(x, t0, Imp, P, Tf), [1.001, 10000]);
function [f] = myfunction( x, t0, Imp, P0, Tf)
f = Imp - (-(P0*t0*(x-1.0)*(x^(-Tf/(t0*(x-1.0)))-1.0))/(log(x)*(x^(-1.0/(x-1.0)) -x^(-x/(x-1.0))))+(P0*t0*(x^(-(Tf*x)/(t0*(x-1.0)))-1.0)*(x-1.0))/(x*log(x)*(x^(-1.0/(x-1.0))-x^(-x/(x-1.0)))));
end
```
x must bigger than 1.0
I don't think these input will make fzero suffer
thank you
##### 4 件のコメント表示非表示 3 件の古いコメント
Sam Chak 2022 年 6 月 5 日
Once you have found the root of nonlinear function, can you verify if the solution really crosses 0?
Imp = 100;
t0 = 1e-6;
P0 = 204000000;
Tf = 2e-3;
f = @(x) Imp - (-(P0*t0*(x-1.0)*(x^(-Tf/(t0*(x-1.0)))-1.0))/(log(x)*(x^(-1.0/(x-1.0)) -x^(-x/(x-1.0))))+(P0*t0*(x^(-(Tf*x)/(t0*(x-1.0)))-1.0)*(x-1.0))/(x*log(x)*(x^(-1.0/(x-1.0))-x^(-x/(x-1.0)))));

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

### 回答 (1 件)

Lateef Adewale Kareem 2022 年 6 月 4 日
Imp=100;
t0=1e-6;
P=204000000;
Tf=2e-3;
x = nan;
options = optimset('Display','off'); % show iterations
x0 = 2;
while(isnan(x))
x = fzero( @(x) myfunction(x, t0, Imp, P, Tf), x0, options);
x0 = x0*1.2;
end
disp(['x = ', num2str(x)])
x = 1.762566874060497e+21
function [f] = myfunction( x, t0, Imp, P0, Tf)
f = Imp - (-(P0*t0*(x-1.0)*(x^(-Tf/(t0*(x-1.0)))-1.0))/(log(x)*(x^(-1.0/(x-1.0)) -x^(-x/(x-1.0))))+(P0*t0*(x^(-(Tf*x)/(t0*(x-1.0)))-1.0)*(x-1.0))/(x*log(x)*(x^(-1.0/(x-1.0))-x^(-x/(x-1.0)))));
end

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

### カテゴリ

Find more on Surrogate Optimization in Help Center and File Exchange

R2021b

### Community Treasure Hunt

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

Start Hunting!

Translated by