Question: Strange behavior of fsolve

 

Let us define a piecewise-linear continuous function:

restart; VP := Vector[row](16, {(1) = 10, (2) = 177.9780267, (3) = 355.9560534, (4) = 533.9340801, (5) = 711.9121068, (6) = 889.8901335, (7) = 1067.868160, (8) = 1245.846187, (9) = 1423.824214, (10) = 1601.802240, (11) = 1779.780267, (12) = 1957.758294, (13) = 2135.736320, (14) = 2313.714347, (15) = 2491.692374, (16) = 2669.670400}); VE := Vector[row](16, {(1) = 5.444193931, (2) = .4793595141, (3) = .3166653569, (4) = .2522053489, (5) = .2123038784, (6) = .1822258228, (7) = .1544240625, (8) = .1277082078, (9) = .1055351619, (10) = 0.8639065510e-1, (11) = 0.6936612570e-1, (12) = 0.5388339810e-1, (13) = 0.3955702170e-1, (14) = 0.2612014630e-1, (15) = 0.1338216460e-1, (16) = 0.1203297900e-2}); for i to 15 do p[i] := VE[i+1] < x and x <= VE[i], (VP[i+1]-VP[i])*(x-VE[i])/(VE[i+1]-VE[i])+VP[i] end do; g := unapply(piecewise(seq(p[i], i = 1 .. 15)), x);

for i to 15 do print(fsolve(g(x) = VP[i])) end do;

Why doesn't the fsolve command work if i = 4, 7, 9, 11, 14? There are workarounds:

print(DirectSearch:-SolveEqutions(g(x) = VP[i]));

and/or

VP := convert(VP, rational); VE := convert(VE, rational); print(solve(g(x) = VP[i]));

 How to explain such behavior of the fsolve command? That was asked but not answered in http://forum.exponenta.ru/viewtopic.php?t=13524&sid=025a140e7e00b99803c86060a5c0c33c .

NULL

 

strange_behavior.mw

Edit. Replaced worksheet.

Please Wait...