Use Matlab/Maple to find roots of a nonlinear equa

2019-09-06 06:06发布

问题:

I am having difficulty in finding roots of a nonlinear equation. I have tried Matlab and Maple both, and both give me the same error which is

Error, (in RootFinding:-NextZero) can only handle isolated zeros

The equation goes like

-100 + 0.1335600000e-5*H + (1/20)*H*arcsinh(2003.40/H)

The variable is H in the equation.

How do I find the roots (or the approximate roots) of this equation?

Matlab Code: The function file:

function hor_force = horizontal(XY, XZ, Lo, EAo, qc, VA)
syms H
equation = (-1*ZZ) + (H/qc)*(cosh((qc/H)*(XZ- XB))) - H/qc + ZB;
hor_force = `solve(equation);`

The main file:

EAo = 7.5*10^7;
Lo = 100.17;
VA = 2002;

XY = 0;
ZY = 0;

XB = 50;
ZB = -2;

XZ = 100;
ZZ = 0;

ql = 40;

Error which Matlab shows:

Error using sym/solve (line 22)
Error using maplemex
Error, (in RootFinding:-NextZero) can only handle isolated zeros

Error in horizontal (line 8)
hor_force = solve(equation);
Error in main (line 34)
h = horizontal(XY, XZ, Lo, EAo, ql, VA)

http://postimg.org/image/gm93z3b7z/

回答1:

You don't need the symbolic toolbox for this:

First, create an anonymous function that can take vectors at input (use .* and ./:

equation = @(H) ((-1*ZZ) + (H./qc).*(cosh((qc./H).*(XZ- XB))) - H./qc + ZB);

Second, create a vector that you afterwards insert into the equation to find approximately when the sign of the function changes. In the end, use fzero with x0 as the second input parameter.

H = linspace(1,1e6,1e4);  
x0 = H(find(diff(sign(equation(H)))));  %// Approximation of when the line crosses zero
x = fzero(equation, x0)  %// Use fzero to find the crossing point, using the initial guess x0
x =    
   2.5013e+04
equation(x)
ans =
     0

To verify:

You might want to check out this question for more information about how to find roots of non-polynomials.



回答2:

In Maple, using the expression from your question,

restart:

ee := -100 + 0.1335600000e-5*H + (1/20)*H*arcsinh(2003.40/H):

Student:-Calculus1:-Roots(ee, -1e6..1e6);

            [               5                           ]
            [-1.240222868 10 , -21763.54830, 18502.23816]

#plot(ee, H=-1e6..1e6, view=-1..1);