How to fix this problem 0^0 in Matlab !?

4 visualizaciones (últimos 30 días)
Bewar Yousif Ali
Bewar Yousif Ali el 27 de Nov. de 2023
Comentada: Walter Roberson el 11 de Dic. de 2023
It is crucial to understand that this expression could be used in problems related to engineering, physics, mathematics, or any other aspect of real life.
Typically, Matlab is used to solve PDE and ODE problems. Perhaps users calculated this term 0^0 incorrectly in the process.
>> % Reviewed by Bewar Yousif Ali
>> % How to fix this problem 0^0 in Matlab !?
>> % Mathematically, x^0=1 if x≠0 is equal 1 else undefined(NaN)
>> 0^0
ans =
1
>> f=@(x,y) x^y;
>> f(0,0)
ans =
1
>> v=[2 0 5 -1];
>> v.^0
ans =
1 1 1 1
  1 comentario
Walter Roberson
Walter Roberson el 11 de Dic. de 2023
There are a lot of contexts in which is considered well defined.
For example, if you have is it really necessary to say that you have to define that as piecewise(x == 0, undefined, x^2 + 2*x + 1) or can you just define it as x^2 + 2*x + 1 ? If you are writing the derivative of c*x^n for integer n, is it really necessary to define it as piecewise(n == 1 & x == 0, undefined, (c*n)*x^(n-1)) or as piecewise(n == 1 & x == 0, c, (c*n)*x^(n-1)) ? Is the derivative of c*x to be defined differently than the derivative of c*x^1, or do we just have to carry around a whole bunch of special cases to protect against the possibility of evaluating 0^0 when the relevant formula would work fine for any other x^0 ?

Iniciar sesión para comentar.

Respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by