MaplePrimes Questions

Dear there,

I want to create a new package. 

Goal of the package:

I have two functions psi(n,m,x) and w(n,x).

 

These functions are defined differently in case A, and in case B

 

In my future works,

I want to use the functions psi(n,m,x) and w(n,x) in ONE (same) worksheet by calling the package.

 

Case A;

 K:=2^(k-1):
with(orthopoly): 
psi:=(n,m,x)->piecewise((n-1)/K <= x and x <= n/K,
(sqrt((m+1/2)*2^k))*LegendreP(m,2^k*x-2*n+1), 0);   
w:=(n,x)->1;  
 

 

Case B;

K:=2^(k-1):
with(orthopoly):
unprotect(gamma):
h:=(m,epsilon,gamma)->2^(epsilon+gamma+1)*GAMMA(epsilon+m+1)*GAMMA(gamma+m+1)/((2*m+1+epsilon+gamma)*m!*GAMMA(epsilon+gamma+1));


psi:=(n,m,x)->piecewise((n-1)/K <= x and x <= n/K,  2^(k/2) *h(m,epsilon,gamma)*simplify(JacobiP(m,epsilon,gamma,2^(k)*x-2*n+1)), 0); 
  

w:=(n,x)->(1-x)^(epsilon)*(1+x)^gamma; 

How can we achieve this in the simplest way?

 

MY TRY: (Please click to download the code.mw)

test:=module()
export functionA,functionB;
 option package;


######################################################
functionA:=proc(k,M) local K,h,psi,w; 
K:=2^(k-1):
with(orthopoly): 
psi:=(n,m,x)->piecewise((n-1)/K <= x and x <= n/K,
(sqrt((m+1/2)*2^k))*LegendreP(m,2^k*x-2*n+1), 0);   
w:=(n,x)->1;   
return psi(n,m,x) ,w:
end proc:
######################################################


functionB:=proc(k,M,epsilon,gamma) local K,h,psi,w; 
K:=2^(k-1):
with(orthopoly):
unprotect(gamma):
h:=(m,epsilon,gamma)->2^(epsilon+gamma+1)*GAMMA(epsilon+m+1)*GAMMA(gamma+m+1)/((2*m+1+epsilon+gamma)*m!*GAMMA(epsilon+gamma+1));


psi:=(n,m,x)->piecewise((n-1)/K <= x and x <= n/K,  2^(k/2) *h(m,epsilon,gamma)*simplify(JacobiP(m,epsilon,gamma,2^(k)*x-2*n+1)), 0); 
  

w:=(n,x)->(1-x)^(epsilon)*(1+x)^gamma;   
return psi(n,m,x),w(n,x):
end proc:
######################################################

end module;


savelib(test):


# FOR EXAMPLE
restart:
with(test);

#For k=2,M=3 in FunctionA, let's calculate values of "Psi(2)" and "w(2,x)"
k:=2:
M:=3:
K:=2^(k-1):
N:=K*M:
(psi,w):=functionA(2,3):
psi:=(n,m,x)->psi; 
w:=(n,x)->w;
unprotect(Psi):
Psi:=x->Array([seq(seq(psi(i,j,x),j=0..M-1),i=1..K)] )^+:
Psi(2);
w(2,x);


#Now, let's calculate values of "Psi(2)" and "w(2,x)" For  k=3,M=4, epsilon=1, gamma=2 in FunctionA 

 (psi,w):=functionB(3,4,1,2):
Psi(2);
w(2,x);

 

 

 

Hi,
Please see the attached file. 

s1.mw

Hi, I hope your going well

 

I was wondering if i can index my matrix column like in the image below and if i can replace u(1) for is estamted value

 

 

 

 

Thank a lot <3

 

 

 

 

 

 

 

 

 

How do I get Maple to simplify:

 

Io := I Cp Vin L1/(M sqrt(Cp L1))

 

to :  I sqrt(L1 CP) Vin/ M  ?

 

Furthermore, if  w = 1/sqrt(L1 *CP),  how do I get Maple to display the solution or the simplification as:

I*Vin/(w M) ?

I've t ried multiple substitutions and simplifications to no avail.

 

Thank you.

Jorge

 

I*Cp*RL*Vin*L1/(M*(Cp*L1)^(1/2))

(4)

simplify(I*Cp*RL*Vin*L1/(M*(L1*Cp)^(1/2)), 'symbolic')

I*Cp^(1/2)*RL*Vin*L1^(1/2)/M

(5)

 

NULL

Io := Vores/RL

I*Cp*Vin*L1/(M*(Cp*L1)^(1/2))

(6)

simplify(I*Cp*Vin*L1/(M*(L1*Cp)^(1/2)))

I*Cp*Vin*L1/(M*(Cp*L1)^(1/2))

(7)

simplify(I*Cp*Vin*L1/(M*(L1*Cp)^(1/2)), 'assume = real')

I*Cp*Vin*L1/(M*(Cp*L1)^(1/2))

(8)

combine(Vores/RL, power)

I*Cp*Vin*L1/(M*(Cp*L1)^(1/2))

(9)

factor(I*Cp*Vin*L1/(M*(L1*Cp)^(1/2)))

I*Cp*Vin*L1/(M*(Cp*L1)^(1/2))

(10)

combine(I*Cp*Vin*L1/(M*(L1*Cp)^(1/2)), radical)

I*Cp*Vin*L1/(M*(Cp*L1)^(1/2))

(11)

I*Cp*Vin*L1/(M*(L1*Cp)^(1/2))

cancel(I*Cp*Vin*L1/(M*(Cp*L1)^(1/2)))

(12)

simplify(cancel(I*Cp*Vin*L1/(M*(L1*Cp)^(1/2))), 'assume = real')

I*Cp*Vin*L1/(M*(Cp*L1)^(1/2))

(13)

simplify(I*Cp*Vin*L1/(M*(L1*Cp)^(1/2)), 'radical')

I*Cp*Vin*L1/(M*(Cp*L1)^(1/2))

(14)

simplify(I*Cp*Vin*L1/(M*(L1*Cp)^(1/2)), 'symbolic')

I*Cp^(1/2)*Vin*L1^(1/2)/M

(15)

``


 

Download Resonant_xformer.mw

 

Sometimes I find Maple a bit unconsequent regarding indexing, some things start with 0, others with 1.

The ReplaceChild function clearly starts with 1 for example, as you see in the help function.

ReplaceChild( 2 = XMLElement( "NEW", [], "text" ), doc )

replaces the second element in the list.

When using the AddChild function, one has to enter 0.

The AddChild(xmlTree, child, n) command creates a new XML element from xmlTree by inserting the XML element child at the position indicated by n. Parameter n must be less than or equal to the number of children in the original tree xmlTree. The new child node child becomes the n + 1st child of the resulting tree.

The first sentence sounds logical, but I would then expect the position of the first element to be 1. The other 2 sentences in the help file contradict the first one in my opinion. Either the position of the element is 0, as stated in the first sentence - then it also should be possible to get its value in the position 0. Or it is 1, but then it also should have been defined at position 1.
 

restart;
deq1 := diff(u(x, y), x) - diff(u(x, y), y$2) = exp(x+y);
                              /  2         \             
              / d         \   | d          |             
      deq1 := |--- u(x, y)| - |---- u(x, y)| = exp(x + y)
              \ dx        /   |   2        |             
                              \ dy         /             

deq2 := diff(u(x, y), x) - diff(u(x, y), y$2) = exp(1)^(x+y);
                            /  2         \                  
            / d         \   | d          |           (x + y)
    deq2 := |--- u(x, y)| - |---- u(x, y)| = (exp(1))       
            \ dx        /   |   2        |                  
                            \ dy         /                  

pdsolve(deq1, u(x,y));  ### no result
pdsolve(deq2, u(x,y));
                        /                                        
                        |                                        
PDESolStrucApplyFunction|uApplyFunction(x,y)=_F1ApplyFunction(x)
                        \                                        

                        1
  _F2ApplyFunction(y) - -
                        2

                       x+y                                                                                   
  (expApplyFunction(1))    (_C1 expApplyFunction(uminus0y)+_C2 expApplyFunction(y)+_C3 expApplyFunction(y) y)
  -----------------------------------------------------------------------------------------------------------
                                            _C3 expApplyFunction(y)                                          

  ,[{diffApplyFunction(_F1ApplyFunction(x),x)=_c[1] _F1

  ApplyFunction(x),diffApplyFunction(diffApplyFunction(_F2

                                                    \
                                                    |
  ApplyFunction(y),y),y)=_c[1] _F2ApplyFunction(y)}]|
                                                    /

No solution appears when the differential equation is expressed in standard form, but when exp(x + y) is converted to

exp(1)^(x + y) the correct solution appears.

 

Can anyone help with forcing this to simplify

assume(x>0)

assum(y>0)

simplify(sqrt(-x^2-y^2))

I am looking for this to force the sqrt to return as the imaginary number multiplied by the square root of x^2+y^2

simplify(sqrt(-x^2)) does simplify as far as bringing in the imaginary number 

Many thanks

Hello
I solved an equation using Maple . but in answer there is RootOf statement that I can't change to a simple statement without RootOf.

restart

``

``

((Lr2*(vo+vs)*sqrt(Lr1*Lr2)+vo*Lr1*sqrt(Lr1*Lr2))*sin(t*sqrt((Lr1+Lr2)/(Lr1*Lr2*cr)))*sqrt(cr*(Lr1+Lr2))+vs*t*Lr1*(Lr1+Lr2))/((Lr1+Lr2)^2*Lr1)

((Lr2*(vo+vs)*(Lr1*Lr2)^(1/2)+vo*Lr1*(Lr1*Lr2)^(1/2))*sin(t*((Lr1+Lr2)/(Lr1*Lr2*cr))^(1/2))*(cr*(Lr1+Lr2))^(1/2)+vs*t*Lr1*(Lr1+Lr2))/((Lr1+Lr2)^2*Lr1)``

(1)

eq := ((Lr2*(vo+vs)*sqrt(Lr1*Lr2)+vo*Lr1*sqrt(Lr1*Lr2))*sin(t*sqrt((Lr1+Lr2)/(Lr1*Lr2*cr)))*sqrt(cr*(Lr1+Lr2))+vs*t*Lr1*(Lr1+Lr2))/((Lr1+Lr2)^2*Lr1)

((Lr2*(vo+vs)*(Lr1*Lr2)^(1/2)+vo*Lr1*(Lr1*Lr2)^(1/2))*sin(t*((Lr1+Lr2)/(Lr1*Lr2*cr))^(1/2))*(cr*(Lr1+Lr2))^(1/2)+vs*t*Lr1*(Lr1+Lr2))/((Lr1+Lr2)^2*Lr1)

(2)

solve(eq, t)

-(Lr1*Lr2)^(1/2)*(Lr1*cr+Lr2*cr)^(1/2)*sin(RootOf(Lr1*sin(_Z)*(Lr1*cr+Lr2*cr)^(1/2)*((Lr1+Lr2)/(Lr1*Lr2*cr))^(1/2)*(Lr1*Lr2)^(1/2)*vo+Lr2*sin(_Z)*(Lr1*cr+Lr2*cr)^(1/2)*((Lr1+Lr2)/(Lr1*Lr2*cr))^(1/2)*(Lr1*Lr2)^(1/2)*vo+Lr2*sin(_Z)*(Lr1*cr+Lr2*cr)^(1/2)*((Lr1+Lr2)/(Lr1*Lr2*cr))^(1/2)*(Lr1*Lr2)^(1/2)*vs+_Z*Lr1^2*vs+_Z*Lr1*vs*Lr2))*(Lr1*vo+Lr2*vo+Lr2*vs)/(Lr1*(Lr1+Lr2)*vs)

(3)

``

Download spr.mw

How can I simplify to an answer without RootOf?

Thank u

I want to create a 2D and 3D graph of the following question. Evaluate F xy+y+z along the curve r(t)=2ti+tj+(2-2t)k, 0<=t<=1 I found the line integral to be 13/2. I am just stuck on how to graph this in 2D and 3D.

Thank you all in advance! I enjoy learning all the new tricks in Maple from you all.

Hello

I am not familiar with the use of notsero in SolveTools:-PolynomialSystem. Is there any special syntax to use it?  In the following example, the trivial solution {x=0,y=0} is to be eliminated.  

SolveTools:-PolynomialSystem({x*(x^2 - 2), y*(y^2 - 2)}, {x, y},explicit=true)

If I issue the command

SolveTools:-PolynomialSystem({x*(x^2 - 2), y*(y^2 - 2)}, {x, y},{x,y},explicit=true)

all roots with either x=0 or y=0 are eliminated.  

Can netzero be used to eliminate only the trivial solution?  

 

Many thanks

 

 

I'm trying to compute the numerical solution for a PDE using the numerical solution of a first-order ODE. I looked at the INTEGRATE keyword of the pdsolve function, but I'm not sure how to use it. Can someone show an example of how to use this keyword?

Hello,

I'm new at Maple, so I'm still trying to figure out basic stuff. I have solved an ode with t as independent variable and x as dependent one and I have used plots[odeplot] to plot x over t, but I also need to plot t over x. Any ideas how I can do that? Here's my code:

ode := 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

ics := x(0) = xlow

solx := dsolve({ics, ode}, numeric, range = 0 .. tfin)

plots[odeplot](solx, 0 .. tfin)

 

Hi

I have the following fractional  system of differential equation. How to plot it for alpha=0.5, beta=0.5?

eq1:=diff(y1(t),t$alpha)=0.04-(0.09*y1(t)*y2(t))-(0.00250*y1(t)*y2(t))/((0.03500+y2(t)))-0.04*y1(t);                                                                                                                                                                    

eq2:=diff(y2(t),t$beta)=(0.09*y1(t)*y2(t))+(0.00250*y1(t)*y2(t))/((0.035+y2(t)))-(0.02+0.04)*y2(t);

 

Hello

I have a funtion defined as 

a := diff(u*ln(m__o/(-q*t + m__o)) - g*t, t)

where m_0, q, g, and u are constants with dimensions. T is the variable and has dimensions as well. I need to print out columns of this function and other similar functions, v and h, in 4 seconds intervals of t. So what I have is this:

for i from -4 by 4 to 80 do
    if i = -4 then printf("%12s %18s %15s %15s \n", "time", "acceleration", "velocity", "altitude"); else printf("%10d %c %10.2f  %s %10.2f  %s %10.2f  %s \n", i, "s", eval(a, t = i), "ft/s^2", eval(v, t = i), "ft/s", eval(h, t = i), "mi"); end if;
end do

this works perfectly fine until I assign units to the constants and t. Then I get the error: Error, (in fprintf) number expected for floating point format. 

Then I also need to plot a v and h against t. Seems like plot doesn't work either with units.

 

So what do i do?

Thanks

First 359 360 361 362 363 364 365 Last Page 361 of 2308