# HG changeset patch
# User Mike Hansen <mhansen@gmail.com>
# Date 1219431365 25200
# Node ID f9d448db9622a8d1b8874db5596a917efd7c25bd
# Parent c338578a38b3ef1ff0610fdc07f447016ff030f6
Fixed synchronization problem with Maxima 5.16.2
diff r c338578a38b3 r f9d448db9622 sage/calculus/calculus.py
a

b


775  775  sage: f = integral(sin(x^2)); f 
776  776  sqrt(pi)*((sqrt(2)*I + sqrt(2))*erf((sqrt(2)*I + sqrt(2))*x/2) + (sqrt(2)*I  sqrt(2))*erf((sqrt(2)*I  sqrt(2))*x/2))/8 
777  777  sage: print f 
778   (sqrt(2) I + sqrt(2)) x 
779   sqrt( pi) ((sqrt(2) I + sqrt(2)) erf() 
780   2 
781   (sqrt(2) I  sqrt(2)) x 
782   + (sqrt(2) I  sqrt(2)) erf())/8 
783   2 
 778  (sqrt(2) I + sqrt(2)) x 
 779  (sqrt( pi) ((sqrt(2) I + sqrt(2)) erf() 
 780  2 
 781  (sqrt(2) I  sqrt(2)) x 
 782  + (sqrt(2) I  sqrt(2)) erf()))/8 
 783  2 
 784  
 785  
784  786  """ 
785  787  if not self._has_been_simplified(): 
786  788  self = self.simplify() 
… 
… 

2178  2180  
2179  2181  sage: f = log(log(x))/log(x) 
2180  2182  sage: forget(); assume(x<2); lim(f, x=0, taylor=True) 
2181   und 
 2183  limit(log(log(x))/log(x), x, 0) 
2182  2184  
2183  2185  Here ind means "indefinite but bounded": 
2184  2186  sage: lim(sin(1/x), x = 0) 
… 
… 

2451  2453  x y + Sqrt[] FresnelS[Sqrt[] x] 
2452  2454  2 Pi 
2453  2455  sage: print f.integral(x) 
2454   z (sqrt(2) I + sqrt(2)) x 
2455   x y + sqrt( pi) ((sqrt(2) I + sqrt(2)) erf() 
2456   2 
2457   (sqrt(2) I  sqrt(2)) x 
2458   + (sqrt(2) I  sqrt(2)) erf())/8 
2459   2 
 2456  z 
 2457  x y + (sqrt( pi) ((sqrt(2) I + sqrt(2)) 
 2458  (sqrt(2) I + sqrt(2)) x 
 2459  erf() + (sqrt(2) I  sqrt(2)) 
 2460  2 
 2461  (sqrt(2) I  sqrt(2)) x 
 2462  erf()))/8 
 2463  2 
2460  2464  
2461  2465  We integrate the above function in maple now: 
2462  2466  sage: g = maple(f); g # optional  requires maple 
… 
… 

2626  2630  """ 
2627  2631  try: 
2628  2632  v = self._maxima_().quad_qags(var(x), 
2629   a, b, desired_relative_error, 
2630   maximum_num_subintervals) 
 2633  a, b, epsrel=desired_relative_error, 
 2634  limit=maximum_num_subintervals) 
2631  2635  except TypeError, err: 
2632  2636  if "ERROR" in str(err): 
2633  2637  raise ValueError, "Maxima (via quadpack) cannot compute the integral to that precision" 
2634  2638  else: 
2635  2639  raise TypeError, err 
 2640  
 2641  #This is just a work around until there is a response to 
 2642  #http://www.math.utexas.edu/pipermail/maxima/2008/012975.html 
 2643  if 'quad_qags' in str(v): 
 2644  raise ValueError, "Maxima (via quadpack) cannot compute the integral to that precision" 
2636  2645  
2637  2646  return float(v[0]), float(v[1]), Integer(v[2]), Integer(v[3]) 
2638  2647  
diff r c338578a38b3 r f9d448db9622 sage/calculus/desolvers.py
a

b


132  132  sage: f = function('f', x) 
133  133  sage: de = lambda y: diff(y,x,x)  2*diff(y,x) + y 
134  134  sage: desolve_laplace(de(f(x)),["x","f"]) 
135   "x*%e^x*(?%at('diff(f(x),x,1),x=0))f(0)*x*%e^x+f(0)*%e^x" 
 135  "x*%e^x*('at('diff(f(x),x,1),x=0))f(0)*x*%e^x+f(0)*%e^x" 
136  136  sage: desolve_laplace(de(f(x)),["x","f"],[0,1,2]) 
137  137  'x*%e^x+%e^x' 
138  138  
diff r c338578a38b3 r f9d448db9622 sage/combinat/combinat.py
a

b


1425  1425  When $x = 1$, this coincides with Riemann's zeta function. The Dirichlet Lfunctions 
1426  1426  may be expressed as a linear combination of Hurwitz zeta functions. 
1427  1427  
 1428  Note that if you use floting point inputs, then the results may be slightly off. 
 1429  
1428  1430  EXAMPLES: 
1429  1431  sage: hurwitz_zeta(3,1/2,6) 
1430  1432  8.41439000000000 
1431   sage: hurwitz_zeta(1.1,1/2,6) 
 1433  sage: hurwitz_zeta(11/10,1/2,6) 
1432  1434  12.1041000000000 
1433   sage: hurwitz_zeta(1.1,1/2,50) 
1434   12.103813495683744469025853545548130581952676591199 
 1435  sage: hurwitz_zeta(11/10,1/2,50) 
 1436  12.103813495683755105709077412966680619033648618088 
1435  1437  
1436  1438  REFERENCES: 
1437  1439  http://en.wikipedia.org/wiki/Hurwitz_zeta_function 
diff r c338578a38b3 r f9d448db9622 sage/functions/piecewise.py
a

b


504  504  interval endpoints. 
505  505  
506  506  EXAMPLES: 
507   sage: x = PolynomialRing(QQ, 'x').0 
 507  sage: R.<x> = QQ['x'] 
508  508  sage: f1 = x^0 
509  509  sage: f2 = 10*x  x^2 
510  510  sage: f3 = 3*x^4  156*x^3 + 3036*x^2  26208*x 
511  511  sage: f = Piecewise([[(0,3),f1],[(3,10),f2],[(10,20),f3]]) 
512   sage: f.critical_points() 
513   [5.0, 12.000000000000171, 12.9999999999996, 14.000000000000229] 
 512  sage: expected = [5, 12, 13, 14] 
 513  sage: all(abs(ea) < 0.001 for e,a in zip(expected, f.critical_points())) 
 514  True 
514  515  """ 
515  516  maxima = sage.interfaces.all.maxima 
516  517  x = PolynomialRing(QQ,'x').gen() 
diff r c338578a38b3 r f9d448db9622 sage/interfaces/expect.py
a

b


1091  1091  def _object_class(self): 
1092  1092  return ExpectElement 
1093  1093  
1094   def function_call(self, function, args=[]): 
 1094  def function_call(self, function, args=[], kwds={}): 
 1095  """ 
 1096  EXAMPLES: 
 1097  sage: maxima.quad_qags(x, x, 0, 1, epsrel=1e4) 
 1098  [0.5,5.5511151231257...E15,21,0] 
 1099  sage: maxima.function_call('quad_qags', [x, x, 0, 1], {'epsrel':'1e4'}) 
 1100  [0.5,5.5511151231257...E15,21,0] 
 1101  """ 
1095  1102  if function == '': 
1096  1103  raise ValueError, "function name must be nonempty" 
1097  1104  if function[:2] == "__": 
… 
… 

1101  1108  for i in range(len(args)): 
1102  1109  if not isinstance(args[i], ExpectElement): 
1103  1110  args[i] = self.new(args[i]) 
1104   return self.new("%s(%s)"%(function, ",".join([s.name() for s in args]))) 
 1111  for key, value in kwds.iteritems(): 
 1112  kwds[key] = self.new(value) 
 1113  
 1114  return self.new("%s(%s)"%(function, ",".join([s.name() for s in args]+ 
 1115  ['%s=%s'%(key,value.name()) for key, value in kwds.items()]))) 
1105  1116  
1106   def call(self, function_name, *args): 
1107   return self.function_call(function_name, args) 
 1117  def call(self, function_name, *args, **kwds): 
 1118  return self.function_call(function_name, args, kwds) 
1108  1119  
1109  1120  def _contains(self, v1, v2): 
1110  1121  raise NotImplementedError 
… 
… 

1156  1167  def __repr__(self): 
1157  1168  return "%s"%self._name 
1158  1169  
1159   def __call__(self, *args): 
1160   return self._parent.function_call(self._name, list(args)) 
 1170  def __call__(self, *args, **kwds): 
 1171  return self._parent.function_call(self._name, list(args), kwds) 
1161  1172  
1162  1173  
1163  1174  class FunctionElement(SageObject): 
… 
… 

1171  1182  def __repr__(self): 
1172  1183  return "%s"%self._name 
1173  1184  
1174   def __call__(self, *args): 
1175   return self._obj.parent().function_call(self._name, [self._obj] + list(args)) 
 1185  def __call__(self, *args, **kwds): 
 1186  return self._obj.parent().function_call(self._name, [self._obj] + list(args), kwds) 
1176  1187  
1177  1188  def help(self): 
1178  1189  print self._sage_doc_() 
diff r c338578a38b3 r f9d448db9622 sage/interfaces/maxima.py
a

b


624  624  if self._expect is None: return 
625  625  r = randrange(2147483647) 
626  626  s = marker + str(r+1) 
627   cmd = '''sconc("%s",(%s+1));\n'''%(marker,r) 
 627  cmd = '''sconcat("%s",(%s+1));\n'''%(marker,r) 
628  628  self._sendstr(cmd) 
629  629  try: 
630  630  self._expect_expr(timeout=0.5) 
… 
… 

919  919  
920  920  EXAMPLES: 
921  921  sage: maxima.version() 
922   '5.13.0' 
 922  '5.16.2' 
923  923  """ 
924  924  return maxima_version() 
925  925  
… 
… 

1120  1120  sage: maxima.clear('x'); maxima.clear('f') 
1121  1121  sage: f = maxima.de_solve_laplace("diff(f(x),x,2) = 2*diff(f(x),x)f(x)", ["x","f"]) 
1122  1122  sage: f 
1123   f(x)=x*%e^x*(?%at('diff(f(x),x,1),x=0))f(0)*x*%e^x+f(0)*%e^x 
 1123  f(x)=x*%e^x*('at('diff(f(x),x,1),x=0))f(0)*x*%e^x+f(0)*%e^x 
1124  1124  sage: print f 
1125  1125  ! 
1126  1126  x d ! x x 
… 
… 

1571  1571  0.52848223531423071361790491935415653021675547587292866196865279321015401702040079 
1572  1572  """ 
1573  1573  from sage.rings.all import Integer 
1574   v = self.quad_qags(var, a, b, desired_relative_error, 
1575   maximum_num_subintervals) 
 1574  v = self.quad_qags(var, a, b, epsrel=desired_relative_error, 
 1575  limit=maximum_num_subintervals) 
1576  1576  return v[0], v[1], Integer(v[2]), Integer(v[3]) 
1577  1577  
1578  1578  def integral(self, var='x', min=None, max=None): 