Ask Your Question

Liang's profile - activity

2024-04-14 15:11:43 +0200 received badge  Notable Question (source)
2024-04-14 15:11:43 +0200 received badge  Popular Question (source)
2023-10-27 17:51:56 +0200 received badge  Famous Question (source)
2021-11-19 17:39:20 +0200 asked a question User defined function

User defined function I'm working with beta distribution and its integral. A straightforward integral of beta distributi

2021-02-24 18:19:25 +0200 received badge  Notable Question (source)
2020-10-29 04:36:00 +0200 received badge  Notable Question (source)
2020-04-12 16:24:11 +0200 received badge  Notable Question (source)
2018-10-07 02:43:50 +0200 received badge  Popular Question (source)
2018-08-29 04:54:44 +0200 received badge  Popular Question (source)
2017-02-08 23:06:45 +0200 received badge  Popular Question (source)
2016-04-28 08:54:47 +0200 received badge  Scholar (source)
2016-04-28 08:54:42 +0200 commented answer Slow conversion of symbolic expression to sympy

This works great. Thank you!

2016-04-20 07:07:37 +0200 commented question Slow conversion of symbolic expression to sympy

Here's a short example. It takes about 40 seconds to finish the conversion.

C=matrix(SR, 3, 3, var('C11, C12, C13, C21, C22, C23, C31, C32, C33'))

F=matrix(SR, 3, 3, var('F11, F12, F13, F21, F22, F23, F31, F32, F33'))


Cg=matrix(SR, 3, 3, var('Cg11, Cg12, Cg13, Cg21, Cg22, Cg23, Cg31, Cg32, Cg33'))

Fg=matrix(SR, 3, 3, var('Fg11, Fg12, Fg13, Fg21, Fg22, Fg23, Fg31, Fg32, Fg33'))

Fg_inv=Fg.inverse()

Ce=Fg_inv.T*C*Fg_inv

Fe=F*Fg_inv

Cedet=Ce.det()

Je=sqrt(Cedet)

W=(Je-1)^2

S_PK=Matrix(SR, 3,3, jacobian(W, C.list()).list())

S=Fe*S_PK*Fe.T*Je**(-1)

CF=F.T*F

out1=S[0,0].substitute([(C.list())[i]==(CF.list())[i] for i in xrange(9)])._sympy_()

enter code here

2016-04-19 03:39:19 +0200 asked a question Slow conversion of symbolic expression to sympy

I need to convert symbolic expressions to sympy for code generation using codegen. The symbolic expressions are very long and right now it could take hours to finish the sage to sympy conversion. Any idea to speed things up? Thanks.

2016-03-08 23:19:01 +0200 received badge  Supporter (source)
2016-03-08 23:18:58 +0200 commented answer How to separate a symbolic expression into sub expressions

Thank you so much!

2016-03-08 09:49:54 +0200 commented answer How to separate a symbolic expression into sub expressions

I should have put a more well-thought example out. My function is separable; i.e., f=f1(x)*f2(y,z,.....). What I want is to extract the f1(x) part and then run numerical integration of f1 over x.

2016-03-08 09:13:14 +0200 asked a question How to separate a symbolic expression into sub expressions

I want to separate a symbolic expression into two sub-expressions, one sub-expression with a certain variable and the other without the variable.

The following example was revised to better demonstrate what I want to achieve

For example, with the following function, f,

var('x,y,z')
f=cos(x)*e^(cos(x))*(3*y+z)^2

I want to obtain two sub-expressions as

f1=cos(x)*e^(cos(x))
f2=(3*y+z)^2
2016-03-08 00:44:28 +0200 commented answer Display symbolic expressions without expansion

Thank you for the suggestion. What I want to achieve is to have a "normal" symbolic expression that can be displayed in an easily readable form. Normal here means it can be differentiated or integrated etc. My final expression involves many very complicated functions of the matrix "cc" and displaying with all those functions fully expanded would make the final outcome almost impossible for human to understand.

2016-03-07 21:17:00 +0200 received badge  Editor (source)
2016-03-07 21:12:32 +0200 asked a question Display symbolic expressions without expansion

I'm trying to write symbolic expressions with many intermediate variables. When I use the "show" function to display the final symbolic expression, it always shows the expression with the intermediate variables fully expanded. How can I show the final expression in terms of intermediate variables? Here is a simplified example:

var('t')
cc=matrix(SR, 3, 3, t)
I1=cc.trace()
Q=exp(I1)

show(Q)

With the above code, the output would be

\begin{equation} Q=e^{3t} \end{equation}

How can I generate an output as \begin{equation} Q=e^{I1} \end{equation}

2015-08-26 04:56:30 +0200 commented answer Substitute expressions with cos and sin

Thank you very much for you suggestions.

For people have similar needs as mine, I found maxima.fullratsubst did the job.

2015-08-25 15:56:04 +0200 received badge  Student (source)
2015-08-25 01:18:52 +0200 asked a question Substitute expressions with cos and sin

I'm trying to simplify a symbolic expression obtained from sage integration. It contains terms of cos(theta)^2sin(theta)^2 and many others. I wanted to collect the coefficients of cos(theta)^2sin(theta)^2 and used subs_expr for this purpose. Here's a simplified version of what I'm trying to do:

var('theta,x,Psi')
y(theta)=cos(theta)^2*sin(theta)^2*cos(Psi)
y.subs_expr(cos(theta)^2*sin(theta)^2==x)

The result I got was "theta |--> cos(Psi)cos(theta)^2sin(theta)^2", not the expected "x*cos(Psi)". How can I get my expected result?