Items tagged with applyrule applyrule Tagged Items Feed

Hello everyone,


I am working on a program in Maple and got stuck in exchanging limits for integrals. For example, if I have an expression of following type.

Eq:=4*Int(f(x), x=0..1/3)+Int(x*f(x), x=0..2/3);

I want to convert it in to an expression of form

4*Int(f(x),x=0..x)-4*Int(y,x=1/3..x)+ Int(x*f(x), x=0..x)- Int(x*f(x), x=2/3..x)

In short, I want to split both the integral at x but flip in limits in the second integral. I tried as follows which did not work

applyrule(Int(f::anything,y=c::numeric..d::numeric)=Int(f,y=c..x)-Int(f,y=c..x), Eq)

Please, help me!

Thank you for your time.

I am trying to do a substitution as shown in the attached document. I know variants of this question have been asked before but dont quiet get what to do. It is problem with algsubs and how it handles denominators I think. Can get substiturion to work for simple fractions but more complicated ones fail. Would appreciate any guidance here.




CR := proc (a, b, c, d) options operator, arrow; (a-c)*(b-d)/((a-d)*(b-c)) end proc

proc (a, b, c, d) options operator, arrow; (a-c)*(b-d)/((a-d)*(b-c)) end proc


eqns := CR(a, b, c, d)



e1 := CR(b, a, c, d)



simplify(e1, {(a-c)*(b-d)/((a-d)*(b-c)) = lambda})










applyrule((a-c)*(b-d)/((a-d)*(b-c)) = lambda, e1)



alias(lambda = (a-c)*(b-d)/((a-d)*(b-c)))









f := a/b




f := algsubs(a/b = alpha, f)






algsubs((a-c)*(b-d)/((a-d)*(b-c)) = lambda, e1)

Error, (in algsubs) cannot compute degree of pattern in a





Hi everyone,


I have a question regarding the use of the applyrule function. I have an expression that contains a polynomial. The expression looks something like:


Y := (a0 + a_1*x + a_2*x^2 + ... a_n*x^n)*f(y) + b_0 + b_1*x + b_2*x^2 + ... b_n*x^n)*g(y):


I would like to express this as y(x) = P_1*f(y) + P_2*g(y).


So far I have tried applyrule([a0 + a_1*x + a_2*x^2 + ... a_n*x^n = P_1, b_0 + b_1*x + b_2*x^2 + ... b_n*x^n) = P_2],Y):


This doesn't seem to work. Any suggestions?





Dear people in Mapleprimes,


alpha-gamma*q[k]-eta*(int(q[i], i = 0 .. M__n))-eta*q[k] = p[k];



algsubs(-eta*(int(q[i], i = 0 .. M__n))-eta*q[k] = -eta*(int(q[i], i = 0 .. M__n)), alpha-gamma*q[k]-eta*(int(q[i], i = 0 .. M__n))-eta*q[k] = p[k]);


This works fine.



applyrule(-eta*(int(q[i], i = 0 .. M__n))-eta*q[k] = -eta*(int(q[i], i = 0 .. M__n)), alpha-gamma*q[k]-eta*(int(q[i], i = 0 .. M__n))-eta*q[k] = p[k]);


This doesn't bring an right replacement.


What difference is there between applyrule and algsubs?


Best wishes








tmp := Vector(2, {(1) = 1+(-s[2]-s[4]+2*w[1]/(1+1/exp(mu[p]))^2+(-2*w[1]+2)/(1+1/(exp(mu[p])*exp(eta[p2])))^2)*s[1]^3+(-s[2]+s[3])*s[1]^2-s[2]*s[1], (2) = (s[2]+s[4]-2*w[1]/(1+1/exp(mu[p]))^2-(-2*w[1]+2)/(1+1/(exp(mu[p])*exp(eta[p2])))^2)*s[1]^3})


rule3:=w[1]/(1+1/exp(mu[p]))^2+(-w[1]+1)/(1+1/(exp(mu[p])*exp(eta[p2])))^2 = s[3];

w[1]/(1+1/exp(mu[p]))^2+(-w[1]+1)/(1+1/(exp(mu[p])*exp(eta[p2])))^2 = s[3]










This is part of a large simplifcation where lots of terms are being substituted. In two of those terms, it did not simplify as we would expect.

I think the main thing is trying to find a way to factor out the "2".


I could do this

> rule3:=w[1]/(1+1/exp(mu[p]))^2+(-w[1]+1)/(1+1/(exp(mu[p])*exp(eta[p2])))^2 = s[3];

> rule3ne:=-(w[1]/(1+1/exp(mu[p]))^2+(-w[1]+1)/(1+1/(exp(mu[p])*exp(eta[p2])))^2) = -s[3];
> rule3ne:=2*rule3ne;

> applyrule(rule3,tmp[1]);
> applyrule(rule3ne,tmp[2]);

For this example, this works.

But I hope for a more generic approach.








Hello people in Mapleprimes,


I want to know how to use apply rule in the following problem.

Please tell me how to do about this.


returns F(2*K,2*L), which is right.

But, what I want to do is to apply the rule with holding n as general variable of real number.

But, what I can get through 


is only 2*F(K,L) not F(2*K,2*L).


What should I write additinally to the above to have Maple calcurate and produce the outcome as F(2*K,2*L), F(3*K,3*L) and so on?


Best wishes.





Hi Everyone,

I have an expression that contains a second order derivative: EXPR:=ay''(x) + bz'(x) + cf'(x)+... The variable y  obeys an ordinary differential equation, y''(x) = f(y,x). I would like to replace the second order deriavtive in my expression with f(y,x). So far I have tried applyrule([y''(x)=f(y,x)],EXPR), subs(y''(x)=f(y,x),EXPR) and algsubs(y''(x)=f(y,x),EXPR) and nothing seems to work. Any helpful suggestions?


kappa := Vector(7, [1,w[1]*(1-phi+phi*(1-1/(1+exp(-mu[p]-tau[p3]))))+(1-w[1])*

Download kappa.txt

Here is the expression, I am trying to simplify, given a set of rules.

I have tried different substitutions, using simplify with side rules, applyrule, eval, subs, algsubs.

But none seem to be working as the way I want them to be.


Is there a better way?



Hi everyone,

I have a maple program that generates a polynomial g(y)=(80y^8 + 68y^6 + 12y^4 -4y^2 -1). This polynomial has two real roots (irrational roots), call them +/- y*. My code does a sequential calculation, and often sI am left with a higher order polynomial in y that has the form h(y)= p(y)*g(y), where p(y) is also a polynomial in y. This polynomial h(y)=p(y)*g(y) is not in factored form (i.e. it would look like expand(p(y)*g(y)). Is there a way to instruct maple to recoginize that +/-y* is also a root h(y)=p(y)*g(y)? So far I've tried things like applyrule([g(y*)=0],h(y*)), but nothing seems to work (I suspect because Maple cannot recgonize that g(y) is a factor of h(y)). I am not interested in computing this numerically. I am just trying to find a way to instruct Maple to recognize symbolically that h(y*) =0.

Thanks a million for anyone who has any idea.




I am trying to make a substitution:

> restart;
> f1 := conjugate(z)^2*z^2;
> f2 := applyrule(z*conjugate(z) = x, f1);

however the result is

f2 := conjugate(z)^2*z^2

Do you have any ideas how to solve the problem? Thank you.

I have the following expression (obtained from an earlier calculation):

I want to collect all the terms under one summation. So I define a rule:

end proc:

and then


I get

Error, (in +) unable to identify A::algebraic

I used similar constructs before so I think the rule is constructed correctly. I should, however, mention that I use the Physics:-Vectors package and in fact the expression I start up with here reads, in 1-d Maple inputform:

Physics[Vectors][`+`](Physics[Vectors][`+`](Physics[Vectors][`+`](-y*(Sum((diff(a[n](r), r))/(exp(I*Pi*n/L))^2, n))/r, (2*I)*(Sum(a[n](r)/(exp(I*Pi*n/L))^2, n))*k0), y*(Sum(a[n](r)/(exp(I*Pi*n/L))^2, n))*k0^2), -y*(Sum((diff(a[n](r), r, r))/(exp(I*Pi*n/L))^2, n)))

Is my problem related to the use of Physics:-Vectors? If so, how can I get around that?


Mac Dude


I have a differential equation:

an the solution:

I want to substitute

ekf := omega = sqrt(c/m);

algsubs(ekf, sol);
but sol does not change.

This works a bit but does not substitute everything in a way that you would expedect

This is the result:

Thanks in advance


I have an expression which contains terms like cos(3*x)*cos(x) + sin(3*x)*sin(x). In this expression, I replace the prevous terms by using applyrule as:

applyrule([cos(3*x)*cos(x)=1/2*(cos(2*x)+cos(4*x)), sin(3*x)*sin(x)=1/2(cos(2*x)-cos(4*x))],expr);


Is there a way to generalize this so that I may replace all forms of sin(n*x)*sin(m*x) = 1/2(cos((n-m)*x)-cos((n+m)*x))?


Thanks for your help.

I have a question about the "applyrule" function. I have an expression that looks like:


exprsn1:=sin(z)(Acos(z) + Bcos(x)cos(2z) + Ccos(x));


I would like to express cos(2z)sin(z) in the form 1/2(sin(3z)-sin(z)). However, when I use the "applyrule" as:

exprsn2 := applyrule(sin(z)cos(2z)=1/2(sin(3z)-sin(z), exprsn1);

it returns the same expression. Is there something else I should be doing before I use applyrule?

Following an earlier thread (Collect-And-Sqrt) where a solution using applyrule was proposed (and that solution works), I tried to use applyrule to implement some of the trig half-angle relationships. Immediately I ran into trouble:

Say I want to use the rule


so I say


and Maple promptly goes into an...

1 2 Page 1 of 2