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

2 次查看（过去 30 天）
Miraboreasu2022-6-4

```
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 个）

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