C_R

3577 Reputation

21 Badges

6 years, 96 days

MaplePrimes Activity


These are replies submitted by C_R

@zenterix 

The only documentation I read was the programming guide. To me it is more than a programming guide because it explains for a good extend Maples foundation. Maybe you should ask for a recommendation in a separate thread.

 

@salim-barzani 

Generate a plot for each parameter and then use plots:-display to plot all in once. Additionally you can use the legend option to label the plot, see ?plot,options

@salim-barzani 

I do not have time to look at it. What I see from the screen shots is that the solution does not look strucurally identical

I those situations I would enter the text book solution first and see how it plots. Then I would investigate the own solution.

@nm 

I am not aware of such a setting but I see that it could make sense as a GUI option. Maple has control over the cursor position since it is needed for editing. I assume that the initial cursor setting is unsing a Java default. Only Maplesoft can tell if this is correct.

Rondom jumps of the cursor position is something which should not happen. Maybe it is the cause that I get from time to time a split of 1D input into two lines of an execution group. I.e. enter is working as "shift enter" and creates a new line inside and execution group. I have to use "!" to execute. I never understood  why and when this happens.

@zenterix 
You must do it by hand, because the output of solve is a simplification endpoint of Maple (what Maple considers as "simple"). Compare
 

sqrt(-2*gamma__b^2 + 4*omega__0^2)/2;
(%^2)^(1/2);

 

It did not change with 2024.1. I tested it with 2024.0 which I could install in parallel.

However, a test with Maple 2018 shows that the former Java runtime environement sets the cursor at the start as you remembered.

 

@Carl Love 
This looks promissing, however so far I can only list Maple files in a directory but no subdirectories.

As I understand the help page this should list all *.mw files (but it does not)
 

FileTools:-ListDirectory("C:/", 'select' = "*.mw", 'depth' = 40);

 

@salim-barzani 
Not really for a 3d plot. You have to reformulate your problem. A third parameter is required in your complex expression that can be used in an amination call.

Or if 2d is OK for you, paste this into my reply at the very end

plots:-animate(plot, [map(Re, solnum), x = -50 .. 50], t = -50 .. 50, axes = boxed);
plots:-animate(plot, [map(Im, solnum), x = -50 .. 50], t = -50 .. 50, axes = boxed);


 

@salim-barzani 

Shure:

 

restart;

local gamma:

NULL

Added random values for the parameters theta and gamma

params := {alpha = 2.5, k = 3, w = 2, beta[3] = 3, beta[4] = 1.7,theta=0,gamma=1};

{alpha = 2.5, gamma = 1, k = 3, theta = 0, w = 2, beta[3] = 3, beta[4] = 1.7}

(1)

xi := sqrt(-1/(72*alpha*beta[4]+72*gamma*beta[4]))*(2*alpha*k*t+x)

(-1/(72*alpha*beta[4]+72*gamma*beta[4]))^(1/2)*(2*alpha*k*t+x)

(2)

We perhaps want to plot the magnitude and color it with the phase - so make [mag, phase]

sol1 := [U(xi), -k*x -(9*alpha*k^2*beta[4] + 2*beta[3]^2)/(9*beta[4])*t + theta];

[U((-1/(72*alpha*beta[4]+72*gamma*beta[4]))^(1/2)*(2*alpha*k*t+x)), -k*x-(1/9)*(9*alpha*k^2*beta[4]+2*beta[3]^2)*t/beta[4]+theta]

(3)

Assume some functional form for U(xi)

sol2 := eval(sol1, U(xi) = -beta[3]/(3*beta[4]) + beta[3]*sinh(xi)/(6*beta[4]*cosh(xi)) + beta[3]*cosh(xi)/(6*beta[4]*sinh(xi)));

[-(1/3)*beta[3]/beta[4]+(1/6)*beta[3]*sinh((-1/(72*alpha*beta[4]+72*gamma*beta[4]))^(1/2)*(2*alpha*k*t+x))/(beta[4]*cosh((-1/(72*alpha*beta[4]+72*gamma*beta[4]))^(1/2)*(2*alpha*k*t+x)))+(1/6)*beta[3]*cosh((-1/(72*alpha*beta[4]+72*gamma*beta[4]))^(1/2)*(2*alpha*k*t+x))/(beta[4]*sinh((-1/(72*alpha*beta[4]+72*gamma*beta[4]))^(1/2)*(2*alpha*k*t+x))), -k*x-(1/9)*(9*alpha*k^2*beta[4]+2*beta[3]^2)*t/beta[4]+theta]

(4)

insert numerical values

solnum :=eval(sol2, params);

[-.5882352940+(.2941176471*I)*sin(.7247137946*t+0.4831425297e-1*x)/cos(.7247137946*t+0.4831425297e-1*x)-(.2941176471*I)*cos(.7247137946*t+0.4831425297e-1*x)/sin(.7247137946*t+0.4831425297e-1*x), -3*x-23.67647059*t]

(5)

#plots:-complexplot3d(solnum, x = -50.. 50, t = -50..50);

P := Array(1 .. 2); P[1] := plot3d(map(Re, solnum), x = -50 .. 50, t = -50 .. 50, title = Re); P[2] := plot3d(map(Im, solnum), x = -50 .. 50, t = -50 .. 50, title = Im); plots:-display(P)

 

 

 

 

 

 

subs(x = Re(z), t = Im(z), solnum); plots:-complexplot3d(%[1], z = -50-50*I .. 50+50*I)

[-.5882352940+(.2941176471*I)*sin(.7247137946*Im(z)+0.4831425297e-1*Re(z))/cos(.7247137946*Im(z)+0.4831425297e-1*Re(z))-(.2941176471*I)*cos(.7247137946*Im(z)+0.4831425297e-1*Re(z))/sin(.7247137946*Im(z)+0.4831425297e-1*Re(z)), -3*Re(z)-23.67647059*Im(z)]

 

 

NULL

 

Download complexplot3d_reply.mw

I have never seen this before but I remember that you run Maple with modified kernelopts settings form default values.
When exactly do you get this message? After having executed input involving kernelopts?

@salim-barzani 

The sheer amount of libraries you load makes me uneasy. So I have done it by hand just excluded that packages do not work well together. This does not seem to be the case.
Could it be that you B__0 has an error of sign in the second or third summand?


 

I*G(x)^3*conjugate(G(x))^2+(2*I)*G(x)^2*(diff(G(x), x))+(2*I)*(diff(G(x), x))*G(x)*conjugate(G(x))

I*G(x)^3*conjugate(G(x))^2+(2*I)*G(x)^2*(diff(G(x), x))+(2*I)*(diff(G(x), x))*G(x)*conjugate(G(x))

(1)

Let's make the expression a bit simpler to investigate the summands

simplify((I*G(x)^3*conjugate(G(x))^2+(2*I)*G(x)^2*(diff(G(x), x))+(2*I)*(diff(G(x), x))*G(x)*conjugate(G(x)))/(I))

G(x)*abs(G(x))^4+2*(diff(G(x), x))*abs(G(x))^2+2*G(x)^2*(diff(G(x), x))

(2)

G(x) = beta*exp(I*x)

G(x) = beta*exp(I*x)

(3)

conjugate(G(x)) = beta*exp(-I*x)

conjugate(G(x)) = beta*exp(-I*x)

(4)

(G(x) = beta*exp(I*x))+(conjugate(G(x)) = beta*exp(-I*x))

G(x)+conjugate(G(x)) = beta*exp(x*I)+beta*exp(-I*x)

(5)

simplify(%)

2*Re(G(x)) = 2*beta*cos(x)

(6)

This matches my definition of conjugate.
First summand:

subs(G(x) = beta*exp(I*x), conjugate(G(x)) = beta*exp(-I*x), I*G(x)^3*conjugate(G(x))^2+(2*I)*G(x)^2*(diff(G(x), x))+(2*I)*(diff(G(x), x))*G(x)*conjugate(G(x)))

I*beta^3*(exp(x*I))^3*conjugate(beta*exp(x*I))^2+(2*I)*beta^2*(exp(x*I))^2*(diff(beta*exp(x*I), x))+(2*I)*(diff(beta*exp(x*I), x))*beta*exp(x*I)*conjugate(beta*exp(x*I))

(7)

(G(x) = beta*exp(I*x))^3

G(x)^3 = beta^3*(exp(x*I))^3

(8)

(conjugate(G(x)) = beta*exp(-I*x))^2

conjugate(G(x))^2 = beta^2*(exp(-I*x))^2

(9)

(G(x)^3 = beta^3*(exp(I*x))^3)*(conjugate(G(x))^2 = beta^2*(exp(-I*x))^2)

G(x)^3*conjugate(G(x))^2 = beta^5*(exp(x*I))^3*(exp(-I*x))^2

(10)

simplify(G(x)^3*conjugate(G(x))^2 = beta^5*(exp(I*x))^3*(exp(-I*x))^2)

G(x)*abs(G(x))^4 = beta^5*exp(x*I)

(11)

This is what you are looking for
Second summand

diff(G(x) = beta*exp(I*x), x)

diff(G(x), x) = I*beta*exp(x*I)

(12)

(G(x) = beta*exp(I*x))^2

G(x)^2 = beta^2*(exp(x*I))^2

(13)

2*(diff(G(x), x) = I*beta*exp(I*x))*(G(x)^2 = beta^2*(exp(I*x))^2)

2*G(x)^2*(diff(G(x), x)) = (2*I)*beta^3*(exp(x*I))^3

(14)

This is not what you are looking for. Let'y see if the thrid summand chancel this
Thrid summand:

simplify(2*(G(x) = beta*exp(I*x))*(conjugate(G(x)) = beta*exp(-I*x))*(diff(G(x), x) = I*beta*exp(I*x)))

2*(diff(G(x), x))*abs(G(x))^2 = (2*I)*beta^3*exp(x*I)

(15)

Same as the second summand. Could it be that you B__0 has an error of sign in the second or third summand?

NULL

NULL


 

Download simplify_by_hand.mw

@Nicole Sharp 

Does it display as you want in print layout mode? This is supposed to be a WYSIWYG (what you see is what you get)

@acer 

You are correct. I had the sum 5 * Unit(m) +x in mind, which does not lead to an error message in the OPs example with the error messages using Simple (but it does using Standard).

In your example, Simple temporarily assumes that x is of unit m which does not fit to the second term where x must be of unit s. No global checks accross several inputs are performed.


I never understood why Simple is called simple. It seems to be more sophisticalted than Standard (or at least allows for assignements to names/variables with and without units).

Anyway, I don't use unit packages. I am fine with subs/eval of 'name=value*unit', simplify, combine and convert after having done algebra on symbolic physical equations/expressions. Unit inconsistencies will finally reveal at the end, when numerical results are computed form the symbolic results. 
Assignments to names as 'name:= value * unit' have complicated my work since they "ruin" symbolic results (which require reexecution of a worksheet when this happens). So I stopped using assignements for physical quantity and parameter definition.

@dharr ,

Since @zenterix came up with a case of practical importance, I was unhappy with Maples output which does not accept units. Here is how a general solution can be derived that does accept parameters with units.

From dharrs worksheet

In the same way

Both expression do not evaluate with units.

However, the intersting part is the following:
Both scale with k which is in J *n/mol. The more molecules are present, the higher is the work to be performed.

So far so easy. The arguments of ln() scale with the values and units of V and P, respectively. But the difference of ln's scale as follows

Meaning: the units used for V an P do not matter only the ratio of values counts.

Substituting Maples output with the right hand side results in a propper general solution.

`assuming`([int(n/V, V = V__1 .. V__2)], [positive])

-ln(V__1)*n+ln(V__2)*n

(1)

`assuming`([combine(-ln(V__1)*n+ln(V__2)*n)], [positive])

n*ln(V__2/V__1)

(2)

V__1 = n*Unit('m'^3), V__2 = m*Unit('m'^3)

V__1 = n*Units:-Unit(m^3), V__2 = m*Units:-Unit(m^3)

(3)

subs(V__1 = n*Units:-Unit(m^3), V__2 = m*Units:-Unit(m^3), n*ln(V__2/V__1))

n*ln(m/n)

(4)

NULL

Download Units_int_general.mw

@acer , @Thomas Richard 

Not as short as I hoped for but better than op().

Unfortuneatley the parenthesis convention of ISO80000 to symbolise the extraction operation of values and units is not common and does not fit Maples use of parentheses. Otherwise it could be used in pretty printed output.

To make code and/or output better understandable defining a function with a selfexplaining name like

UnitOf:=x-> Units:-Split(x, output = unit);

is maybe the best compromise.

Thank you for the details

First 24 25 26 27 28 29 30 Last Page 26 of 70