用八度法求解两个非线性方程 [英] Solving two non-linear equations in Octave

查看:168
本文介绍了用八度法求解两个非线性方程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Octave求解以下两个方程式:

I am trying to solve the following two equations using Octave:

eqn1 = (wp/Cwc)^(2*N) - (1/10^(0.1*Ap))-1 == 0;
eqn2 = (ws/Cwc)^(2*N) - (1/10^(0.1*As))-1 == 0;

我使用了以下代码:

syms Cwc N
eqn1 = (wp/Cwc)^(2*N) - (1/10^(0.1*Ap))-1 == 0;
eqn2 = (ws/Cwc)^(2*N) - (1/10^(0.1*As))-1 == 0;
sol = solve(eqn1 ,eqn2, Cwc, N)

wswpAsAp分别表示为1.57080.314160.545.

ws,wp,As, and Ap are given as 1.5708, 0.31416, 0.5, 45 respectively.

但是出现以下错误:

错误:Python异常:NotImplementedError:无法解决
126491*(pi*(3*10**N*sqrt(314311)*pi**(-N)/1223)**(1/N)/2)**(2*N) - 126495
发生在Python代码块的第7行:
d = sp.solve(eqs, *symbols, dict=True)

error: Python exception: NotImplementedError: could not solve
126491*(pi*(3*10**N*sqrt(314311)*pi**(-N)/1223)**(1/N)/2)**(2*N) - 126495
occurred at line 7 of the Python code block:
d = sp.solve(eqs, *symbols, dict=True)

我应该怎么做才能解决这个问题?

What should I do to solve this?

我对方程式做了一些修改.

I modified the equations a little bit.

pkg load symbolic
clear all
syms Cwc N
wp = 0.31416
ws = 1.5708
As = 45
Ap = 0.5
eqn2 = N - log10(((1/(10^(0.05*As)))^2)-1)/2*log10(ws/Cwc) == 0;
eqn1 = N - log10(((1/(10^(0.05*Ap)))^2)-1)/2*log10(wp/Cwc) == 0;
sol = solve(eqn1,eqn2,Cwc,N)

现在我收到此错误:

错误:Python异常:AttributeError:MutableDenseMatrix没有属性is_Relational.
发生在Python代码块的第3行:
if arg.is_Relational:

error: Python exception: AttributeError: MutableDenseMatrix has no attribute is_Relational.
occurred at line 3 of the Python code block:
if arg.is_Relational:

推荐答案

看看方程式,在同一术语的基数中都有未知数,强烈建议没有符号解决方案成立.我为几个符号求解器提供了一个简化的系统(2/x)^y = 4, (3/x)^y = 5,它们都没有得到任何帮助.因此,解决此问题的唯一方法是数字方式(这很有意义,因为您拥有的四个已知参数无论如何都是一些浮点数).为此,倍频程的数值求解器是 fsolve .用法示例:

Looking at the equations, with unknowns in the base and exponent of the same term, highly suggests there is no symbolic solution to be found. I gave a simplified system (2/x)^y = 4, (3/x)^y = 5 to a couple of symbolic solvers, neither of which got anything from it. So, the only way to solve this is numerically (which makes sense because the four known parameters you have are some floating point numbers anyway). Octave's numeric solver for this purpose is fsolve. Example of usage:

function y = f(x)
  Cwc = x(1);
  N = x(2);
  ws = 1.5708;
  wp = 0.31416;
  As = 0.5;
  Ap = 45;
  y = [(wp/Cwc)^(2*N) - (1/10^(0.1*Ap))-1; (ws/Cwc)^(2*N) - (1/10^(0.1*As))-1];
endfunction

fsolve(@f, [1; 1])

(这里[1; 1]是一个初始猜测.)输出是

(Here, [1; 1] is an initial guess.) The output is

0.31413
0.19796

这篇关于用八度法求解两个非线性方程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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