MaplePrimes Questions

Hi

When I try to substitute a value for j, it doesn't evaluate.

add.mw

Hi, I'm having trouble setting up a procedure for an assignment, we're trying to find root mean square error and remove variable by variable to find the best line of fit etc etc... hopefully from the coding you can see what I'm am trying to do, but I don't understand why it is not working? I wonder if it has something to do with the X and Y being read in?
 
M:=readdata("C:\\Users\\bjense04.CSUMAIN.001\\Documents\\ass1Q2.txt",[float,float,float,float,float]):
convert(M,matrix):
with(LinearAlgebra):
n:=RowDimension(convert(M,matrix));
X:=convert(M[1..n,1..4],matrix):
Y:=convert(M[1..n,5..5],vector):
with(Statistics):
FullEQN:=LinearFit([1,a,b,c,d],X,Y,[a,b,c,d]);
#the next part is incomplete
rmse_mlr:=proc(Full)
local i, sq, n, predicted;
sq:=0:
for i from 1 to n do
 predicted:=subs([a=X[i,1],b=X[i,2],c=X[i,3],d=X[i,4]],Full);
 sq:=sq+(Y[i]-predicted)^2;
end do:
return sqrt(sq/n);
end proc;
 
 
I then test the procedure with 
rmse_mlr(FullEQN,X,Y);
 
and the response i get is

Error, (in rmse_mlr) final value in for loop must be numeric or character
 
help?

Does anyone know why pdetest is not giving [0, 0, 0] for the solution of pdsolve?
 

restart

eq := diff(u(x, t), t)-k*(diff(u(x, t), x, x)) = 0

diff(u(x, t), t)-k*(diff(diff(u(x, t), x), x)) = 0

(1)

ic := u(x, 0) = g(x)

u(x, 0) = g(x)

(2)

bc := (D[1](u))(0, t) = 0, eval(diff(u(x, t), x)+u(x, t), x = 1) = 0

(D[1](u))(0, t) = 0, eval(diff(u(x, t), x), {x = 1})+u(1, t) = 0

(3)

sol := `assuming`([simplify(pdsolve([eq, ic, bc]))], [k > 0, 0 < x and x < 1, t > 0])

u(x, t) = `casesplit/ans`(Sum(4*exp(-k*lambda[n]^2*t)*lambda[n]*cos(lambda[n]*x)*(Int(g(x)*cos(lambda[n]*x), x = 0 .. 1))/(2*lambda[n]+sin(2*lambda[n])), n = 0 .. infinity), {And((sin(lambda[n])*lambda[n]-cos(lambda[n]))/cos(lambda[n]) = 0, 0 < lambda[n])})

(4)

`assuming`([simplify(pdetest(sol, [eq, ic, bc]))], [k > 0, 0 < x and x < 1, t > 0])

[-(diff(diff(`casesplit/ans`(sum(4*exp(-k*lambda[n]^2*t)*lambda[n]*cos(lambda[n]*x)*(Int(g(x)*cos(lambda[n]*x), x = 0 .. 1))/(2*lambda[n]+sin(2*lambda[n])), n = 0 .. infinity), {And(-(1/2)*(I*lambda[n]*exp(I*lambda[n])-I*lambda[n]*exp(-I*lambda[n])+exp(I*lambda[n])+exp(-I*lambda[n]))/cos(lambda[n]) = 0, 0 < lambda[n])}), x), x))*k+diff(`casesplit/ans`(sum(4*exp(-k*lambda[n]^2*t)*lambda[n]*cos(lambda[n]*x)*(Int(g(x)*cos(lambda[n]*x), x = 0 .. 1))/(2*lambda[n]+sin(2*lambda[n])), n = 0 .. infinity), {And(-(1/2)*(I*lambda[n]*exp(I*lambda[n])-I*lambda[n]*exp(-I*lambda[n])+exp(I*lambda[n])+exp(-I*lambda[n]))/cos(lambda[n]) = 0, 0 < lambda[n])}), t), `casesplit/ans`(Sum(4*lambda[n]*cos(lambda[n]*x)*(Int(g(x)*cos(lambda[n]*x), x = 0 .. 1))/(2*lambda[n]+sin(2*lambda[n])), n = 0 .. infinity), {And(-(1/2)*(I*lambda[n]*exp(I*lambda[n])-I*lambda[n]*exp(-I*lambda[n])+exp(I*lambda[n])+exp(-I*lambda[n]))/cos(lambda[n]) = 0, 0 < lambda[n])})-g(x), eval(diff(`casesplit/ans`(Sum(4*exp(-k*lambda[n]^2*t)*lambda[n]*cos(lambda[n]*x)*(Int(g(x)*cos(lambda[n]*x), x = 0 .. 1))/(2*lambda[n]+sin(2*lambda[n])), n = 0 .. infinity), {And(-(1/2)*(I*lambda[n]*exp(I*lambda[n])-I*lambda[n]*exp(-I*lambda[n])+exp(I*lambda[n])+exp(-I*lambda[n]))/cos(lambda[n]) = 0, 0 < lambda[n])}), x), {x = 0}), eval(diff(`casesplit/ans`(Sum(4*exp(-k*lambda[n]^2*t)*lambda[n]*cos(lambda[n]*x)*(Int(g(x)*cos(lambda[n]*x), x = 0 .. 1))/(2*lambda[n]+sin(2*lambda[n])), n = 0 .. infinity), {And(-(1/2)*(I*lambda[n]*exp(I*lambda[n])-I*lambda[n]*exp(-I*lambda[n])+exp(I*lambda[n])+exp(-I*lambda[n]))/cos(lambda[n]) = 0, 0 < lambda[n])}), x), {x = 1})+`casesplit/ans`(Sum(4*exp(-k*lambda[n]^2*t)*lambda[n]*cos(lambda[n])*(Int(g(x)*cos(lambda[n]*x), x = 0 .. 1))/(2*lambda[n]+sin(2*lambda[n])), n = 0 .. infinity), {And(-(1/2)*(I*lambda[n]*exp(I*lambda[n])-I*lambda[n]*exp(-I*lambda[n])+exp(I*lambda[n])+exp(-I*lambda[n]))/cos(lambda[n]) = 0, 0 < lambda[n])})]

(5)

``


 

Download PDE.mw

inside my module, I create types to be used by only procs, and other sub modules inside the main one package I have.

but TypeTools:-AddType invoked inside my package, adds the type to system. So a user after loading the package can still see it and use this type.

Adding local before TypeTools:-AddType is not supported.

How to make the type only visible inside the package? Here is example

restart;
kernelopts('assertlevel'=2):
my_pkg:=module()
 option package;
 TypeTools:-AddType(age_type,t->evalb(t::nonnegint and t<150));
 export foo:=proc()
    local age::age_type:=20;
    print("age=",age);
 end proc;
end module;

with(my_pkg);

And now a user can do this

x::age_type:=30;

It worked, since age_type is now in the system. This can also cause a problem, since loading this package, could overwrite a type name allready set there by another package the user happened to load before.

If I can make it at least such that the user has to do 

x::my_pkg:-age_type:=200;

That would be better. But the best solution is to make the type name completely not visible from outside the package. i.e. private type to the package only.

I looked at Extension Mechanisms under typetools in help, but do not see how to use that for what I want.

 

Maple 2020.1

f[2](x) = -(3*R^2*x^11)/30800 + R^2*x^9/420 - (177*R^2*x^7)/9800 + M1*M2*x^5/40 + (17*R^2*x^5)/700 + ((-(3*M1*M2)/10 - (443*R^2)/21560)*x^3)/6 + (M1*M2/40 - (137*R^2)/26950)*x

Hi,

I am writing the following code and MAPLE is giving me operator error. Please help (file: doubt_6.mw)

d2:=100000000

for m in set_m do
    for n in set_n do
        SOL1 := fsolve({ODE11, ODE12}, {N, t__2});
        N1:=eval(N,SOL1);
        t_2_1 :=eval(t__2,SOL1);
        T_1:= eval(T, [lambda = 3, a = 300, b = .15, c = .25, A__m = 300, A__d = 150, A__r = 50,C__m = 4, P__m = 8, P__d = 10, 
        P__r = 12, theta__m = .15, theta__d = .12, theta__r = 0.5e-1, h__m = .2, h__d = .3, h__r = .5, i__m = .1, i__d = .1, 
        i__r = .1, i__om = .1, i__OD = .15, i__c = .3, i__e = .2, M = 2, alpha = 0.2e-1, t__2 = t_2_1]):
        t_31:= T_1 /m ;
        t_41:= T_1 /(m*n) ;
        if (N1<=t_41 and 2>=t_31) then
            d1:= eval(TCS__1, [lambda = 3, a = 300, b = .15, c = .25, A__m = 300, A__d = 150, A__r = 50, C__m = 4, P__m = 8, 
            P__d = 10, P__r = 12, theta__m = .15, theta__d = .12, theta__r = 0.5e-1, h__m = .2, h__d = .3, h__r = .5, i__m = .1, 
            i__d = .1, i__r = .1, i__om = .1, i__OD = .15, i__c = .3, i__e = .2, M = 2, alpha = 0.2e-1, t__2=t_2_1, N=N1]):
            if (d1<= d2) then
                d2:= d1;
                print("Value is updated",d2,N1,t_2_1,"for",m,n)
            end if
        end if    
        print(N1,t_2_1,t_31,t_41,d1,m,n)
    end do
end do

 

Thanks in advance

Any idea why Maple can simplify this expression only when multiplied by -1 but not otherwise?

expr:=sqrt(-2 + 2*I*sqrt(3));
simplify(expr)

But now

simplify(-1*expr)

Multiplying by -1 should not have mattered. Becuase -2 + 2*I*sqrt(3)=(1+I*sqrt(3))^2  Therefore sqrt(-2 + 2*I*sqrt(3)) is the same as 1+I*sqrt(3) and Maple knows this:

simplify((1 + sqrt(3)*I)-expr) gives zero.

But Maple only simplifies -expr  and not +expr.

Just wondering is someone can suggest why that is and if this is considered OK?

Maple 2020.1, Physics 724

Hello

I need to check if the solution (sols) of a (nonlinear) polynomial system of equations (the coefficients are not numeric) has only one solution for, let's say, y and (one solution for y and one solution for z).  I cannot use allvalues (not threadsafe according to CodeTools:-ThreadSafetyCheck) and then count the number of solutions. 

I have removed all solutions that fit the command 

ormap(x->x=true,map(has,rhs~(op~(sols)),_Z))

(RootOf works too).  (Please tell me if I am using ormap correctly).  

Even using the above command and then checking if nops(sols)=1, not all one solutions are caught.  

Many thanks

Ed

 

 

 

 

Any idea what this could mean?

I'm comparing 2 matrices where one of them is empty, and the other one is unitfree.

Hello,

I want to ask, I have a system of equations... 

eq1:=K_1=(((n_Cl-x)*u_Cl)*(n_H*u_H))/(n_HCl*m);
eq2:=K_2=(((n_Na-x)*u_Na)*(n_OH*u_OH))/(n_NaOH*m);
eq3:=K_w=(n_H*u_H/m)*(n_OH*u_OH/m);
eq4:=K_NaCl=((n_Na-x)*u_Na*(n_Cl-x)*u_Cl)/m^2;
eq5:=(n_NaCl-x)=(n_Na-x)+n_NaOH;
eq6:=(n_NaCl-x)=(n_Cl-x)+n_HCl;
eq7:=(n_Na-x)+n_H=(n_Cl-x)+n_OH;
eq8:=2*ionic=(n_H/m)+((n_Cl-x)/m)+((n_Na-x)/m)+(n_OH/m);
eq9:=u_H=0.4077*ionic^2-0.3152*ionic+0.9213;
eq10:=u_Na=0.0615*ionic^2-0.2196*ionic+0.8627;
eq11:=u_OH=0.1948*ionic^2-0.1803*ionic+0.8887;
eq12:=m=r*V;
eq13:=u_Cl=(1.417625986641341e-01)*exp^(-ionic/2.199955601666953e-02)+2.369460669647978e-01*exp^(-ionic/3.756472377688394e-01)+5.859738096037875e-01;

but when I use solve command, Maple starts computing, but suddenly gives message: Solutions may have been lost. 

I guess problem is the last exponential equation. Is there any way how to make Maple to be able to compute this system?

 

             

What is the best way to get some one on one training in maple , has anyone done this?

Area of shadow : i have studied one way of solution by hand, but now in Maple ?
Note: for math illustrations : geogebra seems to be wel suited

I would like to plot a specific vector with an initial point of <4,3,-5> and a terminal point of <3,-1,4>. I have been searching through Maple Primes and Maple Soft.

restart;
M1 := 12.3:
M2 := 12.4:
M3 := 12.5:
R := 50:

EQ:={(diff(F(x), x $ 4)) - M1*diff(G(x),x$2) -2*R*F(x)*diff(F(x),x$3)=0, diff(G(x),x$2)+ M2*(diff(F(x),x$2)-2*G(x)) +M3*(diff(F(x),x)*G(x)-2*F(x)*diff(G(x),x))=0}:


IC:={D(F)(-1)=0, D(F)(1)=0,F(-1)=-1,F(1)=1,G(-1)=0,  G(1)=0}:

sol:= dsolve(EQ union IC,numeric,output=Array([-1,-0.9,-0.8,-0.7,-0.6,-0.5,-0.4,-0.3,-0.2,-0.1,0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1]));
Error, (in dsolve/numeric/bvp) uanble to achieve continuous solution with requested accuracy of 0.1e-5 with maximum 128 point mesh (was able to get 0.47e-5), consider increasing `maxmesh` or using larger `abserr`
plots:-odeplot(sol,[x,F(x)],x=-1..1,color=red,axes=box)


Error, (in plots/odeplot) input is not a valid dsolve/numeric solution
plots:-odeplot(sol,  [x, diff(F(x), x)], x = -1 .. 1, color =  green, axes = box)
Error, (in plots/odeplot) input is not a valid dsolve/numeric solution
plots:-odeplot(sol,[[x,F(x)],[x,diff(F(x),x)],[x,G(x)]],x=-1..1,color=[red,green,blue],axes=box):
Error, (in plots/odeplot) input is not a valid dsolve/numeric solution
plots:-odeplot(sol, [x, G(x)], x = -1 .. 1, color = blue, axes = box);
Error, (in plots/odeplot) input is not a valid dsolve/numeric solution

 

solve( sum((1/(1+x+x^2))*y^n, n=1..infinity) = 1, parametric=true, real);

 

How to solve two variables summation equation with parametric true or real triangularize?

how to solve for x and y?

First 522 523 524 525 526 527 528 Last Page 524 of 2428