Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Substitute expression for a symbolic function

I have the following variable and functions:

th = var('th')
f = function('f')(th)
omega = function('omega')(th)

and the equation:

eq = 2*pi*cos(th)*sin(th)*diff(omega,th,th)

Now, I want cos(th)*sin(th) to be substituted by f. I have tried the following:

eq = eq.substitute(cos(th)*sin(th)==f)

and also,

expression = cos(th)*sin(th)
eq = eq.substitute_function(expression,f)

but when I print eq, I still get:

2picos(th)sin(th)diff(omega(th), th)

How can I do it then?

I have found that a similar question was asked a long time ago:

https://ask.sagemath.org/question/29349/substitute-expressions-with-cos-and-sin/

where the author commented that maxima.fullratsubst did the job. However, I am not capable of working with it. I have run

eq = maxima.fullratsubst(f,cos(th)*sin(th),eq)

directly on SageMath, but I guess I am doing something wrong since it does not work.

Substitute expression for a symbolic function

I have the following variable and functions:

th = var('th')
f = function('f')(th)
omega = function('omega')(th)

and the equation:

eq = 2*pi*cos(th)*sin(th)*diff(omega,th,th)

Now, I want cos(th)*sin(th) to be substituted by f. I have tried the following:

eq = eq.substitute(cos(th)*sin(th)==f)

and also,

expression = cos(th)*sin(th)
eq = eq.substitute_function(expression,f)

but when I print eq, I still get:

2picos(th)sin(th)diff(omega(th), th)

How can I do it then?

I have found that a similar question was asked a long time ago:

https://ask.sagemath.org/question/29349/substitute-expressions-with-cos-and-sin/

where the author commented that maxima.fullratsubst did the job. However, I am not capable of working with it. I have run

eq = maxima.fullratsubst(f,cos(th)*sin(th),eq)

directly on SageMath, but I guess I am doing something wrong since it does not work.

Substitute expression multiplication of sine and cosine for a symbolic function

I have the following variable and functions:

th = var('th')
f = function('f')(th)
omega = function('omega')(th)

and the equation:

eq = 2*pi*cos(th)*sin(th)*diff(omega,th,th)

Now, I want cos(th)*sin(th) to be substituted by for f. I have tried the following:

eq = eq.substitute(cos(th)*sin(th)==f)

and also,

expression = cos(th)*sin(th)
eq = eq.substitute_function(expression,f)

but when I print eq, I still get:

2picos(th)sin(th)diff(omega(th), th)

How can I do it then?

I have found that a similar question question was asked a long time ago:

https://ask.sagemath.org/question/29349/substitute-expressions-with-cos-and-sin/

ago, where the author commented that maxima.fullratsubst did the job. However, I am not capable of working with it. it; I have run

eq = maxima.fullratsubst(f,cos(th)*sin(th),eq)

directly on SageMath, but I guess I am doing something wrong since it does not work.

Substitute multiplication of sine and cosine for a symbolic function

I have the following variable and functions:

th = var('th')
f = function('f')(th)
omega = function('omega')(th)

and the equation:

eq = 2*pi*cos(th)*sin(th)*diff(omega,th,th)

Now, I want cos(th)*sin(th) to be substituted for f. I have tried the following:

eq = eq.substitute(cos(th)*sin(th)==f)

and also,

expression = cos(th)*sin(th)
eq = eq.substitute_function(expression,f)

but when I print eq, I still get:

2picos(th)sin(th)diff(omega(th), th)

How can I do it then?

I have found that a similar question was asked a long time ago, where the author commented that maxima.fullratsubst did the job. However, I am not capable of working with it; I have run

eq = maxima.fullratsubst(f,cos(th)*sin(th),eq)

directly on SageMath, but I guess I am doing something wrong since it does not work.

Substitute multiplication of sine and cosine for a symbolic function

I have the following variable and functions:

th = var('th')
f = function('f')(th)
omega = function('omega')(th)

and the equation:

eq = 2*pi*cos(th)*sin(th)*diff(omega,th,th)

Now, I want cos(th)*sin(th) to be substituted for f. I have tried the following:

eq = eq.substitute(cos(th)*sin(th)==f)

and also,

expression = cos(th)*sin(th)
eq = eq.substitute_function(expression,f)

but when I print eq, I still get:

2picos(th)sin(th)diff(omega(th), th)

How can I do it then?

I would need it to work also for different permutations of the individual components of the equation. For example:

eq = 2*pi*sin(th)*diff(omega,th,th)*cos(th)

I have found that a similar question was asked a long time ago, where the author commented that maxima.fullratsubst did the job. However, I am not capable of working with it; I have run

eq = maxima.fullratsubst(f,cos(th)*sin(th),eq)

directly on SageMath, but I guess I am doing something wrong since it does not work.

Substitute multiplication of sine and cosine for a symbolic function

I have the following variable and functions:

th = var('th')
f = function('f')(th)
omega = function('omega')(th)

and the equation:

eq = 2*pi*cos(th)*sin(th)*diff(omega,th,th)

Now, I want cos(th)*sin(th) to be substituted for f. I have tried the following:

eq = eq.substitute(cos(th)*sin(th)==f)

and also,

expression = cos(th)*sin(th)
eq = eq.substitute_function(expression,f)

but when I print eq, I still get:

2'2picos(th)sin(th)diff(omega(th), th)th)'

How can I do it then? I would need it to work also for different permutations of the individual components of the equation. For example:

eq = 2*pi*sin(th)*diff(omega,th,th)*cos(th)

I have found that a similar question was asked a long time ago, where the author commented that maxima.fullratsubst did the job. However, I am not capable of working with it; I have run

eq = maxima.fullratsubst(f,cos(th)*sin(th),eq)

directly on SageMath, but I guess I am doing something wrong since it does not work.

Substitute multiplication of sine and cosine for a symbolic function

I have the following variable and functions:

th = var('th')
f = function('f')(th)
omega = function('omega')(th)

and the equation:

eq = 2*pi*cos(th)*sin(th)*diff(omega,th,th)

Now, I want cos(th)*sin(th) to be substituted for f. I have tried the following:

eq = eq.substitute(cos(th)*sin(th)==f)

and also,

expression = cos(th)*sin(th)
eq = eq.substitute_function(expression,f)

but when I print eq, I still get:

'2picos(th)sin(th)2 * pi * cos(th) * sin(th) * diff(omega(th), th)'th)

How can I do it then? I would need it to work also for different permutations of the individual components of the equation. For example:

eq = 2*pi*sin(th)*diff(omega,th,th)*cos(th)

I have found that a similar question was asked a long time ago, where the author commented that maxima.fullratsubst did the job. However, I am not capable of working with it; I have run

eq = maxima.fullratsubst(f,cos(th)*sin(th),eq)

directly on SageMath, but I guess I am doing something wrong since it does not work.

Substitute multiplication of sine and cosine for a symbolic function

I have the following variable and functions:

th = var('th')
f = function('f')(th)
omega = function('omega')(th)

and the equation:

eq = 2*pi*cos(th)*sin(th)*diff(omega,th,th)

Now, I want cos(th)*sin(th) to be substituted for f. I have tried the following:

eq = eq.substitute(cos(th)*sin(th)==f)

and also,

expression = cos(th)*sin(th)
eq = eq.substitute_function(expression,f)

but when I print eq, I still get:

2 * pi * cos(th) * sin(th) * diff(omega(th), th)

How can I do it then? I would need it to it? It should also work also for different permutations of the individual components of the equation. For example:

eq = 2*pi*sin(th)*diff(omega,th,th)*cos(th)

I have found that a similar question was asked a long time ago, where the author commented that maxima.fullratsubst did the job. However, I am not capable of working with it; I have run

eq = maxima.fullratsubst(f,cos(th)*sin(th),eq)

directly on SageMath, but I guess I am doing something wrong since it does not work.

Substitute multiplication of sine and cosine for a symbolic function

I have the following one variable and two functions:

th = var('th')
f = function('f')(th)
omega = function('omega')(th)

and the equation:following equation (this is an example, my actual equation has more terms such as +cos(th)+sin(th)):

eq = 2*pi*cos(th)*sin(th)*diff(omega,th,th)

Now, I want cos(th)*sin(th) to be substituted for f. I have tried the following:

eq = eq.substitute(cos(th)*sin(th)==f)

and also,

expression = cos(th)*sin(th)
eq = eq.substitute_function(expression,f)

but when I print eq, I still get:

2 * pi * cos(th) * sin(th) * diff(omega(th), th)

How can I do it? It should also work for different permutations of the individual components of the equation. For example:

eq = 2*pi*sin(th)*diff(omega,th,th)*cos(th)

I have found that a similar question was asked a long time ago, where the author commented that maxima.fullratsubst did the job. However, I am not capable of working with it; I have run

eq = maxima.fullratsubst(f,cos(th)*sin(th),eq)

directly on SageMath, but I guess I am doing something wrong since it does not work.