If any one find this question answerable or understandable please do respond or the just give an idea of what are those values whih are so complex by look.
My question is what is the value i am getting as the output of my code.
1 回表示 (過去 30 日間)
古いコメントを表示
syms x
eqn = 0.5959 + 0.0321*(x^2.1)-0.184*(x^8)+0.0143*(x^2.5)-0.2359*(sqrt((1-x^4)/x^4));
solve(eqn == 0,x)
the results are given as
3 件のコメント
VBBV
2024 年 8 月 2 日
@Varun You could alternately use fsolve for the expression and solve it for defined initial value limits. Note that your equation/ function involves a term ((sqrt((1-x.^4)./x.^4))) which can potentially cause the result into a indefinite value. Hence, the initial value need to be more specific to solve this type of equation.
x0 = [0.01 1] % give an initial value excluding 0 !!!
eqn = @(x) 0.5959 + 0.0321*(x.^2.1)-0.184*(x.^8)+0.0143*(x.^2.5)-0.2359*(sqrt((1-x.^4)./x.^4));
options = optimoptions('fsolve','Display','iter'); % ^
[x] = fsolve(eqn,x0,options)
real(x)
採用された回答
Arnav
2024 年 8 月 2 日
The result that you are getting is a closed form way of representing the solution of the equation. Here root(P(x),x,k) represents the kth root of the symbolic polynomial P(x). You can evaluate these roots numerically using the function vpa as follows:
syms x
eqn = 0.5959 + 0.0321*(x^2.1)-0.184*(x^8)+0.0143*(x^2.5)-0.2359*(sqrt((1-x^4)/x^4));
res = solve(eqn == 0,x);
numeric_res = vpa(res)
The numeric result obtained is:
0.6015191969401057095577237699673
- 0.60342554599494554515246506424316 - 0.0032524435318404812187506975163144i
- 0.60342554599494554515246506424316 + 0.0032524435318404812187506975163144i
- 0.0022957627114584795743384488144413 - 0.6148033016363615664866637134719i
- 0.0022957627114584795743384488144413 + 0.6148033016363615664866637134719i
- 0.034350766702267990632625142341669 - 1.1446441922416124914568634765747i
- 0.034350766702267990632625142341669 + 1.1446441922416124914568634765747i
0.045439493798166588383693273719136 - 1.14543346751870257491869864044i
0.045439493798166588383693273719136 + 1.14543346751870257491869864044i
- 1.1691779737703086214274911464114 - 0.029488409879496751528279391787196i
- 1.1691779737703086214274911464114 + 0.029488409879496751528279391787196i
1.1752945738347608763208400050921 - 0.037263119738081124633951256034582i
1.1752945738347608763208400050921 + 0.037263119738081124633951256034582i
You can refer to the below example for more information:
2 件のコメント
Walter Roberson
2024 年 8 月 2 日
format long g
syms x
eqn = 0.5959 + 0.0321*(x^2.1)-0.184*(x^8)+0.0143*(x^2.5)-0.2359*(sqrt((1-x^4)/x^4));
F = matlabFunction(eqn)
numeric_res = fzero(F, [1e-6 1])
その他の回答 (1 件)
Walter Roberson
2024 年 8 月 2 日
You are getting garbage values, for a garbage query.
You have used floating point quantities in a symbolic equation. You have used solve() on the equation. solve() is intended to find indefinitely precise solutions. It makes no sense to ask for indefinitely precise solutions to equations involving floating point values, since floating point values are inherently imprecise.
0 件のコメント
参考
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!