【问题标题】:Separation and allocation of terms of Taylor series expansion in MATLABMATLAB中泰勒级数展开项的分离与分配
【发布时间】:2019-09-24 23:36:23
【问题描述】:

如何将泰勒级数展开的项“分离”成单个部分?我正在使用这个工具在管理会计中进行差异分析。

我需要将单个术语分配给影响因素。

此代码可能是永续年金的最简单表示。我想展示贴现率 (b) 和现金流量 (a) 的变化如何影响价值。

syms a b a1 b1 test;
test = evalin(symengine,'mtaylor(a/b , [a = a1, b = b1], 4)')
dtest = subs(test, [a, a1, b, b1],[40,150,0.01,0.12])-(a1/b1)
dtest2 = subs(dtest, [a1,b1],[150,0.12])   
test =
 a1/b1 + (a - a1)/b1 - (a1*(b - b1))/b1^2 - ((a - a1)*(b - b1))/b1^2 + (a1*(b - b1)^2)/b1^3 - (a1*(b - b1)^3)/b1^4 + ((a - a1)*(b - b1)^2)/b1^3

dtest2 =
 545875/864

手动进行了以下分离:

+(a - a1)/b1                  affected by delta cashflow
-(A1*(b - B1))/B1^2           affected by delta discount rate
-((a - a1)*(b - b1))/b1^2     affected by a mix of cashflow and disc. rate
+(a1*(b - b1)^2)/b1^3         affected by delta discount rate
-(a1*(b - b1)^3)/b1^4         affected by delta discount rate
+((a - a1)*(b - b1)^2)/b1^3   affected by a mix of cashflow and disc. rate

dtest2 -->>> The whole deviation 

为了减少系列扩展的其余部分,我想扩展至“200”的顺序,例如这就是为什么我想系统地而不是手动地分离和分配单个术语。

【问题讨论】:

    标签: matlab symbolic-math taylor-series


    【解决方案1】:

    找到两个连续的泰勒级数展开式,然后从以前的级数中减去当前级数,你会得到你需要的额外的单个部分。

    syms a b a1 b1 test test2;
    n = 4 % Taylor Expansion degree
    for i = 1:n
        test(i) = evalin(symengine,strcat('mtaylor(a/b , [a = a1, b = b1], ', num2str(i), ')'));
         if i == 1
            test2(i) = test(i);
         else
            test2(i) = test(i)-test(i-1);
         end
    end
    
    test2(1) = a1/b1
    test2(2) = (a - a1)/b1 - (a1*(b - b1))/b1^2
    test2(3) = (a1*(b - b1)^2)/b1^3 - ((a - a1)*(b - b1))/b1^2
    test2(4) = ((a - a1)*(b - b1)^2)/b1^3 - (a1*(b - b1)^3)/b1^4
    

    过滤测试2(2)

      filter = children(test2(2) + (a-a1) + (b-b1));
      filter = [ a, -a1, b, -b1, (a - a1)/b1, -(a1*(b - b1))/b1^2]
    

    忽略前 4 个数组元素

    filter(5) = (a - a1)/b1
    filter(6) = -(a1*(b - b1))/b1^2
    

    过滤测试2(3)

    filter = children(test2(3) + (a-a1) + (b-b1));
    filter = [ a, -a1, b, -b1, -((a - a1)*(b - b1))/b1^2, (a1*(b - b1)^2)/b1^3]
    

    忽略前 4 个数组元素

    filter(5) = -((a - a1)*(b - b1))/b1^2
    filter(6) = a1*(b - b1)^2)/b1^3
    

    【讨论】:

    • 非常感谢您快速而有帮助的回复!这很好用,但我还有另一个问题。如何过滤有关影响因素数量的方程式?例如:test2(2) = (a - a1)/b1 - (a1*(b - b1))/b1^2 包含 (a - a1) 和 (b - b1)。因此,“a”(现金流)的变化会产生混合影响。
    • 再次感谢您的帮助。我如何从矩阵过滤器中挑选出关于其内容的项目?例如,filter(5) 如果它包含 (a-a1) 和 (b-b1)。
    猜你喜欢
    • 2014-06-11
    • 2011-12-06
    • 2017-06-14
    • 2013-10-09
    • 2015-04-30
    • 1970-01-01
    • 2020-04-10
    • 2020-04-06
    • 2019-06-15
    相关资源
    最近更新 更多