Carl Love

Carl Love

28070 Reputation

25 Badges

13 years, 29 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are answers submitted by Carl Love

Here's another way: We make a single recursive procedure that reads its own index (whatever's in the square brackets after the procedure name). No loop is needed.

phi:= proc(x,y)
local s, j:= op(1,procname);
     `if`(j=1, exp(x-y), int(exp(x-s)*thisproc[jj-1](s,y), s= y..x))
end proc:


phi[1](x,y);

phi[2](x,y);

phi[3](x,y);

 

Use plots:-odeplot. For example, assuming your independent variable is t:

plots:-odeplot(dsn, [t, Y[1](t)], t= 0..10);

You have three syntax errors. I'm surprised that you did not get an error message.

The first two errors are that you used both proc(x) ... and x-> ... to define procedures. Every procedure must begin with one of these, but never both.

The third error is that you didn't declare the variable of integration. Given a procedure f, its integral can be expressed these two ways: int(f, a..b) or int(f(x), x= a..b). (There a few other syntaxes also.)

So here's your code, corrected. I pulled the procedure definitions out of the loop and simplified a complicated logical expression by using xor. And I removed needless repetition from the sum of integrals expression.

PMmmf_func:= x->
     `if`(x >= rotorshift xor trunc((x-rotorshift)/tau[p])::odd, 1, -1)*H[c]*l[m]:

B[g]:= x-> 1000*mu[0]*(PMmmf_func(x)+MMF_func(x))/d[eff, stator](x):

for i from 0 to 42 do
     rotorshift:= evalf[6](2*(1/180* i *Pi*(1/2*OO[gap]))/N[m]-1/2*(tau[p]-tau[s]));
     Flux(i+1):=
          add(Int(B[g](x), x= map(`*`, R, tau[s])), R= [0..1, 3..4, 6..7, 9..10])*1e-3*L[ro]    
end do:

This will return the integrals in unevaluated Int form. If you want numeric results, apply evalf to these.

 

You were correct that the presence of Pi was causing your problem. You can convert it to a number by replacing Pi with evalf(Pi).

Since there are only 11 variables there are only 2^11 = 2048 possible variable assignments. It would be trivial to loop through all possibilities and select the ones that satisfy the equations. I'll work on some code for it later today, if you haven't finished it already. I expect it'll be only 10-20 lines.

How about this?

Y:= expand(add(a_||k*x^k, k= 0..3)*f(y) + add(b_||k*x^k, k= 0..3)*g(y));

alias(P_1= coeff(Y, f(y)), P_2= coeff(Y, g(y))):
collect(Y, [f(y),g(y)]);


Maintaining sets of Vectors or Matrices in Maple is a big problem because Maple considers each copy of a Vector or Matrix  to be a unique entity even if they are identical mathematically. One way to get around this is by converting a Vector to list form or converting a Matrix to listlist form before adding it to the set. Thus,

St1:= St1 union {convert(Mt1.Ms, list)};

Be careful about building sets or lists one element at a time. It is inefficient when done large scale. There are better ways that require a tiny bit more programming.

Eqs:= [sqrt((x-1)^2+(y-5)^2)+(1/2)*abs(x+y) = 3*sqrt(2), sqrt(abs(x+2)) = (2-y)]:
Y:= solve(Eqs[2], y);

X:= solve(eval(Eqs[1], y= Y));

[x,y] =~ eval([x,Y], x= X);

 

1. To convert an integer n to base b, use convert(n, base, b). To convert a float to another base (other than base 2) will require a custom procedure I think. I might work on it.

2. To do custom logical operations on strings of bits, use the Bits package. There are only 16 possible binary operations on two variable. Every one of them can be built from the operators given in the package. The example you gave is simply Not(2nd op); it doesn't depend on the first operand.

So,

Bits:-Not(235, bits= 8);

                        20

You almost had the answer. You apparently don't know about the value command, which converts inert integrals (those composed with Int) to active form (as if composed with int). You attempted to do this with eval. You also forgot the v= in the limits of integration. Also, those complicated (and not mathematically robust) applyrules are unnecessary; it can be done with convert and simplify.

Int(ln(1+x)/(1+x^2), x= 0..1):
IntegrationTools:-Change(%, x= tan(v/2));

convert(%, sincos);

simplify(%);

value(%);

I don't know how to make pdsolve solve this easy PDE. Here's a solution with Laplace transforms and dsolve.

restart:
pde:= diff(u(x,t),t$2) + 2*diff(u(x,t),t) - diff(u(x,t),x$2) = 18*sin(3*Pi*x/L):
ic:= u(0,t)=0, u(L,t)=0, u(x,0)=0, D[2](u)(x,0)=0:
inttrans[laplace](pde, t, s);

#Convert to an ODE:
eval(%, [ic, laplace(u(x,t), t, s)= U(x)]);

dsolve({%, U(0)=0, U(L)=0}, U(x));

#Final solution:
Sol:= inttrans[invlaplace](rhs(%), s, t);

 

 

"Length of out exceeds limit of ...." is not an error. The computation was carried out fully. Maple's (Standard) GUI simply chose not to display the output. This output can still be assigned to a variable for continued analysis and manipulation.

You can set the maximum length of an expression that will be displayed using the Tools menu. Select Options, then the Precision tab. The last item is "Limit expression length to ...." But, I warn you, having a long expression displayed can make the GUI unbearably slow. And, really, what's the point of looking at an expression that's hundreds of screens long?

This is only an Answer to the question that you posed in the title of your Question:

There are a few types of displayed output that a Maple program can have. One type---which is probably most familiar to users of compiled languages---is that generated by explicit output-displaying statements such as print, iolib (printf, etc.), lprint, userinfo, and error (there may be a few other kernel-level commands in that list that I am forgetting).

Another type---which may be more familiar to users of interactive interpretted systems such as Maple---is the return value of the most recently executed statement. It is only this latter type which is suppressed by ending with a colon. The latter type can also be controlled by using the variable printlevel, which is set to 1 by default.

A third type is output generated by including option trace in a procedure. This is a debugging option.

(There might be a few other types of displayed output that I am forgetting.)

To get a result in terms of a hypergeometric function, use definite integration with a variable upper limit. In my experience, Maple is more likely to give an answer when integrals are done this way.

int(cos(t)^n, t= 0..x);

Any string of characters can be a name in Maple. It would be artificial to forbid the string `pi` and allow all others. What does Mathematica do if you use lowercase pi?

First 282 283 284 285 286 287 288 Last Page 284 of 395