Carl Love

Carl Love

28035 Reputation

25 Badges

12 years, 318 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are answers submitted by Carl Love

P:= [$2..5]:
Tours:= combinat:-setpartition(P):
nops~(Tours);
([1,op]~)~(Tours);

 

Your equation is an ODE with a parameter, y; it is not really a PDE because there are no derivatives with respect to y. So, it can be solved with dsolve:

restart:
equa1:= diff(u(x), x, x) - y*(1+x):
dsolve({equa1, u(0)=0, D(u)(0)=0});

 

You can use continued fraction convergents, like this:

x:= rand(2^1000..2^1001)()/rand(2^1001..2^1002)():

evalf(x);

.392692920399853

cf:= NumberTheory:-ContinuedFraction(x):

seq(Convergent(cf, k), k= 1..19);

1/2, 1/3, 2/5, 9/23, 11/28, 75/191, 86/219, 1537/3914, 3160/8047, 4697/11961, 17251/43930, 56450/143751, 976901/2487697, 7871658/20045327, 8848559/22533024, 25568776/65111375, 111123663/282978524, 136692439/348089899, 247816102/631068423

evalf([%]);

[.500000000000000, .333333333333333, .400000000000000, .391304347826087, .392857142857143, .392670157068063, .392694063926941, .392692897291773, .392692929041879, .392692918652287, .392692920555429, .392692920397075, .392692920399872, .392692920399852, .392692920399854, .392692920399853, .392692920399853, .392692920399853, .392692920399853]

 

Download Continued_fraction_convergents.mw

If your version of Maple is too old to have the NumberTheory package, then exactly the same thing is available in the numtheory package as commands cfrac and nthconver.

 

You can apply simplify to nested piecewise to convert it to a one-level piecewise:

simplify(m);

eval([x,y,z], L);

Careful, that must be [x,y,z] rather than {x,y,z} lest it won't be an ordered triple.

0.3*(1 - 0.4*0.5) = 24%

It is not clear to me that the OP is interested in distinguishing between trees whose underlying graphs are isomorphic. This is often the treatment of the subject in an undergraduate mathematics course titled "graph theory" or "discrete mathematics", where a tree is defined simply as a connected undirected graph with no cycles. Using that definition, a representative of each isomorphism class of trees of order 7 can be displayed in a single row using

plots:-display(
   GraphTheory:-DrawGraph~(
      <GraphTheory:-NonIsomorphicGraphs(
         7, 6, output= graphs, outputform= graph, restrictto= connected
      )>^+
   )
);

On the other hand, if the OP does mean "trees" in the computer-science sense of rooted oriented trees, then these can be generated by the command Iterator:-OrientedForests. There are 48 of these of order 7, and they can be displayed in a 6x8 array like this:

plots:-display(
   GraphTheory:-DrawGraph~(
      Matrix(
         (6,8), 
         [seq(
            GraphTheory:-Graph({seq({k,V[k]}, k= 1..numelems(V))}),
            V= Iterator:-OrientedForests(6) #6 = 7 nodes - 1
         )]
      ), style= tree, root= 0
   )
);

Unfortunuately, neither of these solutions will work in the OP's claimed version, Maple 12.


 

restart:

 

From the indentity

sech(x): % = convert(%,sec);

sech(x) = sec(I*x)

it follows that

J0:= Int(sech(x)^q, x):
J:= Int(''sec''(I*t)^q, t= 0..x):
J0 = J;

Int(sech(x)^q, x) = Int(sec(I*t)^q, t = 0 .. x)

modulo a constant of integration, provided continuity. Make a u-substitution z= I*t:

J1:= IntegrationTools:-Change(J, I*t= z);

-I*(Int((1/cos(z))^q, z = 0 .. I*x))

Get the antiderivative

Int((1/cos(z))^q, z):  A:= value(%) assuming q::posint:  %% = A;

Int((1/cos(z))^q, z) = (Sum((Product(1-1/(-q+2*j+1), j = 0 .. i))*cos(z)^(-q+2*i+1), i = 0 .. -ceil(-(1/2)*q)-1))*sin(z)/q+(Product(1+1/(-q+2*j-1), j = 1 .. -ceil(-(1/2)*q)))*ln(sec(z)+tan(z))

and use it to evaluate the definite integral J1.

  -I*(Eval(A, z= I*x) - Eval(A, z= 0)) = eval(-I*(subs(z= I*x, A) - subs(z= 0, A)));

-I*(Eval((Sum((Product(1-1/(-q+2*j+1), j = 0 .. i))*cos(z)^(-q+2*i+1), i = 0 .. -ceil(-(1/2)*q)-1))*sin(z)/q+(Product(1+1/(-q+2*j-1), j = 1 .. -ceil(-(1/2)*q)))*ln(sec(z)+tan(z)), z = I*x)-(Eval((Sum((Product(1-1/(-q+2*j+1), j = 0 .. i))*cos(z)^(-q+2*i+1), i = 0 .. -ceil(-(1/2)*q)-1))*sin(z)/q+(Product(1+1/(-q+2*j-1), j = 1 .. -ceil(-(1/2)*q)))*ln(sec(z)+tan(z)), z = 0))) = -I*(I*(Sum((Product(1-1/(-q+2*j+1), j = 0 .. i))*cosh(x)^(-q+2*i+1), i = 0 .. -ceil(-(1/2)*q)-1))*sinh(x)/q+(Product(1+1/(-q+2*j-1), j = 1 .. -ceil(-(1/2)*q)))*ln(sech(x)+I*tanh(x)))

So the desired formula is

R:= expand(rhs(%)):
J0 = R;

Int(sech(x)^q, x) = cosh(x)*(Sum((Product(-q/(-q+2*j+1)+2*j/(-q+2*j+1), j = 0 .. i))*(cosh(x)^i)^2, i = 0 .. -ceil(-(1/2)*q)-1))*sinh(x)/(cosh(x)^q*q)-I*(Product(-q/(-q+2*j-1)+2*j/(-q+2*j-1), j = 1 .. -ceil(-(1/2)*q)))*ln(sech(x)+I*tanh(x))

If x is real, that can be simplified to

R1:= simplify(evalc(Re(R))) assuming q::posint;

((Product((-q+2*j)/(-q+2*j-1), j = 1 .. -ceil(-(1/2)*q)))*arctan(sinh(x))*q+cosh(x)^(-q+1)*(Sum((Product((-q+2*j)/(-q+2*j+1), j = 0 .. i))*cosh(x)^(2*i), i = 0 .. -ceil(-(1/2)*q)-1))*sinh(x))/q

 


 

Download Int_of_sech_power.mw

Your file titles indicate that you actually already know what to do: Use cat instead of ||. The parse is to convert the strings to names.

fe11_1:= p^2;
fe11_2:= p^3;
fle11_1:= p^4;
fle11_2:= p;
for appm in ["fe", "fle"] do 
   for i in ["11_1", "11_2"] do 
      f:= parse(cat(appm, i)); 
      sp:= evalf(int(f, p = 1 .. 11/3))+evalf(int(f, p = 11/3 .. 19/3))+evalf(int(f, p = 19/3 .. 9));
      print(f, sp) 
   end do
end do;

 

Why do you need the Excel file? You can do the entire plot with Maple:

plot3d(
   sin(A)*exp(1-L/1000), A= 0..2*Pi, L= 0..1000, coords= cylindrical,
   grid= floor~([360/1, 1000/5]), thickness= 0
);

Note that coordinate A is measured in radians rather than degrees.

It is not allowed to assign to a local variable unless the local variable evaluates to something that can be assigned to, namely a name. Do you want to change the value of b locally? Then you need a local variable. Do you want to change the value of some variable that is passed in for b? Then you need something like this:

P:= proc(a::integer, b::evaln(integer))
   if eval(b) = 2 then b:= 3 end if
end proc:
b:= 2:
P(a,b):
b;

                               3
b:= 2.5:
P(a,b);

Error, invalid input: P expects its 2nd argument, b, to be of type evaln(integer), but received b := 2.5
b:= 4:
P(a,b);
b;

                               4

Use of this technique is considered a bad programming practice called side effects.

Use fsolve, like this:

sys:= diff(ca(t), t) = -3.600000000*10^20*exp(-15098.13790/(340-20*ca(t)))*ca(t), ca(0) = 2:
sol:= dsolve({sys}, numeric):
fsolve(T-> eval(ca(t), sol(T)) - 0.2);

3.89994719649399

A variation on the above that a lot of people seem to prefer, but which makes little difference to me, is

sol:= dsolve({sys}, numeric, output= listprocedure):
fsolve(eval(ca(t), sol)(t) = 0.2);

 

Acer's answers are fine, but here is one to add to his list:

R:= Matrix((1,4), (i,j)-> x-> j*x);

This is what I would use because I prefer symbol infix operators over word prefix operators.

Your ODEs refer to cot(theta). This involves division by 0 at theta=0, which is your initial point. Hence, the system is "initially singular", as the error message says.

Tom Leslie's example shows that a type declaration of M::Matrix(datatype= ...) checks only the explicitly declared datatype of M. That's probably not what you want. You probably want to check that the contents of M have a specific data type. For that, you need to use coercion (see ?coerce), like this:

P:= proc(M::~Matrix(square, datatype= rational))
   #...
end proc:

Notice the tilde in front of the word Matrix. That indicates that coercion is desired.

square is a "top-level" property of Matrices; it isn't a shape. As I used it above, square will enforce that the input Matrix be square.

First 196 197 198 199 200 201 202 Last Page 198 of 395