MaplePrimes Questions

I am having hard time understanding why Maple does this.

I have an integral, which maple could not integrate. So it returns int(....,x). Which is all fine. Then I used subsindets to force all terms in form e^(ln()+ln()+...) to expand in order to simplify the integrand, just for display purposes. 

subsindets returns back the integral unevaluated (as expected) but with integrand a little simpler, again as expected.

All is well so far.  

Then I find to my surprise, if I type the result back one more type, now the the integral actually evaluates.

Why? 

I have 2 questions on this.

1) If the original integral did not evaluate, why simplifying e^(ln()+ln()+...) makes it now evaluate? Did not Maple know this allready?

2) Why result back from subsindets remained unevaluated integral, and I had to type it again to see it now evaluates?

I found this after long time debugging, since this was done in code, not looking at screen. 

What happened is this: I store the result  of subsindets in a variable, and when I look at it in the debugger, I see int() still there, as expected.

I call a function to return back this result. I now see int() is gone!   So the act of just returning the result back, caused it to evaluate. Even though the orginal variable still had int() in it as. So returning the expression back, was equivalent to typing it again on the screen in the example below, which caused it to evaluate. 


Please see worksheet below.

interface(version);

`Standard Worksheet Interface, Maple 2020.2, Windows 10, November 11 2020 Build ID 1502365`

Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 882. The version installed in this computer is 881 created 2020, November 21, 11:11 hours Pacific Time, found in the directory C:\Users\me\maple\toolbox\2020\Physics Updates\lib\`

restart;

expr:=int(-1/2*exp((ln(a+cos(1/2*x)^2)+(-2*a-2)*ln(cos(1/2*x)))/a)*(-1+cos(x))/sin(1/2*x)/cos(1/2*x)/(a+cos(1/2*x)^2),x);

int(-(1/2)*exp((ln(a+cos((1/2)*x)^2)+(-2*a-2)*ln(cos((1/2)*x)))/a)*(-1+cos(x))/(sin((1/2)*x)*cos((1/2)*x)*(a+cos((1/2)*x)^2)), x)

#try again
expr;

int(-(1/2)*exp((ln(a+cos((1/2)*x)^2)+(-2*a-2)*ln(cos((1/2)*x)))/a)*(-1+cos(x))/(sin((1/2)*x)*cos((1/2)*x)*(a+cos((1/2)*x)^2)), x)

expr:=subsindets(expr,'specfunc( anything, exp )',f->(`if`(has(op(1,f),'ln'),expand(f),f)));

int(-(1/2)*(a+cos((1/2)*x)^2)^(1/a)*(-1+cos(x))/(cos((1/2)*x)^3*(cos((1/2)*x)^(1/a))^2*sin((1/2)*x)*(a+cos((1/2)*x)^2)), x)

#notice, the above is still int. Why is typing expr again, now makes it evaluate??
expr

-((4*a*exp(I*x)+exp((2*I)*x)+2*exp(I*x)+1)^(1/a)*exp(-((1/2)*I)*(2*csgn(I*exp(I*x)+I)*Pi*csgn(I*cos((1/2)*x))^2-2*csgn(I*exp(I*x)+I)*Pi*csgn(I*cos((1/2)*x))*csgn(I*exp(-((1/2)*I)*x))-2*Pi*csgn(I*cos((1/2)*x))^3+2*Pi*csgn(I*cos((1/2)*x))^2*csgn(I*exp(-((1/2)*I)*x))-Pi*csgn(I*exp(I*x))^3+2*Pi*csgn(I*exp(I*x))^2*csgn(I*exp(((1/2)*I)*x))-Pi*csgn(I*exp(I*x))*csgn(I*exp(((1/2)*I)*x))^2-Pi*csgn(I*a*exp(I*x)+((1/4)*I)*exp((2*I)*x)+((1/2)*I)*exp(I*x)+(1/4)*I)*csgn(I*a+(1/2)*I+((1/2)*I)*cos(x))^2+Pi*csgn(I*a*exp(I*x)+((1/4)*I)*exp((2*I)*x)+((1/2)*I)*exp(I*x)+(1/4)*I)*csgn(I*a+(1/2)*I+((1/2)*I)*cos(x))*csgn(I*exp(-I*x))+Pi*csgn(I*a+(1/2)*I+((1/2)*I)*cos(x))^3-Pi*csgn(I*a+(1/2)*I+((1/2)*I)*cos(x))^2*csgn(I*exp(-I*x))-4*x*a)/a)/((exp(I*x)+1)^(1/a))^2-2*(4*a*exp(I*x)+exp((2*I)*x)+2*exp(I*x)+1)^(1/a)*exp(-((1/2)*I)*(2*csgn(I*exp(I*x)+I)*Pi*csgn(I*cos((1/2)*x))^2-2*csgn(I*exp(I*x)+I)*Pi*csgn(I*cos((1/2)*x))*csgn(I*exp(-((1/2)*I)*x))-2*Pi*csgn(I*cos((1/2)*x))^3+2*Pi*csgn(I*cos((1/2)*x))^2*csgn(I*exp(-((1/2)*I)*x))-Pi*csgn(I*exp(I*x))^3+2*Pi*csgn(I*exp(I*x))^2*csgn(I*exp(((1/2)*I)*x))-Pi*csgn(I*exp(I*x))*csgn(I*exp(((1/2)*I)*x))^2-Pi*csgn(I*a*exp(I*x)+((1/4)*I)*exp((2*I)*x)+((1/2)*I)*exp(I*x)+(1/4)*I)*csgn(I*a+(1/2)*I+((1/2)*I)*cos(x))^2+Pi*csgn(I*a*exp(I*x)+((1/4)*I)*exp((2*I)*x)+((1/2)*I)*exp(I*x)+(1/4)*I)*csgn(I*a+(1/2)*I+((1/2)*I)*cos(x))*csgn(I*exp(-I*x))+Pi*csgn(I*a+(1/2)*I+((1/2)*I)*cos(x))^3-Pi*csgn(I*a+(1/2)*I+((1/2)*I)*cos(x))^2*csgn(I*exp(-I*x))-2*x*a)/a)/((exp(I*x)+1)^(1/a))^2+(4*a*exp(I*x)+exp((2*I)*x)+2*exp(I*x)+1)^(1/a)*exp(-((1/2)*I)*Pi*(2*csgn(I*exp(I*x)+I)*csgn(I*cos((1/2)*x))^2-2*csgn(I*exp(I*x)+I)*csgn(I*cos((1/2)*x))*csgn(I*exp(-((1/2)*I)*x))-2*csgn(I*cos((1/2)*x))^3+2*csgn(I*cos((1/2)*x))^2*csgn(I*exp(-((1/2)*I)*x))-csgn(I*exp(I*x))^3+2*csgn(I*exp(I*x))^2*csgn(I*exp(((1/2)*I)*x))-csgn(I*exp(I*x))*csgn(I*exp(((1/2)*I)*x))^2+csgn(I*a*exp(I*x)+((1/4)*I)*exp((2*I)*x)+((1/2)*I)*exp(I*x)+(1/4)*I)*csgn(I*a+(1/2)*I+((1/2)*I)*cos(x))*csgn(I*exp(-I*x))-csgn(I*a+(1/2)*I+((1/2)*I)*cos(x))^2*csgn(I*exp(-I*x))-csgn(I*a*exp(I*x)+((1/4)*I)*exp((2*I)*x)+((1/2)*I)*exp(I*x)+(1/4)*I)*csgn(I*a+(1/2)*I+((1/2)*I)*cos(x))^2+csgn(I*a+(1/2)*I+((1/2)*I)*cos(x))^3)/a)/((exp(I*x)+1)^(1/a))^2)/((a+1)*(exp(I*x)+1)^2)

 


 

Download why_it_now_evaluates.mw

Another simpler example, is just doing assignment to new variable. This causes evaluation.

restart;
expr:=int(-1/2*exp((ln(a+cos(1/2*x)^2)+(-2*a-2)*ln(cos(1/2*x)))/a)*(-1+cos(x))/sin(1/2*x)/cos(1/2*x)/(a+cos(1/2*x)^2),x);
expr:=subsindets(expr,'specfunc( anything, exp )',f->(`if`(has(op(1,f),'ln'),expand(f),f)));
#the above still has int() in it.

#this assignment, also causes evaluation
A:=expr;

 

converts a Maple polynomial into a list of its coefficients.

Suppose we have a parametric function g(x)=max{h(x,p),f(x,p)}. How can I find the exact form of g(x) by conditioning on x and also how I can find the integration of g(x) over an interval [a,b]?

For example, g(x)= max{ x-p, x^2+px} and [a,b]=[0,10].

I want to solve the following system of differential equations to find xphi, but I seem to be doing something wrong because I get an error message.

 

xodephi := {diff(x(t), t) = 16250.25391*(1 - (487*x(t))/168 + 4*Pi*x(t)^(3/2) + (274229*x(t)^2)/72576 - (254*Pi*x(t)^(5/2))/21 + (119.6109573 - (856*ln(16*x(t)))/105)*x(t)^3 + (30295*Pi*x(t)^(7/2))/1728 + (7.617741607 - 23.53000000*ln(x(t)))*x(t)^4 + (535.2001594 - 102.446*ln(x(t)))*x(t)^(9/2) + (413.8828821 + 323.5521650*ln(x(t)))*x(t)^5 + (1533.899179 - 390.2690000*ln(x(t)))*x(t)^(11/2) + (2082.250556 + 423.6762500*ln(x(t)) + 33.2307*ln(x(t)^2))*x(t)^6)*x(t)^5, diff(xphi(t), t) = 5078.204347*x(t)^(3/2), x(0) = 0.03369973351, xphi(10.92469316) = 0}

xsolphi := dsolve(xodephi, numeric)

Error, (in dsolve/numeric/bvp) precision is insufficient for required absolute error, suggest increasing Digits to approximately 25 for this problem

 

Later, I am interested in plotting xphi for t ranging from (11.92469316 - 1) to 11.92469316, but first I need to obtain a numerical solution for xphi in this region. Any advice?

Hey

Can anyone help me with this file?

I don't know how it happend, but the file somehow got corrupted. Is there anything i can do?

Thanks 

Videregående_beton_Gang_9.mw

 

 

A := Matrix(2, 2):
CodeGeneration:-Matlab(unapply(A), optimize, resultname = "A");

Warning, unable to optimize
Warning, procedure/module options ignored
function Areturn = A()
  Areturn = [0 0; 0 0;];
 

What is this behaviour. I can't find any explanation online.

Suppose you do this
 

restart:
with(plots):
with(Statistics):
A := Sample(RandomVariable(Normal(0, 1)), 10^4):
B := Sample(RandomVariable(Normal(0, 1)), 10^4):
ScatterPlot(A, B, symbol=point);

The plot shows a greater density of dots around (0, 0) and they become increasingly sparse as one moves away from (0, 0).
A pretty way to represent such clouds is to do "2D density plots".
You will find some example from R here  2d-density-plot-with-ggplot2.html

For the moment I do something like this (which is to be adpated for almost any particular case).
My main question is: do recent versions of MAPLE possess something similar to R's features?
 

restart:

interface(version);

`Standard Worksheet Interface, Maple 2015.2, Mac OS X, December 21 2015 Build ID 1097895`

(1)

with(Statistics):

UseHardwareFloats := false:

N := 10^5:
A := Sample(RandomVariable(BetaDistribution(2, 6)), N):
B := Sample(RandomVariable(BetaDistribution(6, 2)), N):

nb := 50:

mA := min(A):
hA := Range(A)/(nb-1):
mB := min(B):
hB := Range(B)/(nb-1):

cA := floor~((A-~mA)/~hA)+~1:
cB := floor~((B-~mB)/~hB)+~1:

NP := Matrix(nb$2, 0):
for n from 1 to N do
  NP[cA[n], cB[n]] := NP[cA[n], cB[n]]+1
end do:

NP:
 

plots:-matrixplot(
  NP,
  heights=histogram,
  colorscheme=["Blue", "White", "Red"],
  orientation=[270, 0, 0],
  style=patchnogrid,
  lightmodel=none,
  labels=["A", "B", ""],
  axis[1]=[tickmarks=[nb+1=max(B), 1=mB]],
  axis[2]=[tickmarks=[nb+1=max(A), 1=mA]]
)

 

 


 

Download 2D_density_plot.mw

 1. Consider this code line: > a := b; b := c; c := matrix([[1, 2, 3], [3, 4, 5]]);
    • if you ask Maple to return the values assigned to a, b and c, which values will be printed?
    • Are these values the ones you would expect? Why? Which kind of evaluation rule is utilized by Maple to return these values?
   • Show the single steps of the evaluation process and briefly explain the outcome of each evaluation step (hint: use eval (a, 1/2/3), to return each evaluation step).
   • How can you “force” Maple to return the “expected” values for a, b and c? • Extract the first row of the matrix in such a way to have [1, 2, 3] as output. Hint: use the command row/Row and its right syntax (it needs two arguments: the name of the matrix and the number of the row to extract). Be careful to load the linalg/LinearAlgebra package before using the command. Instruction: apply the row/Row command to a, b and c.
  • Can you explain what Maple does in the previous step? Can you explain, in other words, why you get the expected outcome? Hint: remember which are the “drivers” of the evaluation process in Maple (position of the assignment/level of evaluation; type of object / data-structure / datacontainer / procedures / local versus global variables / use of built-in commands, etc.).

      how to write a procedure that shuffle a matrix  (c:=matrix([[1,2,3],[3,4,5]] ) by using command randperm in maple?

What is the logic behind this. 

restart;
expr:=int(f(x),x);
lprint(algsubs(int=Int,expr));
lprint(subs(int=Int,expr));

gives


   int(f(x),x)

   Int(f(x),x)

So algsubs failed to replace int by Int

Looked at help. and see nothing. But I might have overlooked something. It says

It is a generalization of the subs command, which only handles syntactic substitution.

Generalization? If so, I expected it to work here. But may be there is a subtle reason why it did not? May be with algsubs, the replacement has to be algebraic expression and "int" is not, it is just a name.

Maple 2020.2
 

Hello Maple experts.

According to our teacher class notes, the ODE   y'=2*sqrt(y) with IC  y(0)=0 has 2 solutions. y(0)=0 and sqrt(y)=x

I am not able to get Maple to give the second solution,. It only gives y(0)=0.

Is there an option I am overlooking to make it give the other solution sqrt(y)=x ?

ode := diff(y(x),x) = 2*sqrt(y(x));
ic:=y(0)=0;
sol:=dsolve([ode,ic],y(x));

One can see the other solution by doing this

ode := diff(y(x),x) = 2*sqrt(y(x));
ic:=y(0)=A;
sol:=dsolve([ode,ic],y(x));
subs(A=0,sol)

I tried this in Mathematica. Mathematica does not give y=0 but it gives the second solution

I tried the singsol=all also, but it had no effect. Maple only shows the y(0)=0 solution.

Any suggestions?

Maple 2020.2

 

Hello everyone,

I have a question about adding references to a non executable math in a document. Namely, If we use an executable math there is a label that appears on the right of a formula. We can use it as a reference. However, there is no label when we use non-executable math. I wonder how can I refer to that, the point is to create a document with a references to formulas.

To illustrate the point I would like to create a text like the following :

...

X=2 (equation 1)

X=3 (equation 2)

.....Some text here......

From the (equation 2) we can achieve that ....

Regards

Hi

cant get the answer, any comments plz

f := (x, y) ->(1/2)*a*(sinh(y-x^2)+tanh(x-y^3));

evalf(int(int(f(x, y), x = -6 .. 5), y = -5 .. 5)):

Is there any simple way to combine the commands ChromaticNumber(G) and DrawGraph(G), in order to get a vertex coloring of a graph G? Thanks

Hi everybody,

This is my code:

assume(0 < a, 0 < L, a < L);

M := piecewise(0 <= x and x < a, P*x*(L-a)/L, a <= x and x < L, P*a*(L-x)/L);
ode := diff(y(x), `$`(x, 2)) = M/(E*I__0);
ic := y(0) = 0, y(L) = 0;
sol := factor(dsolve([ode, ic], y(x))); assign(sol); y1 := y(x);

I have two questions:

1) How to plot y1?

I would like to plot y1, but in the plot can to specify a values of a, L, P, E and I.

2) How can I find a maximun and minimun value of y1?

I tried to use maximize and minimize commands but really I don't know if I used them correctly.

Thank you.

 

 

First 480 481 482 483 484 485 486 Last Page 482 of 2434