Does the SymPy function integration_steps reveal the result if the integration? - sympy

I'm using the SymPy function integral_steps to build a tool that, just like SymPy Gamma, reveals the integration steps when you ask it to integrate a function. My work-in-progress is available at https://lem.ma/1YH.
What I can't quite figure out is how to obtain the result of applying a particular rule. For example, consider the substitution rule
URule(u_var=_u, u_func=sin(x), constant=1, substep=ExpRule(base=E, exp=_u, context=exp(_u), symbol=_u), context=exp(sin(x))*cos(x), symbol=x)
The context field tells that the function being integrated is exp(sin(x))*cos(x) and that the rule uses a particular substitution - but what's the result of the integration so I can report to the user the same way SymPy Gamma does it. What I currently do is call integrate at every step, but that seems quite inefficient.
Perhaps there's an option that one can pass to integral_steps to make that information available?

SymPy Gamma is open source as SymPy itself. Looking at its module intsteps I see lines like
self.append("So, the result is: {}".format(
self.format_math(_manualintegrate(rule))))
So, the way to obtain the outcome of a rule from the rule is to call _manualintegrate(rule), which needs to be imported as
from sympy.integrals.manualintegrate import _manualintegrate
I imagine reading the rest of intsteps.py will be useful as well.

Related

Working with strings in GCP-Workflows and GCP-Admin

I'm integrating a project in GCP-Workflows with GCP-Admin, but I'm having trouble working with some data, when extracting a date it is delivered in this format: 2020-12-28T11: 20: 05.000Z, so I can't turn the string into int, and apparently there is no function in GCP like substring() either. I need to use the date with an IF, checking if it is greater or less than the reference.
How can I do this?
There is some lack of function implementation for now in Workflows. New ones are coming very soon. But I don't know if they will solve your problem
Anyway, with workflows, the correct pattern, if a built-in function isn't implemented, is to call an endpoint, for example a Cloud Function or a Cloud Run, which perform the transformation for you and return the expected result.
Quite boring to do, but don't hesitate to open feature request on the issues tracker product team is very reactive and love user feedbacks!
The Workflows standard library now includes a text module with functions for searching (including regular expressions), splitting, substrings and case transformations.

How to output the final tableau of simplex method in docplex?

Is there a way to output the final tableau in python with docplex library? If not, is there a work around?
I want to use dual simplex method to solve linear programming problem with newly added constraints. So, I would need to access the final tableau to decide which variable to exit the basis, without having to re-solve the problem from scratch.
This sort of low level interaction cannot be done at the docplex level. In order to do this you can use Model.get_cplex() to get a reference to the underlying engine object. With this you can then get additional information. You can find the reference documentation for this class here. You probably want to look at the solution, solution.basis, solution.advanced properties. This should give you all the information you need.
Note that the engine works with an index oriented model in which every variable or constraint is just a number. You can convert docplex variable objects by using Model.get_var_by_index().
I also wonder whether you may want drop docplex and instead directly use the CPLEX Python API. You can find documentation of this here.

How to perform integration of a number in python2.7

Someone please help me to integrate a_z as shown in the picture using Python2.7
Is there any predefined method to perform the action.Thank you
Try this:
http://docs.scipy.org/doc/scipy/reference/tutorial/integrate.html
for numerical integration.
In your particular example, a_z is a linear function of t and thus you dont need any numerical methods, you can do a symbolic integral and just compute the resultant function, which is much more efficient.
In fact, the solution is already printed there, so not sure what else you need to know?

Stata Code for the Expectations Maximization Algorithm

Is there a Stata module or code available for the Expectation Maximization (EM) algorithm? I cannot seem to find any, but I thought it was worth checking in.
My interest is in EM for record linkage. See, for example:
http://www.ncbi.nlm.nih.gov/pmc/articles/PMC1479910/
Usual name: expectation-maximization.
There is not a general command or set of commands providing a framework for applications of EM. Rather, the EM algorithm is used within the code for various commands.

Make HTTP Request from Verilog

Is it possible to call a C/C++/Python/Java function that makes an HTTP request inside of a Verilog module?
Yes, do some searching for 'DPI' or 'PLI'. If you have a SystemVerilog capable simulator the DPI solution is a lot less overhead. Basically the Verilog end of it will be:
import "DPI" function void do_http(...)
Where you can then call do_http within your Verilog like a normal task or function and you pass the .c file that implements do_http on the command line along with the rest of your sources. This of course is assuming that you're using a commercial Verilog simulator. I don't think Icarus supports DPI yet (could be wrong).
Using VPI is a more portable but takes significantly more coding to put together. I encourage you to research that one on your own if that's what you need.