Items tagged with diff



I have some matrix valued functions that that I can only define piecewise. Unfortunately I have some problems to manipulate those functions. Piecewise sees to do the job for  scalar valued functions. There I can easily differentiale and add results. For Matrix valued functions however, those features seem to not be availible.

I can work around these limitations by manually applying all operations to the operands of the piecewise function. Like I show here:



# a piecewise function


p1 := piecewise(a(t)^2 = 0, Vector(2, {(1) = cos(a(t))^2+sin(a(t))^2, (2) = 0}), Vector(2, {(1) = 1, (2) = 1/a(t)}))


# differentiation does not work


diff(piecewise(a(t)^2 = 0, Vector(2, {(1) = cos(a(t))^2+sin(a(t))^2, (2) = 0}), Vector(2, {(1) = 1, (2) = 1/a(t)})), t)


# selecting individual entries does not work


r := (piecewise(a(t)^2 = 0, Vector(2, {(1) = cos(a(t))^2+sin(a(t))^2, (2) = 0}), Vector(2, {(1) = 1, (2) = 1/a(t)})))(1)+1


# strange simplification behaviour


piecewise(t = RootOf(a(_Z)), _z1(RootOf(a(_Z))), Vector(2, {(1) = 1, (2) = 1/a(t)}))


# current workaround, define new piecewise function by using op


r := piecewise(a(t)^2 = 0, cos(a(t))^2+sin(a(t))^2+1, 2)






I think my workaround is very cumbersome and error prone. Is there a better way to tackle this probem? Or should I try to overload all needed operations, and is this even possible?

Thanks for all suggestions!


I am relatively new to maple and am using it for a multivariate calculus class.

I want to define a function g(x,y) which is the derivative of f(x,y).

I am trying:

which is my function, and

which should be the derivative.

When I try g(x,y) I get

but when I try to put numerical values in the first argument, (eg: f(1,y) I get

"Error, (in g) invalid input: diff received 1, which is not valid for its 2nd argument"
Any tips?

subs can not make diff(1, t) = 0

sys := simplify(subs(diff(1,t)=0,subs(c(t)=1,[ode1a,ode3a])));
sys := [diff(a(t), t) = 1.342398800*10^5*a(t)+89591*b(t)+44647, 44647*a(t)+44902*b(t)+44859];

DEplot(sys, [a(t), b(t)], t = 0 .. 16, a = -16 .. 16, b = -16 .. 16, color = magnitude, title = `Stable Limit Cycles`, arrows = curve, dirfield = 800, axes = none);
Error, (in DEtools/DEplot/CheckDE) derivatives must be given explicitly

why can not plot?


please see the attached worksheet and assist me with understanding why these unusual results are computed.

simplify(op((diff(z/sqrt(z^2), [`$`(z, k)]))/pochhammer(1-k, k))[1]^(1/k), 'symbolic')

simplify(simplify(op((diff(z/sqrt(z^2), [`$`(z, k)]))/pochhammer(1-k, k))[2]^(-1/k)-op((diff(z/sqrt(z^2), [`$`(z, k)]))/pochhammer(1-k, k))[1]^(1/k)*z, 'symbolic'))



Not sure if this is documented explicitly to Maple users, but normally (prior to Maple 2017) interface(typesetting=extended) was all that was required to output display diff(y(x),x) as y'(x)

With Maple 2017 typesetting=extended is default and one must use with(Typesetting)  Settings(typesetprime=true) in order to output the display of diff(y(x),x) as y'(x).

Perhaps this is well documented somewhere, however I was unable to find the change. 

I know the latex() command in Maple have many issues and I have no hope of what I will ask having a solution, but thought to ask any way.

Is there a way to make maple generate the latex for all the derivatives to use ' instead of d/dx ?

for example, given this


The Latex generated (which is correct) is

{\frac {\rm d}{{\rm d}x}}y \left( x \right) =x

but sometines I find it more readable if the latex was


which is more common in textbooks and other places. The problem also is that I am using worksheet so can't use  y'(x) as input.

But even switching to document mode, and writing it 2D math as input, the Latex output still does not match the input

So if there is a solution to this, would it require changing the latex() command itself? or can it be done at user level?

I'd like all orders of derivatives anywhere in the equation to come out as y'' etc.. so diff(y(x),x$3) should generate the latex y'''(x) and so on.

Is there a trick to do this?

Maple 2017.2




I'm trying to write and simplify expressions involving partial derivatives of an arbitrary function, say f(x,y).

Specifically, I would like diff(f(t,y),t) to evaluate to D[1](f)(t,y), instead of 

And eval(diff(f(x,y),x),x=t) gives the same result. 

Interestingly, diff(f(2*t,y),t) does evaluate to 2*D[1](f)(2*t,y), as expected.

I could get some results by using a custom differentiation function

`diff/f` := proc(x,y,v) 
    if v = x then return D[1](f)(v,y):
    elif v = y then return D[2](f)(x,v):
    else return 0: # is there a fallback I can use without risking infinite recursion?
end proc:

and it works for the simple case, but now diff(f(2*t,y),t) does not work.

All this makes me feel that there must be a way to get what I want by default, but I can't figure it out.

Is there? Thank you in advance!

Hi, i have a problem with subs instruction. I'd like to change a function D(s) with symbol d/ds d(t), but i won't to calculate derivate, I want only change symbol. Thanks a lot.

I'm still quite new to maple and I'm working calculating some dynamic equations.

I want to be able to selectively group certain variables or numbers depending on how I need the equations to be showed, I don't know if that's possible, I´ll explain further.

In typewritting extended format one equation is shown like this:



And maple standard:


The fisrt thing I want is to show the time derivatives in the dot representation, but I also want the 1/2 multiplyting each term of the whole equation like in the maoke standard format. 

I also need to group certain variables in some other equations I have and I was wondering if there is a way to do this.

Since I am a very recent Maple user, I do not know why I obtained a wrong answer with the following two comands:

Exp:= Psi(rho(x,t),theta(x,t));
                  Psi(rho(x, t), theta(x, t))
Exp1:= diff(Exp,t);
     / d           \                                  
     |--- rho(x, t)| D[1](Psi)(rho(x, t), theta(x, t))
     \ dt          /                                  

          / d             \                                
    + |--- theta(x, t)| Psi(rho(x, t) + 1, theta(x, t))
          \ dt            /                                

Can someone, please, help me?

Thank you.


I want to know the partial derivative of


in order to 


If I write 

I obtain this


which is incorrect  since I did not have any indexes in sigma. However if I do this next command the result seems correct although no substituion of rhocrf

What I would like to obtain was the solution in order to rho and not to rhocrf and additionally having the result as a summation over p and q and not the extended result. How should I write it in Maple then? 


Thank you very much!


z := Diff(x(t),t)*y(t) + x(t)*Diff(y(t),t);

Is there a way to tell Maple to collapse that into Diff(x(t)*y(t), t) ?

I tried factor, combine, simplify, but none of them worked.



hi .in substuting in ode equation i encounter with error

Error, (in eval/diff) invalid input: diff received (f1[i+1, i]-2*f1[i, i]+f1[i-1, i])/h^2, which is not valid for its 2nd argument

please help me


restart; with(DEtools); with(plots); interface(rtablesize = 25); ode1 := -P1*(diff(f1(x, y), x, x, x, x, x, x)+diff(f1(x, y), y, y, y, y, y, y)+3*(diff(f1(x, y), x, x, x, x, y, y))+3*(diff(f1(x, y), x, x, y, y, y, y)))+P2*(diff(f1(x, y), x, x, x, x)+diff(f1(x, y), y, y, y, y)+2*(diff(f1(x, y), x, x, y, y)))-N_x*(diff(f1(x, y), x, x))-N_y*(diff(f1(x, y), y, y)); F1xx := i, proc (j) options operator, arrow; (f1[i+1, j]-2*f1[i, j]+f1[i-1, j])/h^2 end proc; F1yy := i, proc (j) options operator, arrow; (f1[i, j+1]-2*f1[i, j]+f1[i, j-1])/hy^2 end proc; F1xxxx := i, proc (j) options operator, arrow; (f1[i+2, j]-4*f1[i+1, j]+6*f1[i, j]-4*f1[i-1, j]+f1[i-2, j])/h^4 end proc; F1yyyy := i, proc (j) options operator, arrow; (f1[i, j+2]-4*f1[i, j+1]+6*f1[i, j]-4*f1[i, j-1]+f1[i, j-2])/hy^4 end proc; F1xxxxxx := i, proc (j) options operator, arrow; (f1[i+3, j]-6*f1[i+2, j]+15*f1[i+1, j]-20*f1[i, j]+15*f1[i-1, j]-6*f1[i-2, j]+f1[i-3, j])/h^6 end proc; F1yyyyyy := i, proc (j) options operator, arrow; (f1[i, j+3]-6*f1[i, j+2]+15*f1[i, j+1]-20*f1[i, j]+15*f1[i, j-1]-6*f1[i, j-2]+f1[i, j-3])/hy^6 end proc; F1xxyyyy := i, proc (j) options operator, arrow; (f1[i-1, j-2]-4*f1[i-1, j-1]+6*f1[i-1, j]-4*f1[i-1, j+1]+f1[i-1, j+2]-2*f1[i, j-2]+8*f1[i, j-1]-12*f1[i, j]+8*f1[i, j+1]-2*f1[i, j+2]+f1[i+1, j-2]-4*f1[i+1, j-1]+6*f1[i+1, j]-4*f1[i+1, j+1]+f1[i+1, j+2])/(hy^4*h^2) end proc; F1yyxxxx := i, proc (j) options operator, arrow; (f1[i-2, j-1]-2*f1[i-2, j]+f1[i-2, j+1]-4*f1[i-1, j-1]+8*f1[i-1, j]-4*f1[i-1, j+1]+6*f1[i, j-1]-12*f1[i, j]+6*f1[i, j+1]-4*f1[i+1, j-1]+8*f1[i+1, j]-4*f1[i+1, j+1]+f1[i+2, j-1]-2*f1[i+2, j]+f1[i+2, j+1])/(h^4*hy^2) end proc; eq := simplify(eval(ode1, {diff(f1(x, y), x, x) = F1xx(i, j), diff(f1(x, y), y, y) = F1yy(i, j), diff(f1(x, y), x, x, x, x) = F1xxxx(i, j), diff(f1(x, y), y, y, y, y) = F1yyyy(i, j), diff(f1(x, y), x, x, x, x, x, x) = F1xxxxxx(i, j), diff(f1(x, y), x, x, x, x, y, y) = F1yyxxxx(i, j), diff(f1(x, y), x, x, y, y, y, y) = F1xxyyyy(i, j), diff(f1(x, y), y, y, y, y, y, y) = F1yyyyyy(i, j)}))

Error, (in eval/diff) invalid input: diff received (f1[i+1, i]-2*f1[i, i]+f1[i-1, i])/h^2, which is not valid for its 2nd argument










diff(f1(x, y), x, x, y, y, y, y)

diff(diff(diff(diff(diff(diff(f1(x, y), x), x), y), y), y), y)








Dear all:

I have used the "diff" command in Maple to help me derive a huge and very long function, and now I want to convert this huge expression from Maple to Matlab format, for example, into a Matlab .m file. The format of this expression in Maple is very different from Matlab.

So could you help me with this problem?

Thank you all.

Hello, I have a function defined as

                                                   g :=  (x, y)->diff(u1(x, y), x, x)+diff(u2(x, y), x, y). 

I want to define another function as follows

                                                           f :=  (y) ->subs(x = 0, g(x, y)) ,

Now, when I want to calculate numerical values for the new function f(0), f(0.1), f(0.2),..... and so on. The following massage appear

Error, (in f) invalid input: diff received 0, which is not valid for its 2nd argument.

What is the problem here.




1 2 3 4 5 6 7 Last Page 1 of 13