|
|
On 9/28/19 9:26 AM, William F Pokorny wrote:
> On 9/28/19 8:08 AM, Bald Eagle wrote:
>>
>> "IGM" <iar### [at] gmailcom> wrote:
...
>
> A site and web search might be worthwhile. I remember Tor Olav
> Kristensen creating a simplex solver (for min, max) some while ago in
> the SDL. Expect somebody, at some time past, has gone after a problem
> similar to yours. Quickly finding previous work of a type can be a
> difficult trick though.
>
Had the thought for what you want, given you have one root/zero-crossing
and can probable specify known values of x for lo and hi where y is
negative and positive (or visa versa) a bisection root finder probably OK.
Here is the core of my tcl bisection root finding command:
for {set i 0} {$i < $interationLimit} {incr i} {
set mid [expr {($lo + $hi)/2.0}]
set midV [UPolyVal $mid coefList]
if { $midV == 0.0 } {
return [list $mid]
} else {
if { [expr {($loV * $midV)>=0.0}] } {
set lo $mid
} else {
set hi $mid
}
if { [expr {($hi - $lo) < $limitVal}] } {
return [list [expr {($lo + $hi)/2.0}]]
}
}
}
return [list];
Replace [UPolyVal $mid coefList] with your Fspline(x) evaluation while
otherwise translating the tcl into SDL and, I think, you'll be good to
go. You might want to add a check the intersection limit was not reached
and kick out and error in that case instead of just returning no roots
as I do above.
Bill P.
Post a reply to this message
|
|