QQ登录

只需要一步,快速开始

 注册地址  找回密码
查看: 5773|回复: 0
打印 上一主题 下一主题

用切比雪夫多项式逼近已知函数

[复制链接]
字体大小: 正常 放大

8

主题

4

听众

955

积分

  • TA的每日心情
    无聊
    2013-1-7 08:31
  • 签到天数: 258 天

    [LV.8]以坛为家I

    群组学术交流A

    跳转到指定楼层
    1#
    发表于 2011-10-28 18:16 |只看该作者 |倒序浏览
    |招呼Ta 关注Ta
    function f = Chebyshev(y,k,x0)
    %用切比雪夫多项式逼近已知函数
    %已知函数y
    %逼近已知函数所需项数:k
    %逼近点的x坐标:x0
    %求得的切比雪夫逼近多项式或是在x0处的逼近值:f
    syms t;
    T(1:k+1) = t;
    T(1) = 1;
    T(2) = t;
    c(1:k+1) = 0.0;
    c(1)=int(subs(y,findsym(sym(y)),sym('t'))*T(1)/sqrt(1-t^2),t,-1,1)/pi;
    c(2)=2*int(subs(y,findsym(sym(y)),sym('t'))*T(2)/sqrt(1-t^2),t,-1,1)/pi;
    f = c(1)+c(2)*t;

    for i=3:k+1
        T(i) = 2*t*T(i-1)-T(i-2);
        c(i) = 2*int(subs(y,findsym(sym(y)),sym('t'))*T(i)/sqrt(1-t^2),t,-1,1)/2;
        f = f + c(i)*T(i);
        f = vpa(f,6);
       
        if(i==k+1)
            if(nargin == 3)
                f = subs(f,'t',x0);
            else
                f = vpa(f,6);
            end
        end
    end
    调用时:
    f = Chebyshev('1/(2-x)',6)
    Warning: Explicit integral could not be found.  
    ??? The following error occurred converting from sym to double:
    Error using ==> mupadmex
    Error in MuPAD command: DOUBLE cannot convert the input
    expression into a double array.

    If the input expression contains a symbolic variable, use the
    VPA function instead.

    Error in ==> Chebyshev at 7
    c(1)=int(subs(y,findsym(sym(y)),sym('t'))*T(1)/sqrt(1-t^2),t,-1,1)/pi;
    zan
    转播转播0 分享淘帖0 分享分享0 收藏收藏0 支持支持0 反对反对0 微信微信
    您需要登录后才可以回帖 登录 | 注册地址

    qq
    收缩
    • 电话咨询

    • 04714969085
    fastpost

    关于我们| 联系我们| 诚征英才| 对外合作| 产品服务| QQ

    手机版|Archiver| |繁體中文 手机客户端  

    蒙公网安备 15010502000194号

    Powered by Discuz! X2.5   © 2001-2013 数学建模网-数学中国 ( 蒙ICP备14002410号-3 蒙BBS备-0002号 )     论坛法律顾问:王兆丰

    GMT+8, 2025-11-28 13:05 , Processed in 0.592177 second(s), 49 queries .

    回顶部