1

In Maxima CAS I have a list ( here only some values are shown)

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]

of floating point values of a function

y =  f(x)

The list is ordered : position in the list is proportional to x.

for n points fron 0 to 1.

If I draw the list then I get a diagram of my function.

enter image description here

I can find maximal value and it's index:

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

and roots ( x:f(x) = 0 )

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

but it finds only one root. One can see that there are 2 roots here ?

How can I find the second root?

Maybe:

  • finding points where sign is changing

==== edit ===

This is a part of finding gradient of the 2D scalar field

Adam
  • 1,254
  • 12
  • 25

1 Answers1

1

I can do it by checking sign of value :

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  
)$

Now:

enter image description here

Adam
  • 1,254
  • 12
  • 25