2145 Reputation

19 Badges

4 years, 248 days

MaplePrimes Activity

These are answers submitted by C_R



Your problem has the following  structure




where the coefficients a, b, c, d are functions of λ0  λ1  λ2  λ3  µ1  µ2 and  µ3. (I assume in the following that you are able to express a, b, c, d as functions of λ0  λ1  λ2  λ3  µ1  µ2 and  µ3)
Solve now (1) for s

solve(s*(a*s^3+s^4+b*s^2+c*s^2+d), s)

0, RootOf(_Z^4+a*_Z^3+(b+c)*_Z^2+d)


You get the trivial solution and the roots for m, n, o, p in terms of a RootOf expression.
You can make them explict by

m, n, o, p := allvalues((0, RootOf(_Z^4+a*_Z^3+(b+c)*_Z^2+d))[2])

These are big expressions. Here is the solution for one of them






You can now substitute a, b, c, d into the solutions for n, m, o, p and try to simplify. If assumitions can be made on λ0  λ1  λ2  λ3  µ1  µ2 and  µ3 it is advisable to simplify a, b, c, d, first.



Download det_roots_ans.mw

Its not simplify throwing the error, its RootOf


Its difficult to find out more. I assume that RootOf does not look into 1/sin(_Z) because 1/sin(_Z) has no roots and looks for dependencies on other variables. Since RootOf cannot find any other variable it reports that there are none. If a root is added


one can observe how variables are changed to the place holder_Z in the RootOf call.

Maple does not have a built-in solution to prevent automatic simplification from removing a one from a product.

As is does not make sense to write 1 hour as h, it does not make sense mathematically to keep the one in a product. Edit: with units it makes sense now.

(Try whattype on your output and you will see that it is not a product any more.)

To get a printed one, you can find work-arounds here (all of which come with a drawback).
acers solution points toward a propper way: an inert 1 that could be evalauted to 1 by using the value command.

@MapleSoft: Please consider this for future releases

Below is an additional way that does not require typesetting knowlegde


restart; interface(version)

`Standard Worksheet Interface, Maple 2024.0, Windows 10, March 01 2024 Build ID 1794891`








In 2d-Math, select the 1`` below and convert it to atomic (using right-click)

a_one := `#mrow(mn("1"),mi("\`\`"))`












After computation, the atomic one can be removed by subs

subs(a_one = 1, `#mrow(mn("1"),mi("\`\`"))`*h)



subs(`#mrow(mn("1"),mi("\`\`"))` = 1, `#mrow(mn("1"),mi("\`\`"))`*h)



The second way (select and copypaste of GUI output) must be performed carefully to copy exactly the atomic one symbol and not more.




Technically, the injection at t=1 is called an event. An event normally requires reconfiuration of an ODE system. More on dsolve events under ?dsolve,numeric,Events. My understanding of the event options (maybe I am wrong) is that your event (ifelse(t=1,Dose,0)) cannot be given as an option. What you could do instead is splitting the problem at the event into two problems (one before and one after the event) and then plot everything with plots,display. By doing so the event becomes an initial condition for the second problem

However, before you do so, have a look at the event. As you defined it, it does not add any dose to the system because the timespan is infinite small. You need to define an injection amount. I have done this below by introducing a time span epsilon

k12 := 0.0452821;
k21 := 0.0641682;
k1x := 0.00426118;
Dose := 484;
Inj := Heaviside(t - 1) - Heaviside(t - 1 - epsilon);
epsilon := 0.1;
ode_sys := diff(SA2(t), t) = SA1(t)*k12 - SA2(t)*k21, diff(SA1(t), t) = Inj - k1x*SA1(t);
ics := SA2(0) = 0, SA1(0) = 0;
Solution1 := dsolve({ics, ode_sys}, {SA1(t), SA2(t)}, numeric);
plots:-odeplot(Solution1, [[t, SA1(t), color = "red", thickness = 1], [t, SA2(t), color = "blue", thickness = 1]], t = 0 .. 500, labels = ["Time t", "Salicylic acid"], labeldirections = [horizontal, vertical]);


Why not remove the differential from the start?

In your example you could have devided expression (1) by dz. This effectively transforms (1) into a differential quotient.

Maple does not accept differentials for integration but can work this way with differential quotients.



`τ_` = int(diff(`τ_`(z), z), z = l .. -l)

`τ_` = int(diff(`τ_`(z), z), z = l .. -l)


diff(`τ_`(z), z) = -I*z*B__0*x^2*_j/d^2-I*y*B__0*x^2*_k/d^2

diff(`τ_`(z), z) = -I*z*B__0*x^2*_j/d^2-I*y*B__0*x^2*_k/d^2


subs(diff(`τ_`(z), z) = -I*z*B__0*x^2*_j/d^2-I*y*B__0*x^2*_k/d^2, `τ_` = int(diff(`τ_`(z), z), z = l .. -l))

`τ_` = int(-I*z*B__0*x^2*_j/d^2-I*y*B__0*x^2*_k/d^2, z = l .. -l)



`τ_` = (2*I)*y*B__0*x^2*_k*l/d^2



 Mathematically, this is the exact way and (I assume) the reason why we don't find differentials in Maple, even though they are still widely used in physics and engineering.

Download RemoveDifferential_wothout_differential.mw

with 2024

(normal@expand@combine)((2), trig)

same as

normal(expand(combine(expr2, trig)))


You can use format strings to format the output as you want

a := 3*89/100.;
b := 3*21/100.;
printf("%g,%g,%6.2f,%9.2f", a, b, a, b);
                        a := 2.670000000

                       b := 0.6300000000

2.67,0.63,  2.67,     0.63

Newer versions of Maple have the context pannel (or right click on the output) for numeric formating. I don't know if that is possible in Maple 2016.


Prefixnotation is especially useful in functional programming where a sequence of commands is grouped using the composition operator @. It is way of separating functions (i.e. Maple commands) from arguments. Otherwise, nested commands with allot of parentheses have to be used.

There is little documentation on that and it is IMO not self-explaining. I got a pretty good explanation here in MaplePrimes. And here is a nice example of a self-made “unary prefix operator” that simplifies a rational expression. (I have put operator in quotation marks since depending on what is does it can equally be called function or command in Maple. In this example it is rather a command.)

I agree that for only two operands infix notation is often preferable. But in functional programming the number of operands (or better arguments if interpreted from a procedure perspective) can change in the course of processing composed commands.

I think a bit more explanatory documentation on top of dharr's examples would not harm.

I hope this completes the picture why Maple sometimes provides infix and prefix notation for the same operation. Functional programming without some prefix variants would be less powerful.


I have fixed a few errors

I assume that you are familar with Maple styles and in your question you want, for example, to change only the font of all Maple input in an existing document.

What you have to do is:

  • hide all other screen content using view-> show/hide contents
  • select all remaining content with the mouse
  • change the font
  • show the hinden content using view-> show/hide contents

Units in (4) are correct if t in (4) is evaluated with units. With units standard int must be mapped over a column vector (I don't know why that is).


with(VectorCalculus); SetCoordinates('cartesian[x, y, z]')




g := evalf(Constant(g, units))



`#mover(mi("\`v__0\`"),mo("&rarr;"))` := `<,>`(v[0]*Unit('m'/'s'), 0*Unit('m'/'s'), 0*Unit('m'/'s'))

Vector[column](%id = 36893490633426056244)


`#mover(mi("a"),mo("&rarr;"))` := `<,>`(0*Unit('m'/'s'^2), g, 0*Unit('m'/'s'^2))

Vector[column](%id = 36893490633436725244)


int(`#mover(mi("a"),mo("&rarr;"))`, t)

Vector[column](%id = 36893490633436713196)



Vector[column](%id = 36893490633436699932)



`#mover(mi("a"),mo("&rarr;"))` := <0*Unit(('m')/'s'^2), g, 0*Unit(('m')/'s'^2)>

Vector(3, {(1) = 0, (2) = g, (3) = 0})



Vector(3, {(1) = 0, (2) = g*t, (3) = 0})



Vector(3, {(1) = 0, (2) = g*t, (3) = 0})


Download Units_and_Integrals_reply.mw

I assume that you are able to generate plots for the exact and the approximate solution using the plot command.

Each of these plots have to be assigned to a name with the assignment operator :=

Then you can plot boths solutions in one plot using plots:- display command.

If you have these solutions in a worksheet and you can't manage to compare them, you could upload them using the green arrow.

To your question: How to calculate this integral?

My preliminary answer is: Don't use Maples sophisticated algorithms.

Zoomed in it looks like this

This could explain why Maples sophisticated integration methods have difficulties. They will try to follow all the oscillations.

Annother reason could be: The function you want to integrate is not always real valued also (see the attachment).

Could you tell a bit more about your integrand?

PS:: I have just seen Roubens answer. Zoomed it looks also jagged.


Do you want the new constant to have the highest index? If filling of gaps is acceptable

do n++ until not(has(_C||n,myconstants)):
new_constant := _C ||(n)

Otherwise, in your example myconstants is a set and the element with the highest index is to the right.

do n++ until is(_C||n=myconstants[-1]):
new_constant := _C ||(n)

I guess there are shorter ways

but you will get three bulky solutions

For clarity I assume in the following that you combine the coefficients into new ones.
Your equations will look like this


cos(3*phi)-a*cos(phi) = b



sin(3*phi)-a*sin(phi) = c



Solve for phi


4*cos(phi)^3-3*cos(phi)-a*cos(phi) = b


[[phi = arccos((1/6)*(27*b+3*(-3*a^3-27*a^2+81*b^2-81*a-81)^(1/2))^(1/3)-6*(-(1/12)*a-1/4)/(27*b+3*(-3*a^3-27*a^2+81*b^2-81*a-81)^(1/2))^(1/3))], [phi = Pi-arccos((1/12)*(27*b+3*(-3*a^3-27*a^2+81*b^2-81*a-81)^(1/2))^(1/3)-3*(-(1/12)*a-1/4)/(27*b+3*(-3*a^3-27*a^2+81*b^2-81*a-81)^(1/2))^(1/3)-((1/2)*I)*3^(1/2)*((1/6)*(27*b+3*(-3*a^3-27*a^2+81*b^2-81*a-81)^(1/2))^(1/3)+6*(-(1/12)*a-1/4)/(27*b+3*(-3*a^3-27*a^2+81*b^2-81*a-81)^(1/2))^(1/3)))], [phi = arccos(-(1/12)*(27*b+3*(-3*a^3-27*a^2+81*b^2-81*a-81)^(1/2))^(1/3)+3*(-(1/12)*a-1/4)/(27*b+3*(-3*a^3-27*a^2+81*b^2-81*a-81)^(1/2))^(1/3)-((1/2)*I)*3^(1/2)*((1/6)*(27*b+3*(-3*a^3-27*a^2+81*b^2-81*a-81)^(1/2))^(1/3)+6*(-(1/12)*a-1/4)/(27*b+3*(-3*a^3-27*a^2+81*b^2-81*a-81)^(1/2))^(1/3)))]]


You get 3 solutions for for phi that you can substitute one after each other into eq2



(1/18)*(-9*(((2/3)*a-2)*(27*b+3*(-3*a^3-27*a^2+81*b^2-81*a-81)^(1/2))^(2/3)+(3*b+(1/3)*(-3*a^3-27*a^2+81*b^2-81*a-81)^(1/2))*(27*b+3*(-3*a^3-27*a^2+81*b^2-81*a-81)^(1/2))^(1/3)+(a+3)^2)/(27*b+3*(-3*a^3-27*a^2+81*b^2-81*a-81)^(1/2))^(2/3))^(1/2)*((-a+3)*(27*b+3*(-3*a^3-27*a^2+81*b^2-81*a-81)^(1/2))^(2/3)+(9*b+(-3*a^3-27*a^2+81*b^2-81*a-81)^(1/2))*(27*b+3*(-3*a^3-27*a^2+81*b^2-81*a-81)^(1/2))^(1/3)+3*(a+3)^2)/(27*b+3*(-3*a^3-27*a^2+81*b^2-81*a-81)^(1/2))^(2/3) = c



Depending on the initial parameters you might be able to simplify further and select an equation that describes your problem

Download elliminate_phi.mw

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