Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

I have a set of 15 equations in state space form, and I'm just trying to program a way to substitute all variables representing the time derivates as for example x__s_dot (t) as diff(x__s (t), t)  and diff( x__s_dot (t),t) as diff(x__s (t), t,t) so I can manipulate my equations easier.

The last half of the list xx has the variables that I want to substitute, the x,y and u (with respective diff(x__s (t), t) ) variables are always constant, but in the case of zeta, eta and u I might have indexes from 1 to n , in this case just 1 and 2.

I tried a bunch of methods including creating vectors with the seq, op commands and substituting them into my original equations with subs, algsubs but none of the things I programmed worked the way I wanted, I ended up with a very inefficient way , doing it manually, but the point is that I wanted to automate this bit. I've been doing maple for about 2 weeks and I still struggle a lot with it, I would greatly appreciate any guidence/advice.


My original equations are actually much bigger and my original code too, I tried to shorten it a bit just for making my problem simpler to understand but the equations still look really big here, If there is another way to format this question please do advice so.

EDIT : I think my last code was hard to understand because my equations were too big and it looked all messy and horrible, I edited to show just one vector of variables, I think that if it works here, it should work on the rest of my code:


 

NULL

interface(rtablesize=50):

xx := [x__s(t), y__s(t), u__s(t), x__r(t), y__r(t), u__r(t), x__c(t), y__c(t), u__c(t), zeta__1(t), eta__1(t), u__1(t), zeta__2(t), eta__2(t), u__2(t), x__s_dot(t), y__s_dot(t), u__s_dot(t), x__r_dot(t), y__r_dot(t), u__r_dot(t), x__c_dot(t), y__c_dot(t), u__c_dot(t), zeta__1_dot(t), eta__1_dot(t), u__1_dot(t), zeta__2_dot(t), eta__2_dot(t), u__2_dot(t)]:

nq := 15;            
xxUNDOT := [ seq ( xx[i], i = 1..nq),
             seq ( diff(xx[i],t), i = 1..nq)];
 

15

 

[x__s(t), y__s(t), u__s(t), x__r(t), y__r(t), u__r(t), x__c(t), y__c(t), u__c(t), zeta__1(t), eta__1(t), u__1(t), zeta__2(t), eta__2(t), u__2(t), diff(x__s(t), t), diff(y__s(t), t), diff(u__s(t), t), diff(x__r(t), t), diff(y__r(t), t), diff(u__r(t), t), diff(x__c(t), t), diff(y__c(t), t), diff(u__c(t), t), diff(zeta__1(t), t), diff(eta__1(t), t), diff(u__1(t), t), diff(zeta__2(t), t), diff(eta__2(t), t), diff(u__2(t), t)]

(1)

DOTL := [ seq ( xx[i], i = 1..nops(xx)) ]:
DOTR := [ seq ( xxUNDOT[i], i = 1..nops(xx))]:
Vector[column](DOTL),Vector[column](DOTR);

for i from nq+1 to nops(xx) do
newxx    := subs[inplace][eval](
  op(i,DOTL) = op(i,DOTR) ,xx):
end do:

Vector(30, {(1) = x__s(t), (2) = y__s(t), (3) = u__s(t), (4) = x__r(t), (5) = y__r(t), (6) = u__r(t), (7) = x__c(t), (8) = y__c(t), (9) = u__c(t), (10) = `ζ__1`(t), (11) = `η__1`(t), (12) = u__1(t), (13) = `ζ__2`(t), (14) = `η__2`(t), (15) = u__2(t), (16) = x__s_dot(t), (17) = y__s_dot(t), (18) = u__s_dot(t), (19) = x__r_dot(t), (20) = y__r_dot(t), (21) = u__r_dot(t), (22) = x__c_dot(t), (23) = y__c_dot(t), (24) = u__c_dot(t), (25) = `ζ__1_dot`(t), (26) = `η__1_dot`(t), (27) = u__1_dot(t), (28) = `ζ__2_dot`(t), (29) = `η__2_dot`(t), (30) = u__2_dot(t)}), Vector(30, {(1) = x__s(t), (2) = y__s(t), (3) = u__s(t), (4) = x__r(t), (5) = y__r(t), (6) = u__r(t), (7) = x__c(t), (8) = y__c(t), (9) = u__c(t), (10) = `ζ__1`(t), (11) = `η__1`(t), (12) = u__1(t), (13) = `ζ__2`(t), (14) = `η__2`(t), (15) = u__2(t), (16) = diff(x__s(t), t), (17) = diff(y__s(t), t), (18) = diff(u__s(t), t), (19) = diff(x__r(t), t), (20) = diff(y__r(t), t), (21) = diff(u__r(t), t), (22) = diff(x__c(t), t), (23) = diff(y__c(t), t), (24) = diff(u__c(t), t), (25) = diff(`ζ__1`(t), t), (26) = diff(`η__1`(t), t), (27) = diff(u__1(t), t), (28) = diff(`ζ__2`(t), t), (29) = diff(`η__2`(t), t), (30) = diff(u__2(t), t)})

(2)

Vector[column](newxx);

Vector(30, {(1) = x__s(t), (2) = y__s(t), (3) = u__s(t), (4) = x__r(t), (5) = y__r(t), (6) = u__r(t), (7) = x__c(t), (8) = y__c(t), (9) = u__c(t), (10) = `ζ__1`(t), (11) = `η__1`(t), (12) = u__1(t), (13) = `ζ__2`(t), (14) = `η__2`(t), (15) = u__2(t), (16) = x__s_dot(t), (17) = y__s_dot(t), (18) = u__s_dot(t), (19) = x__r_dot(t), (20) = y__r_dot(t), (21) = u__r_dot(t), (22) = x__c_dot(t), (23) = y__c_dot(t), (24) = u__c_dot(t), (25) = `ζ__1_dot`(t), (26) = `η__1_dot`(t), (27) = u__1_dot(t), (28) = `ζ__2_dot`(t), (29) = `η__2_dot`(t), (30) = diff(u__2(t), t)})

(3)

``


 

Download subs.mw

I tried to make a for loop that substitutes each variable one by one, but it only seems to work for the last term, I don't know why, please help or suggest another method? I also have diff(x__s,t,t) terms in my equations, not just diff(x__s,t), but I guess only by specifying the first derivate it should work?

 

Thanks.

 

how can i solve coupled differential of equation with rkf or another method

maple.mw

A1 , A2, A3 ??

v=u+at                      (1)
s=u*t+1/2*a*t^2        (2)

below 3 equations, can substitute  (1)  into it to form (2)
s=1/2*(u+v)*t       (3)
v^2=u^2+2*a*s    (4)
s=v*t-1/2*a*t^2    (5)

can these 5 equations be considered as a solution set of solve function?

or

is only first 2 equations be a solution set?

if so, number of equations less than 5 variables, is there something missing?
 

i want to dsolve frome this equation . but i cant

1.mw


 

op(2, -(1/4)*z^2-(1/18*I)*z^3+(1/96)*z^4+(1/600*I)*z^5-(1/4320)*z^6-(1/35280*I)*z^7+(1/322560)*z^8+(1/3265920*I)*z^9-(1/36288000)*z^10-(1/439084800*I)*z^11+O(z^12))

-((1/18)*I)*z^3

(1)

op(2, series(Ei(I*z)-gamma-ln(z)-I*csgn(I*z)*Pi-I*z, z, 12))

2

(2)

series(Ei(I*z)-gamma-ln(z)-I*csgn(I*z)*Pi-I*z, z, 12)

series(-(1/4)*z^2-((1/18)*I)*z^3+(1/96)*z^4+((1/600)*I)*z^5-(1/4320)*z^6-((1/35280)*I)*z^7+(1/322560)*z^8+((1/3265920)*I)*z^9-(1/36288000)*z^10-((1/439084800)*I)*z^11+O(z^12),z,12)

(3)

is(series(Ei(I*z)-gamma-ln(z)-I*csgn(I*z)*Pi-I*z, z, 12) = -(1/4)*z^2-(1/18*I)*z^3+(1/96)*z^4+(1/600*I)*z^5-(1/4320)*z^6-(1/35280*I)*z^7+(1/322560)*z^8+(1/3265920*I)*z^9-(1/36288000)*z^10-(1/439084800*I)*z^11+O(z^12))

false

(4)

``


 

Download op_error.mw

Hello,

Is there a Maple command for copying a text to the clipboard ? (Apart from using the contextual menu or the Edit-Copy menu option)

For example:

ee := x^2+y^2+z^2

CopyToClipboard( convert(ee,string) )

Thank you,

César Lozada

 

 

 

work.mw

I'm having problems plotting these three functions on the same graph. I can get two of them, but as soon as I try to add the third, it throws a couple errors no matter what I do. It doesn't help that the docs are confusing. The first two functions are approximating diff(y(x),x) = -2xy(x)+1 with the Euler method (step size of 0.05 and 0.1) that I implemented using a for loop. I gather the data into an array and then plot those. That works. But once I try to set y(x) equal to a Taylor approximation, I can plot that graph but the values for the other functions are strangely absent. I've attached my work. What is wrong with my syntax and how can I plot all three functions at once?

I want to plot a function f(x,y)=x^3-2x^2y. But I only want to plot values where $x^2+y^2 <= 1$. So far I specified the plotting range in the standard way, but I really need to specify it like I described. I want to use plot3d.

Hello,

How can we write a code for solving following system of Pdes ?

restart;
PDE1:=m1*diff(w1(x,t),t$2)-S1*diff(w1(x,t),x$2)+k*(w1(x,t)-w2(x,t))=F1(t)*delta(x-x1);
PDE2:=m2*diff(w2(x,t),t$2)-S2*diff(w2(x,t),x$2)+k*(w2(x,t)-w1(x,t))=F2(t)*delta(x-x2);

In here,  Ki, mi, xi and k are constants where i=1,2.

Since F1(t) and F2(t) are unspecified (ungiven) functions, solutions u1,u2 which we seek, will be depended on  F1(t) and F2(t). 

 

Thanks for your valuable and praiseworthy suggestions and comments.

When one uses the PolynomialIdeals package, then how should he ask the elemnts in an ideal or the number of generators?

An idea can be writing a proc getting a polynomialideal and returning a list with the generators as its elements in this way. Converting the polynomialideal to a list, then deleting its three last entries. But I'm wondering if there is any other way to do this? It's reasonable to be able to ask generators of an ideal of result of some computations in polynomialideal package.

 

Dear Maple users,

I want to label Y axis such that it doesn't encroach the numbers. The figure below illustrates the difficulty I am facing. How can I change the default setting to put letter '\bar{U}' at some distance from Y axis so that it doesn't look crowded? Thanks.

Edit. One crude way to do this is by using typesetting command.

labels = [log(n), typeset(conjugate(U), " ")]

 

i am trying to write the differential equation 

u_{t}=u_{xx}+2u^{2}(1-u) in my maple 15. 

but it shows error,

Error, empty number and  1 additional error.
 

The Lattice package to investigate particle accelerator magnet lattices (original post) has been updated to V1.1. This is a significant update, addressing a number of inaccuracies and bugs of V1.0 as well as introducing new elements: Octupole, Fringe effect in dipoles, a MatchedSection allowing to insert a piece of beamline when the details are irrelevant, and a few experimental elements like WireQuad. New functions include the 6th synchrotron-radiation integral I6x, momentum compaction alphap and TaylorMap, which allows to compute the Taylor expansion of  the non-linear map to any degree.

The code and documentation are available in the Application Center.

U. Wienands, aka Mac Dude

 

A couple of weeks ago, I recorded a short video that discussed various applications for the Statistics:-Fit command. One of the more interesting examples examined how manually adjusting the number of parameters used for a regression model affected the resulting adjusted r-squared value.

I won’t go into detail about r-squared here, but to briefly summarize: In a linear regression model, r-squared measures the proportion of the variation in a model's dependent variable explained by the independent variables. Basically, r-squared gives a statistical measure of how well the regression line approximates the data. R-squared values usually range from 0 to 1 and the closer it gets to 1, the better it is said that the model performs as it accounts for a greater proportion of the variance (an r-squared value of 1 means a perfect fit of the data). When more variables are added, r-squared values typically increase. They can never decrease when adding a variable; and if the fit is not 100% perfect, then adding a variable that represents random data will increase the r-squared value with probability 1. The adjusted r-squared attempts to account for this phenomenon by adjusting the r-squared value based on the number of independent variables in the model.

The formula for the adjusted r-squared is:

Where:

n is the number of points in the data sample

k is the number of independent variables in the model excluding the constant

By taking the number of independent variables into consideration, the adjusted r-squared behaves different than r-squared; adding more variables doesn’t necessarily produce better fitting models. In many cases, more variables can often lead to lower adjusted r-squared values. In particular, if you add a variable representing random data, the expected change in the adjusted r-squared is 0.

As such, the adjusted r-squared has a slightly different interpretation than the r-squared. While r-squared is perceived to give an indication of the measure of fit for a chosen regression model, the adjusted r-squared is perceived more as a comparative tool that can be useful for picking variables and designing models that may require less predictors than other models. The science of “gaming” models is a broad topic, so I won’t go into any more detail here, but there’s lots of great information out there if you are looking to learn more (here’s a good place to start).

The following example adjusts a fitted model by adding or removing variables in order to find better adjusted r-squared values.

with(Statistics):

The Import command reads a datafile into a new DataFrame.

ExperimentalData := Import(FileTools:-JoinPath(["Excel", "ExperimentalData.xls"], base = datadir));

The dataset has seven variables: time and experimental readings for 6 various concentrations. Removing “time” from our variable set, the convert command converts the values in the DataFrame to a Matrix of values.

ExMat := convert( ExperimentalData, Matrix )[..,2..7];

We start by fitting a model that includes predicting variables for each of the columns of data. We mark “Concentration A” as our dependent variable.

Fit( C + C2*v + C3*w + C4*x + C5*y + C6*z, ExMat[..,2..6], ExMat[..,1], [v,w,x,y,z], summarize=embed ):

From the above, we can observe that both the r-squared and adjusted r-squared are reasonably high, however only one of the coefficient values has a significant p-value, C3.

Note: Maple shows all p-values less than 0.05 in bold.

Let's try to fit the data again, this time keeping the two coefficients with the lowest p-values and the intercept.

Fit( C + C3*v + C5*w, ExMat[..,[3,5]], ExMat[..,1], [v,w], summarize=embed ):

From the above, we can see that the r-squared value does go down, however the adjusted r-squared goes up! Let's fit the model one last time to see if removing C5 increases or decreases the adjusted r-squared.

Fit( C + C3*v, ExMat[..,3], ExMat[..,1], [v], summarize=embed ):

We can see that the final adjusted r-squared value is lower than the previous two, so we are probably better to keep the additional C5 coefficient value.

You can see this example as well as a couple of other examples of using the Fit command in the following video:

You can download the worksheet here: https://www.maplesoft.com/applications/view.aspx?SID=154246

I'm trying to program a procedure that will return me a list of positions defining equally spaced points (planets) around a circumference, for example:
PSI := [0, Pi]; # Location of 2 planets
PSI := [0, ((2/3)*Pi) , ((4/3)*Pi) ]; # For 3 Planets
I'm new to maple so most commands are new to me, I tried building the size of the list with [0 $ n] because I want the first position to always be at 0 degrees. The first problem is that I get this error:

Error, reserved word `for` unexpected

 

nplanets := 2;

2

(1)

make_PSI :=
proc(nplanets);
local n,psin,i,PSI:
n = nplanets;
psin  :=(pi*2)/n;
PSI := [0 $ n];
for i from 1 to n do
 angle :=(psin*i);
 op(i,PSI) := angle;
end do;
end;

 

 

Error, reserved word `for` unexpected

 


Any advice would be appreciated!

Download planetspace.mw

First 934 935 936 937 938 939 940 Last Page 936 of 2215