MaplePrimes Questions

I could not figure how to fix my code. Could you help me?

Thanks in advance,

LinearAnalysis.mw

restart;

:with(DynamicSystems):with(DEtools):with(plots):with(plottools):with(DETools):

wiht(LinearAlgebra): with(VectorCalculus):

 

 

e1:=0.5: e2:=0.2:

sigma1:=e1*alpha: sigma2:=e2*delta:

g:=x/(1+beta*x^2);
f:=(theta*x-1)*(1-x)*(1+beta*x^2)-y;
h:=alpha*g-z-sigma1;
j:=delta*y-sigma2;
F:=g*f;
H:=y*h;
G:=z*j;

x/(1+.4*x^2)

 

(5*x-1)*(1-x)*(1+.4*x^2)-y

 

x/(1+.4*x^2)-z-.5

 

y-.2

 

x*((5*x-1)*(1-x)*(1+.4*x^2)-y)/(1+.4*x^2)

 

y*(x/(1+.4*x^2)-z-.5)

 

z*(y-.2)

(1)

 

theta:=5;alpha:=1;delta:=1;beta:=0.4;
Ffunc:=unapply(F,x,y); Hfunc:=unapply(H,x,y,z);Gfunc:=unapply(G,y,z);
J1:=Jacobian([Ffunc(x,y),Hfunc(x,y,z),Gfunc(y,z)],[x,y,z]);
C:= CharacteristicPolynomial(J1,lambda);
R:= RouthTable(C,lambda);

theta := 5

 

alpha := 1

 

delta := 1

 

beta := .4

 

Ffunc := proc (x, y) options operator, arrow; x*((5*x-1)*(1-x)*(1+.4*x^2)-y)/(1+.4*x^2) end proc

 

Hfunc := proc (x, y, z) options operator, arrow; y*(x/(1+.4*x^2)-z-.5) end proc

 

Gfunc := proc (y, z) options operator, arrow; z*(y-.2) end proc

 

Matrix(3, 3, {(1, 1) = ((5*x-1)*(1-x)*(1+.4*x^2)-y)/(1+.4*x^2)-.8*x^2*((5*x-1)*(1-x)*(1+.4*x^2)-y)/(1+.4*x^2)^2+x*((5-5*x)*(1+.4*x^2)-(5*x-1)*(1+.4*x^2)+(4.0*x-.8)*(1-x)*x)/(1+.4*x^2), (1, 2) = -x/(1+.4*x^2), (1, 3) = 0, (2, 1) = y*(1/(1+.4*x^2)-.8*x^2/(1+.4*x^2)^2), (2, 2) = x/(1+.4*x^2)-z-.5, (2, 3) = -y, (3, 1) = 0, (3, 2) = z, (3, 3) = y-.2})

 

Error, (in Verify:-CommonExports) system object is not a module

 

Matrix(%id = 36893491070243237028)

(2)

E0:= [0,0,0];
JE0:=subs(x=E0[1],y=E0[2],z=E0[3],J1);
CE0:=CharacteristicPolynomial(JE0,lambda);
RE0:= RouthTable(CE0,lambda);
RouthTable(CE0,lambda,'stablecondition'=true);

E0 := [0, 0, 0]

 

Matrix(3, 3, {(1, 1) = -1., (1, 2) = -0., (1, 3) = 0, (2, 1) = 0., (2, 2) = -.5, (2, 3) = 0, (3, 1) = 0, (3, 2) = 0, (3, 3) = -.2})

 

Error, (in Verify:-CommonExports) system object is not a module

 

Matrix(%id = 36893491070243233172)

 

true

(3)

E1:= [1,0,0];
JE1:=subs(x=E1[1],y=E1[2],z=E1[3],J1);
CE1:=CharacteristicPolynomial(JE1,lambda);
RE1:= RouthTable(CE1,lambda);
RouthTable(CE1,lambda,'stablecondition'=true);

E1 := [1, 0, 0]

 

Matrix(3, 3, {(1, 1) = -4.000000000, (1, 2) = -.7142857143, (1, 3) = 0, (2, 1) = 0., (2, 2) = .2142857143, (2, 3) = 0, (3, 1) = 0, (3, 2) = 0, (3, 3) = -.2})

 

Error, (in Verify:-CommonExports) system object is not a module

 

Matrix(%id = 36893491070243221500)

 

true

(4)

E2:= [1/theta,0,0];
JE2:=subs(x=E2[1],y=E2[2],z=E2[3],J1);
CE2:=CharacteristicPolynomial(JE2,lambda);
RE2:= RouthTable(CE2,lambda);
RouthTable(CE2,lambda,'stablecondition'=true);

E2 := [1/5, 0, 0]

 

Matrix(3, 3, {(1, 1) = .8000000000, (1, 2) = -.1968503937, (1, 3) = 0, (2, 1) = 0., (2, 2) = -.3031496063, (2, 3) = 0, (3, 1) = 0, (3, 2) = 0, (3, 3) = -.2})

 

Error, (in Verify:-CommonExports) system object is not a module

 

Matrix(%id = 36893491070243218004)

 

true

(5)

 

Download LinearAnalysis.mw

 

I have been using WXMaxima for years and just upgraded to Maple 2023, but I am having a very difficult time adjusting from Maxima to Maple.  Is there a way to make Maple more Maxima-like?

The first problem that I encounter is that "Shift + Enter" and "Enter" should be reversed for people who are used to inputting with Maxima.  I would like to reconfigure Maple so that "Shift + Enter" will be for "Evaluate Expression" and "Enter" will be for "Soft New Line".  This makes inputting multi-line commands (using ":") much easier, so that you "Enter" to add the next line, and then "Shift + Enter" to evaluate.  I thought there was a way to switch these, but I can't find it in the manual.

The next problem is the syntax itself.  "MmaToMaple" will translate Mathematica syntax into Maple syntax, but why is there no equivalent for Maxima?  Maxima/Macsyma is the original computer algebra system (CAS) that inspired both Maple and Mathematica, and being free and open-source, has the widest possible user base (since anyone can use it for free).  Maple needs a way to translate to and from Maxima syntax.  For personal use, I already have a large body of Maxima worksheets saved as plaintext MAC files that I would like to use in Maple.  It will save me a lot of time and trouble if I can import Maxima worksheets directly into Maple.

Is there an easy way to save commonly used Maxima expressions that are not already reserved by Maple, such as "float" (for "evalf") and "%e" (for "exp(1)") so that some Maxima syntax can run directly in Maple?  The only major changes then would be replacing "$" with ":" and ":" with ":=" since ";" is the same in both Maxima and Maple.  Not sure what a "$" means in Maple....

Maple syntax is more similar to Maxima syntax than to Mathematica syntax.  Below is a sample problem that is un-solvable in Maxima (application will crash or run out of memory) but solvable in Maple, to show the differences in syntax.  Unfortunately, it seems that in many cases the Maple syntax is more verbose than the Maxima syntax, requiring more characters to type (such as when defining functions).

/* Maxima syntax */ $
c : 299792458 $
h : 6.62607015E-34 $
k : 1.380649E-23 $
n : exp(1) $
T : 25200 $
P (lmin,lmax) := integrate(2*(c^2)*h/(l^5*(n^(c*h/(k*l*T))-1)),l,lmin,lmax)/integrate(2*(c^2)*h/(l^5*(n^(c*h/(k*l*T))-1)),l,0,inf) $
float(P(380E-9,750E-9));

 

(* Maple syntax *) :
c := 299792458 :
h := 6.62607015E-34 :
k := 1.380649E-23 :
n := exp(1) :
T := 25200 :
P := (lmin,lmax) -> integrate(2*(c^2)*h/(l^5*(n^(c*h/(k*l*T))-1)),l=lmin..lmax)/integrate(2*(c^2)*h/(l^5*(n^(c*h/(k*l*T))-1)),l=0..infinity) :
evalf(P(380E-9,750E-9));

It seems like Maplesoft has gone to a lot of effort to create intercompatibility between Maple and Mathematica, but their real competition is getting customers to upgrade from Maxima (which is completely free and open-source) to Maple (which is non-free and closed-source like Mathematica is).  Making Maple more Maxima-friendly should increase the number of Maple customers by making it easier to upgrade from Maxima to Maple.

Can anyone help me fix a corrupted maple file?

I have tried to fix it myself and searched all over for a solution but can' seem to fix it myself. Please help

Download Styrkelære2regneopgaver.mwStyrkelære2regneopgaver.mwStyrkelære2regneopgaver.mw

Stupid question, but how do I get the code on the math apps CaesarCipher from the help page?  I see the variable cipher but it's content is a mystery.

(Sorry guys, I changed the title to better reflect the content of the question and it bumped back up the top)

1) Say I have an Excel sheet with first column with my dependent variable values Y

2) Remaining columns to the left say some maximum 30 columns are independent variable

One thing is to import the excel columns to maple matrix

Then matrix will have first column dependent variable

Another's independent variables

3) Now i need to pick 2 independent variables columns and ( the dependent variable columns say Y which is the first column)

4) apply the normal regular MLR regression on it  then check if R^2 is good the p vaule are below 0.05

5) I print the column names of those columns

The first row will be the header column which has the variable name.

Kind help someone please kind help your help will be great greatly acknowledged 

Hello everyone,

Here is a stylized version of my problem. Given three normally distributed random variables {A, B, C}, I want to find the X_1, X_2, X_3 that maximize the following expression (gamma being a constant and A being a linear combination of other normally distributed random variables):

Max{ Exp[A|B,C] - (gamma/2)*Var[A|B,C] }

All the details are here: 070423_Optimization.mw

In particular, I am seeking your help to:

  1. Correlate three random variables (an example of the procedure for correlating two random variables is already provided in the script).
  2. Verify my understanding of the linear projection theorem (https://stats.stackexchange.com/questions/30588/deriving-the-conditional-distributions-of-a-multivariate-normal-distribution) in two dimensions, that is, to compute conditional means and variances of the form E[X|Y,Z] and V[X|Y,Z].
  3. Implement and adapt the linear projection theorem to my problem in Maple.
  4. Combine all together to obtain Expr = E[A|B,C] + V[A|B,C] and find the optimal {X_1, X_2, X_3} by solving the linear system of three equations in the three variables {X_1, X_2, X_3}, where the three equations are obtained by setting to 0 the partial derivatives of Expr with respect to {X_1, X_2, X_3}.

 

In relation to point 2., did I correctly interpret the matrix form of the three-dimensions version of the linear projection theorem?

 

In relation to point 3., I attach a stylized script for the three-dimensions version (note that I need the two-dimensions version for my problem): LinearProjectionTheorem_3dimensions.mw. Assuming a correct interpretation of the theorem:

  • Did I correctly implement E[X_2|Y_1,Y_2,Y_3] and E[X_3|Y_1,Y_2,Y_3] as in the picture above?
  • How to adapt it accordingly to include E[X_1|Y_1,Y_2,Y_3] and V[X_1|Y_1,Y_2,Y_3], V[X_2|Y_1,Y_2,Y_3], and V[X_3|Y_1,Y_2,Y_3]? 
  • How to apply it to the random variables in my script to eventually find the optimal {X_1,X_2,X_3}?

 

You can play around with my script 070423_Optimization.mw and send me the updated version. The problem I am trying to solve is quite convoluted, so let me know if you need any further clarification. Thanks a lot!

Actually, I have two questions here, I don't know if they are connected.

I don't know if it's the right way to deifne function with indexed variables, is there any difference between f and g?

I assume they are the same since neither of them work with Maximize.

Finally, I use the most original way in (5), why give the wrong answer? (no way the answer is -infinity)

restart

f := proc (x) options operator, arrow; sum(ln(x[i]), i = 1 .. 4) end proc

proc (x) options operator, arrow; sum(ln(x[i]), i = 1 .. 4) end proc``

(1)

g := proc (x) options operator, arrow; ln(x[1])+ln(x[2])+ln(x[3])+ln(x[4]) end proc

proc (x) options operator, arrow; ln(x[1])+ln(x[2])+ln(x[3])+ln(x[4]) end proc

(2)

f([1, 1, 1, 1])

0

(3)

cons := {x[1]+x[2] <= 1, x[1]+x[3] <= 2}

{x[1]+x[2] <= 1, x[1]+x[3] <= 2}

(4)

with(Optimization)

Maximize(f, cons, assume = nonnegative)

Error, (in Optimization:-NLPSolve) constraints must be specified as a set or list of  procedures

 

Maximize(f, {x[1]+x[2] <= 1, x[1]+x[3] <= 2}, assume = nonnegative)

Error, (in Optimization:-NLPSolve) constraints must be specified as a set or list of  procedures

 

Maximize(g, cons, assume = nonnegative)

Error, (in Optimization:-NLPSolve) constraints must be specified as a set or list of  procedures

 

Maximize(g, {x[1]+x[2] <= 1, x[1]+x[3] <= 2}, assume = nonnegative)

Error, (in Optimization:-NLPSolve) constraints must be specified as a set or list of  procedures

 

 

Maximize(sum(ln(x[i]), i = 1 .. 4), {x[1]+x[2] <= 1, x[1]+x[3] <= 2}, assume = nonnegative)

[Float(-infinity), [x[1] = HFloat(1.0), x[2] = HFloat(0.0), x[3] = HFloat(1.0), x[4] = HFloat(1.0)]]

(5)

NULL

Download mre.mw

In the last two months I've have been asked to download an update to 2022.1 around 7 times.

Each oupdates takes 5-10 minutes and I have to sit idle.

1. Is this the typical pace of updates?

2.Is there a veriosn 2023 I need to get? if yes, how?

Thanks!

i try to plot this equation        2.96736996560705*10^(-12)*p^2+1.31319840299485*10^(-13)*t^2-8.89549693662593*10^(-7)*p+8.53128393394231*10^(-7)*t-3.65558815509970*10^(-30)*p*t-1 = 0 and use this command plots:-implicitplot(TWeq, p = -10^10 .. 10^11, t = -3*10^8 .. 3*10^8, gridrefine = 3, scaling = constrained, size = [1000, 100]) but  it only shows like this

it should be an ellipse but it just show like this..please help me.

S1 := 441;
S2 := 1109;
S3 := 511;
S4 := 900;
S5 := 2904;
S6 := 285;

S2 + S3 + S4 + S5 + S6;                             
for i to 5 do
    S*[i] + S[i + 1];
end do;
Thank you.

The following results should be true or false, but unfortunately, both of them become FAIL (in Maple 2023): 

interface(version)

_EnvTry := hard:

`Standard Worksheet Interface, Maple 2023.0, Windows 10, March 6 2023 Build ID 1689885`

(1)

assume(`or`(n < 0, n >= 1), m > (1/2)*n*(n-1))

is(m < 0);

is(m > 0)

false

 

FAIL

(2)

coulditbe(m, 0)

FAIL

(3)

NULL


Download Unable_to_prove.mw

Does anyone know why?

Is there a simpler and more elegant way to get the last result in this code snippet?

add(f~([op(a+b)])[]);
                          f(a) + f(b)
# simpler and more elegant
map(f, a+b);
                          f(a) + f(b)
# now I want to obtain this result
add(f~([op(a+b)], t)[]);
                       f(a, t) + f(b, t) 

TIA

I receive the following error when I run maple to solve a diff equation.
Thank you in advance for your help.

eq1:=A__n=[X__n+[(C-z)*(tan(theta1)+tan(theta2))]] * [B + (2*(C-z)*tan(theta3))];
eq2:=P__n=[2*(X__n+B)] + 2 * (C-z) * [(tan(theta1)+tan(theta2)) + (2*tan(theta3))];
eq3:=gamma - [cu*(P__n/A__n)] = diff(sigma__v(z),z);
eq4:=subs([eq1,eq2],eq3);
ics:=sigma__v(0)=sigma__s;
sol:=simplify(dsolve(([eq4,ics]), sigma__v(z)));
NULL

A__n = [X__n+[(C-z)*(tan(theta1)+tan(theta2))]]*[B+2*(C-z)*tan(theta3)]

 

P__n = [2*X__n+2*B]+2*(C-z)*[tan(theta1)+tan(theta2)+2*tan(theta3)]

 

gamma+[-cu*P__n/A__n] = diff(sigma__v(z), z)

 

gamma+[-cu*([2*X__n+2*B]+2*(C-z)*[tan(theta1)+tan(theta2)+2*tan(theta3)])/([X__n+[(C-z)*(tan(theta1)+tan(theta2))]]*[B+2*(C-z)*tan(theta3)])] = diff(sigma__v(z), z)

 

sigma__v(0) = sigma__s

 

Error, (in PDEtools/NumerDenom) invalid input: `PDEtools/NumerDenom` expects its 1st argument, ee, to be of type algebraic, but received [tan(theta1)+tan(theta2)+2*tan(theta3)]

 

``

Download diffeq.mw

I've been trying for so long to fix my code I could've done the math by hand by now. All equations and variables seem to be recognized correctly. Can anyone point out where I made an error? Thanks

Chem.mw

restart; K1 := 10^(-2.12); K2 := 10^(-7.21); K3 := 10^(-12.32); Kw := 10^(-14); NaCl := .5004/(58.44); NaH2PO4 := .1092/(119.98); Na2HPO4 := 1.214/(141.96); Why := Kw = H*OH; Do := K1 = H*H2PO4/H3PO4; It := K2 = H*HPO4/H2PO4; Today := K3 = H*PO4/HPO4; When := Cl = NaCl; Its := Na = NaH2PO4+2*Na2HPO4+NaCl; Due := Na+H = Cl+3*PO4+2*HPO4+H2PO4+OH; Tomorrow := Na2HPO4+NaH2PO4 = H3PO4+H2PO4+HPO4+PO4; z := solve([Why, Do, It, Today, When, Its, Due, Tomorrow], [H, OH, Na, CL, PO4, HPO4, H2PO4, H3PO4]); assign(z)

[]

(1)

Download Chem.mw

What is the result of the following?

solve((4*t1+4*sqrt(t1^2-4*t2))>0,{t2});
 

First 94 95 96 97 98 99 100 Last Page 96 of 2308