使用Matlab/Maple查找非线性方程的根 [英] Use Matlab/Maple to find roots of a nonlinear equation

查看:178
本文介绍了使用Matlab/Maple查找非线性方程的根的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很难找到非线性方程的根.我已经尝试过Matlab和Maple两者,并且都给了我相同的错误,即

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

等式如下

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

等式中的变量为H.

如何找到该方程式的根(或近似根)?

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

Matlab代码: 功能文件:

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);`

主文件:

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

XY = 0;
ZY = 0;

XB = 50;
ZB = -2;

XZ = 100;
ZZ = 0;

ql = 40;

Matlab显示的错误:

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/

推荐答案

您不需要使用符号工具箱:

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);

第二步,创建一个向量,然后将其插入方程式中,以大致找到函数的符号何时变化.最后,使用 fzero x0作为第二个输入参数.

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

要验证:

您可能想查看此问题有关如何查找非多项式根的更多信息.

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

这篇关于使用Matlab/Maple查找非线性方程的根的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆