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 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
VBBV
le 2 Août 2024
@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)
Réponse acceptée
Arnav
le 2 Août 2024
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 commentaires
Walter Roberson
le 2 Août 2024
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])
Plus de réponses (1)
Walter Roberson
le 2 Août 2024
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 commentaires
Voir également
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!