【问题标题】:Finding the root of the function from the list of function values in Maxima CAS从 Maxima CAS 中的函数值列表中查找函数的根
【发布时间】:2018-07-26 16:19:59
【问题描述】:

在 Maxima CAS 中,我有一个列表(这里只显示了一些值)

pp:[2.224930361893751E-5,2.106533424809514E-5,1.987219192893519E-5,1.867039677797E-5,1.746047267164874E-5,1.624294701768613E-5,1.501835052467037E-5,1.378721697090773E-5,1.25500829711786E-5,1.130748774272327E-5,1.005997286991633E-5,8.808082068087475E-6,7.552360946350145E-6,6.293356769639102E-6,5.031618219769607E-6,3.767695156954576E-6,2.502138378962515E-6,1.23549938203793E-6,-3.166988037095475E-8,-1.298817237566085E-6,-2.565390542642876E-6,-3.83083791286043E-6,-5.094607970414222E-6,-6.3561500823206E-6,-7.614914600641287E-6,-8.870353101722573E-6,-1.012191862512224E-5,-1.136906591173853E-5,-1.261125164149501E-5,-1.384793466965156E-5,-1.507857626262959E-5,-1.63026403323524E-5,-1.751959366975281E-5,-1.872890617687916E-5,-1.993005109740542E-5,-2.112250524602399E-5,-2.230574923611089E-5,-2.34792677056006E-5,-2.464254954120948E-5,-2.579508810070241E-5]

函数的浮点值

y =  f(x)

列表是有序的:列表中的位置与 x 成正比。

对于从 0 到 1 的 n 个点。

如果我绘制列表,那么我会得到a diagram of my function

我可以find maximal value and it's index

dpMax : lmax(pp), 
iMax : sublist_indices(pp, lambda([p], p = lmax(pp))),

和根 ( x:f(x) = 0 )

ppa : map(abs, pp),
dpMin : lmin(ppa), 
iMin : sublist_indices(ppa, lambda([p], p = lmin(ppa))),

但它只找到一个根。可以看出这里有2个根吗?

如何找到第二个根?

也许:

  • 寻找符号变化的点

==== 编辑 ===

这是finding gradient of the 2D scalar field的一部分

【问题讨论】:

  • 是的,我认为寻找符号变化是个好主意。
  • @Robert Dodier,谢谢。链接包含完整的代码。如果你能检查一下,那就太好了。 TIA

标签: list numerical-methods maxima equation-solving


【解决方案1】:

我可以通过检查值的符号来做到这一点:

GiveRoots(List):=block(
    [i,  rr],
    rr:[],
    for i:1 thru length(List)-1 step 1 do 
        if (is (sign(List[i]) # sign(List[i+1])))
             then rr: endcons([i, List[i]],rr),
    rr  
)$

现在:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-08-22
    • 2014-10-25
    • 2021-05-22
    • 1970-01-01
    • 2021-11-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多