How to solve this equation on MATLAB ? how to get the value of x

1 visualización (últimos 30 días)
Raj Arora
Raj Arora el 25 de Sept. de 2020
Comentada: Star Strider el 28 de Sept. de 2020
((30\((0.45+0.1233*x)*(12+0.2958*x)))-(2.41*((0.57-0.11789*x)^(-0.77))=0)
HOW TO FIND THE VALUE OF X FOR WHICH THE WHOLE EQUATION BECOMES 0

Respuestas (2)

Ameer Hamza
Ameer Hamza el 25 de Sept. de 2020
Editada: Ameer Hamza el 25 de Sept. de 2020
You can use fsolve()
f = @(x) (30\((0.45+0.1233*x)*(12+0.2958*x)))-(2.41*((0.57-0.11789*x)^(-0.77)));
x_sol = fsolve(f, rand())
Result
>> x_sol = fsolve(f, rand())
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
<stopping criteria details>
x_sol =
-50.5386
  2 comentarios
Raj Arora
Raj Arora el 28 de Sept. de 2020
The value of x is not correct. This value is not making this equation 0.
Ameer Hamza
Ameer Hamza el 28 de Sept. de 2020
Editada: Ameer Hamza el 28 de Sept. de 2020
The value is very close to zero
>> f(x_sol)
ans =
6.7308e-11
This is 0.000000000067308. You cannot get exactly zero using numerical methods and finite-precision mathematics.
You can get more closer to zero by using a tighter optimality tolerance
f = @(x) (30\((0.45+0.1233*x)*(12+0.2958*x)))-(2.41*((0.57-0.11789*x)^(-0.77)));
opts = optimoptions('fsolve', 'OptimalityTolerance', 1e-16);
x_sol = fsolve(f, rand(), opts);
Result
>> f(x_sol)
ans =
-2.2204e-16

Iniciar sesión para comentar.


Star Strider
Star Strider el 25 de Sept. de 2020
Running vpasolve two times reveals two solutions:
syms x
f = ((30\((0.45+0.1233*x).*(12+0.2958*x)))-(2.41*((0.57-0.11789*x).^-0.77)));
[xs] = vpasolve(f, 'random',1)
producing:
xs =
-50.538642583200665582981460055213
xs =
8.0085634626306504965321046489768 - 17.862103670822392773324688261794i
.
  2 comentarios
Star Strider
Star Strider el 28 de Sept. de 2020
It is correct, within floating-point approximation error, that is as accurate as it is possible to get using IEEE 754 floating-point operations and 64-bit precision:
syms x f(x)
f(x) = ((30\((0.45+0.1233*x).*(12+0.2958*x)))-(2.41*((0.57-0.11789*x).^-0.77)))
x1 = -50.538642583200665582981460055213;
fx1 = vpa(f(x1))
fx1 = double(fx1)
x2 = 8.0085634626306504965321046489768 - 17.862103670822392773324688261794i;
fx2 = vpa(f(x2))
fx2 = double(fx2)
produces:
fx1 =
-0.00000000000000025499106397930409767855524521741
fx1 =
-2.549910639793041e-16
fx2 =
0.000000000000000043859674162247215336179795855927 + 0.000000000000000012914849938348163810324610654156i
fx2 =
4.385967416224722e-17 + 1.291484993834816e-17i
since on my computer, eps:
eps_value = eps
produces:
eps_value =
2.220446049250313e-16
See the documentatiion section on Floating-Point Numbers for a full explanation.
.

Iniciar sesión para comentar.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by