欧美女同视频激情_国产原创中文字幕在线观看_4438xx亚洲最大五色丁香_成年做羞羞的视频网站在线观看_a毛片免费全部播_原神胡桃乳液vx网站进入_一区亚洲欧美中文日韩v在线观看_校园春色亚洲_搞机time软件app免费下载安装_十八禁无遮拦视频大全

普通會員

Cyhan

PSE@BUCT

1帖子
5回復(fù)
298積分
ID:000077
北京化工大學(xué)
北京,朝陽
https://github.com/baltamatica-dev
Gamma 函數(shù)的特殊值計算

gamma 函數(shù)在部分點(diǎn)的實現(xiàn)有些問題。


例如 gamma(-4) Matlab 選擇的是 +Inf,目前北太會給出錯誤。

可以和 Matlab 行為保持一致,或者直接返回 NaN。這樣對畫圖方便一些。

目前的實現(xiàn)要畫圖,就只能手動分段。計算 1/gamma(x) 也變成不連續(xù)的了。


即 Matlab 可以執(zhí)行以下代碼并畫圖

gamma([-5 -4 -3 -2 -1 0 5])

x = -5:0.01:5;
plot(x, gamma(x))

 

Matlab R2023b 輸出

>> gamma([-5 -4 -3 -2 -1 0 5])

ans = 

    Inf   Inf   Inf   Inf   Inf   Inf    24


北太 3.1.0 目前會報定義域錯誤

>> x = -5:0.01:5;
>> plot(x, gamma(x));
錯誤使用函數(shù) gamma
domain error
程序執(zhí)行中顯示有錯誤信息,請反饋給開發(fā)團(tuán)隊。


目前要繪制  gamma 函數(shù)只能手動分段繪圖:

代碼如下:

% 生成開區(qū)間 (start:stop)
function range=openRange(start, step, stop)
    range = (start+eps(start)):step:(stop-eps(stop));
end
% 繪制 gamma 函數(shù)
function gamma_plot()
    step = 0.01;
    x1 = [
        openRange(-5.0, step, -4.0)
        openRange(-4.0, step, -3.0)
        openRange(-3.0, step, -2.0)
        openRange(-2.0, step, -1.0)
        openRange(-1.0, step, -0.0)
    ]';
    x2 = [ openRange(0.0, step, 5.0) ]';
    
    % draw
    plot(...
        x1,gamma(x1),...
        x2,gamma(x2),...
        'LineWidth',2,...
    );
    grid on;
    xlim([-5, 5]);
    ylim([-10, 10]);
    title('Gamma(x) Line Plot')
    xlabel('x');
    ylabel('Gamma(x)');
end




2 2024-01-27