Révision 120 pobysoPythonSage/src/sageSLZ/sageSLZ.sage
sageSLZ.sage (revision 120) | ||
---|---|---|
162 | 162 |
maxErrorSa = pobyso_get_constant_as_rn_with_rf_so_sa(maxErrorSo) |
163 | 163 |
while maxErrorSa > approxPrecSa: |
164 | 164 |
#print "++Approximation error:", maxErrorSa |
165 |
sollya_lib_clear_obj(maxErrorSo) |
|
166 | 165 |
sollya_lib_clear_obj(polySo) |
167 | 166 |
sollya_lib_clear_obj(intervalCenterSo) |
167 |
sollya_lib_clear_obj(maxErrorSo) |
|
168 | 168 |
shrinkFactorSa = RRR('5')/(maxErrorSa/approxPrecSa).log2().abs() |
169 | 169 |
#shrinkFactorSa = 1.5/(maxErrorSa/approxPrecSa) |
170 | 170 |
#errorRatioSa = approxPrecSa/maxErrorSa |
... | ... | |
182 | 182 |
actualShrinkFactorSa |
183 | 183 |
#print "Current upper bound:", currentUpperBoundSa |
184 | 184 |
sollya_lib_clear_obj(currentRangeSo) |
185 |
sollya_lib_clear_obj(polySo) |
|
186 | 185 |
if currentUpperBoundSa <= currentLowerBoundSa or \ |
187 | 186 |
currentUpperBoundSa == currentLowerBoundSa.nextabove(): |
188 | 187 |
sollya_lib_clear_obj(absoluteErrorTypeSo) |
... | ... | |
195 | 194 |
currentUpperBoundSa) |
196 | 195 |
# print "New interval:", |
197 | 196 |
# pobyso_autoprint(currentRangeSo) |
197 |
#print "Second Taylor expansion call." |
|
198 | 198 |
(polySo, intervalCenterSo, maxErrorSo) = \ |
199 | 199 |
pobyso_taylor_expansion_no_change_var_so_so(functionSo, degreeSo, |
200 | 200 |
currentRangeSo, |
... | ... | |
341 | 341 |
- the corresponding approximation error. |
342 | 342 |
TODO: fix endless looping for some parameters sets. |
343 | 343 |
""" |
344 |
resultArray = [] |
|
344 | 345 |
# Set Sollya to the necessary internal precision. |
346 |
precChangedSa = False |
|
345 | 347 |
currentSollyaPrecSo = pobyso_get_prec_so() |
346 | 348 |
currentSollyaPrecSa = pobyso_constant_from_int_so_sa(currentSollyaPrecSo) |
347 | 349 |
if internalSollyaPrecSa > currentSollyaPrecSa: |
348 | 350 |
pobyso_set_prec_sa_so(internalSollyaPrecSa) |
351 |
precChangedSa = True |
|
349 | 352 |
# |
350 | 353 |
x = functionSa.variables()[0] # Actual variable name can be anything. |
351 | 354 |
# Scaled function: [1=,2] -> [1,2]. |
... | ... | |
356 | 359 |
upperBoundSa, \ |
357 | 360 |
floatingPointPrecSa) |
358 | 361 |
# |
359 |
resultArray = [] |
|
360 |
# |
|
361 | 362 |
print "Approximation precision: ", RR(approxPrecSa) |
362 | 363 |
# Prepare the arguments for the Taylor expansion computation with Sollya. |
363 | 364 |
functionSo = pobyso_parse_string_sa_so(fff._assume_str()) |
... | ... | |
371 | 372 |
approxPrecSa, internalSollyaPrecSa) |
372 | 373 |
if polySo is None: |
373 | 374 |
print "slz_get_intervals_and_polynomials: Aborting and returning None!" |
374 |
if internalSollyaPrecSa != currentSollyaPrecSa:
|
|
375 |
pobyso_set_prec_sa_so(currentSollyaPrecSa)
|
|
375 |
if precChangedSa:
|
|
376 |
pobyso_set_prec_so_so(currentSollyaPrecSo)
|
|
376 | 377 |
sollya_lib_clear_obj(currentSollyaPrecSo) |
377 | 378 |
sollya_lib_clear_obj(functionSo) |
378 | 379 |
sollya_lib_clear_obj(degreeSo) |
... | ... | |
401 | 402 |
sollya_lib_clear_obj(scaledBoundsSo) |
402 | 403 |
#print "Approximation error:", errorSa |
403 | 404 |
return resultArray |
404 |
# Compute the next upper bound. |
|
405 |
# The returned interval upper bound does not reach the requested upper |
|
406 |
# upper bound: compute the next upper bound. |
|
405 | 407 |
# The following ratio is always >= 1 |
406 | 408 |
currentErrorRatio = approxPrecSa / errorSa |
407 | 409 |
# Starting point for the next upper bound. |
Formats disponibles : Unified diff