Repo for the search and displace ingest module that takes odf, docx and pdf and transforms it into .md to be used with search and displace operations
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
965 B

3 years ago
  1. from __future__ import print_function
  2. import matplotlib.pyplot as plt
  3. import numpy as np
  4. import sympy
  5. # create a bunch of symbols
  6. a, b, c, d, x, alpha, beta = sympy.symbols('a b c d x alpha beta')
  7. # create a polynomial function f(x)
  8. f = a*x**3 + b*x**2 + c*x + d
  9. # get its derivative f'(x)
  10. fp = f.diff(x)
  11. # evaluate both at x=0 and x=1
  12. f0 = f.subs(x, 0)
  13. f1 = f.subs(x, 1)
  14. fp0 = fp.subs(x, 0)
  15. fp1 = fp.subs(x, 1)
  16. # we want a, b, c, d such that the following conditions hold:
  17. #
  18. # f(0) = 0
  19. # f(1) = 0
  20. # f'(0) = alpha
  21. # f'(1) = beta
  22. S = sympy.solve([f0, f1, fp0-alpha, fp1-beta], [a, b, c, d])
  23. # print the analytic solution and plot a graphical example
  24. coeffs = []
  25. num_alpha = 0.3
  26. num_beta = 0.03
  27. for key in [a, b, c, d]:
  28. print(key, '=', S[key])
  29. coeffs.append(S[key].subs(dict(alpha=num_alpha,
  30. beta=num_beta)))
  31. xvals = np.linspace(0, 1, 101)
  32. yvals = np.polyval(coeffs, xvals)
  33. plt.plot(xvals, yvals)
  34. plt.show()