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

4 ビュー (過去 30 日間)
Bewar Yousif Ali
Bewar Yousif Ali 2023 年 11 月 27 日
コメント済み: Walter Roberson 2023 年 12 月 11 日
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 件のコメント
Walter Roberson
Walter Roberson 2023 年 12 月 11 日
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 ?

サインインしてコメントする。

回答 (0 件)

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by