Révision 63
| pobysoPythonSage/src/pobyso.py (revision 63) | ||
|---|---|---|
| 466 | 466 |
"(" + pobyso_get_sage_exp_from_sollya_exp_so_sa(subexpressions[0], \
|
| 467 | 467 |
realField) + ")") |
| 468 | 468 |
elif arity == 2: |
| 469 |
# We do not get through the preprocessor. |
|
| 470 |
# The "^" operator is then a special case. |
|
| 469 | 471 |
if operator == SOLLYA_BASE_FUNC_POW: |
| 470 | 472 |
operatorAsString = "**" |
| 471 | 473 |
else: |
| ... | ... | |
| 475 | 477 |
eval("pobyso_get_sage_exp_from_sollya_exp_so_sa(subexpressions[0], realField)"\
|
| 476 | 478 |
+ " " + operatorAsString + " " + \ |
| 477 | 479 |
"pobyso_get_sage_exp_from_sollya_exp_so_sa(subexpressions[1], realField)") |
| 478 |
# We do not know yet how to deal with arity > 3 (is there any in Sollya anyway?). |
|
| 480 |
# We do not know yet how to deal with arity >= 3 |
|
| 481 |
# (is there any in Sollya anyway?). |
|
| 479 | 482 |
else: |
| 480 | 483 |
sageExp = eval('None')
|
| 481 | 484 |
return(sageExp) |
| ... | ... | |
| 505 | 508 |
if realFieldSa is None: |
| 506 | 509 |
expressionPrecSa = pobyso_get_max_prec_of_exp_so_sa(polySo) |
| 507 | 510 |
realFieldSa = RealField(expressionPrecSa) |
| 511 |
#print "Sollya expression before...", |
|
| 512 |
#pobyso_autoprint(polySo) |
|
| 513 |
|
|
| 508 | 514 |
expressionSa = pobyso_get_sage_exp_from_sollya_exp_so_sa(polySo, \ |
| 509 | 515 |
realFieldSa) |
| 516 |
#print "...Sollya expression after.", |
|
| 517 |
#pobyso_autoprint(polySo) |
|
| 510 | 518 |
polyVariableSa = expressionSa.variables()[0] |
| 511 | 519 |
polyRingSa = realFieldSa[str(polyVariableSa)] |
| 512 | 520 |
print polyRingSa |
| ... | ... | |
| 805 | 813 |
if not sollyaPrecSo is None: |
| 806 | 814 |
sollya_lib_set_prec(initialPrecSo) |
| 807 | 815 |
sollya_lib_clear_obj(initailPrecSo) |
| 808 |
return([polyVarChangedSo, intervalCenterSo, maxErrorSo])
|
|
| 816 |
return((polyVarChangedSo, intervalCenterSo, maxErrorSo))
|
|
| 809 | 817 |
# end pobyso_taylor_expansion_with_change_var_so_so |
| 810 | 818 |
|
| 811 | 819 |
def pobyso_taylor_expansion_no_change_var_so_so(functionSo, degreeSo, rangeSo, \ |
| ... | ... | |
| 832 | 840 |
# If changed, reset the Sollya working precision. |
| 833 | 841 |
if not sollyaPrecSo is None: |
| 834 | 842 |
sollya_lib_set_prec(initialPrecSo) |
| 835 |
sollya_lib_clear_obj(initailPrecSo)
|
|
| 836 |
return([polySo, intervalCenterSo, maxErrorSo])
|
|
| 843 |
sollya_lib_clear_obj(initialPrecSo)
|
|
| 844 |
return((polySo, intervalCenterSo, maxErrorSo))
|
|
| 837 | 845 |
# end pobyso_taylor_expansion_no_change_var_so_so |
| 838 | 846 |
|
| 839 | 847 |
def pobyso_taylor(function, degree, point): |
| pobysoPythonSage/src/sageSLZ.sage (revision 63) | ||
|---|---|---|
| 56 | 56 |
return((polySo, currentRangeSo, intervalCenterSo, maxErrorSo)) |
| 57 | 57 |
# End slz_compute_polynomial_and_interval |
| 58 | 58 |
|
| 59 |
def slz_get_intervals_and_polynomials(functionSa, degreeSa, lowerBoundSa, |
|
| 59 |
def slz_get_intervals_and_polynomials(functionSa, variableNameSa, degreeSa, |
|
| 60 |
lowerBoundSa, |
|
| 60 | 61 |
upperBoundSa, floatingPointPrecSa, |
| 61 | 62 |
internalSollyaPrecSa): |
| 62 | 63 |
""" |
| ... | ... | |
| 82 | 83 |
- the center, x0, of the interval (the polynomial is defined as p(x-x0)); |
| 83 | 84 |
- the corresponding approximation error. |
| 84 | 85 |
""" |
| 86 |
x = var(variableNameSa) |
|
| 85 | 87 |
# Scalling the domain -> [1,2[. |
| 86 | 88 |
boundsIntervalRifSa = RealIntervalField(floatingPointPrecSa) |
| 87 | 89 |
domainBoundsIntervalSa = boundsIntervalRifSa(lowerBoundSa, upperBoundSa) |
| 88 | 90 |
(domainScalingExpressionSa, invDomainScalingExpressionSa) = \ |
| 89 |
slz_interval_scaling_expression(domainBoundsIntervalSa, 'x')
|
|
| 91 |
slz_interval_scaling_expression(domainBoundsIntervalSa, variableNameSa)
|
|
| 90 | 92 |
print "domainScalingExpression for argument :", domainScalingExpressionSa |
| 91 |
ff(x) = f(domainScalingExpressionSa) |
|
| 93 |
print "f: ", f |
|
| 94 |
ff = f.subs({x:domainScalingExpressionSa})
|
|
| 92 | 95 |
scaledLowerBoundSa = invDomainScalingExpressionSa(lowerBoundSa).n() |
| 93 | 96 |
scaledUpperBoundSa = invDomainScalingExpressionSa(upperBoundSa).n() |
| 94 | 97 |
print 'ff:', ff, "- Domain:", scaledLowerBoundSa, scaledUpperBoundSa |
| ... | ... | |
| 103 | 106 |
print 'ff:', ff, '- Image:', flbSa, fubSa, imageBinadeBottomSa |
| 104 | 107 |
imageBoundsIntervalSa = boundsIntervalRifSa(flbSa, fubSa) |
| 105 | 108 |
(imageScalingExpressionSa, invImageScalingExpressionSa) = \ |
| 106 |
slz_interval_scaling_expression(imageBoundsIntervalSa, 'x') |
|
| 107 |
fff(x) = invImageScalingExpressionSa(ff(x)) |
|
| 109 |
slz_interval_scaling_expression(imageBoundsIntervalSa, variableNameSa) |
|
| 110 |
iis = invImageScalingExpressionSa.function(x) |
|
| 111 |
fff = iis.subs({x:ff})
|
|
| 108 | 112 |
print "fff:", fff, |
| 109 | 113 |
print " - Image:", fff(scaledLowerBoundSa), fff(scaledUpperBoundSa) |
| 110 | 114 |
# |
Formats disponibles : Unified diff