Preben Alsholm

13728 Reputation

22 Badges

20 years, 241 days

MaplePrimes Activity


These are answers submitted by Preben Alsholm

As Robert Israel pointed out there are apparently no solutions.

The solutions Maple finds are the same ones that it finds when solving

(x*h11-2*y*h1+z*h)^3*eqs

thus it ignores that the denominator (x*h11-2*y*h1+z*h)^3 in the normalized equations in fact is zero for the solutions found.

You may try the following lines:

restart;
k := 1/(x*h11-2*y*h1+z*h);
eqs := normal([2*k^2*P1*(y^2-x*z)*(H1*k*z*P1+h11*H11) = 0, 2*k^2*P1*(y^2-x*z)*(x*k*H1*P1+h*H11) = 0, -4*h1*H11-4*H11*k^2*P1*(y^2-x*z)*(h1-y*k*P1) = 0]);
sol:=solve(eqs, [x, y, z],explicit);
simplify(eval(eqs,sol[1]));
indets(eval(eqs,sol[1]),algebraic^(-3));
expand(%);
eqs2:=simplify(map2(`*`,(x*h11-2*y*h1+z*h)^3,eqs));
sol2:=solve(eqs2, [x, y, z],explicit);
simplify(eval(eqs2,sol[2]));
simplify(eval(eqs2,sol[1]));

 

Or the following, where random integer values in the range 1 .. 10 are chosen for the parameters.

Here Maple finds no solution.

restart;
r:=rand(1..10);
k := 1/(x*h11-2*y*h1+z*h);
eqs := normal([2*k^2*P1*(y^2-x*z)*(H1*k*z*P1+h11*H11) = 0, 2*k^2*P1*(y^2-x*z)*(x*k*H1*P1+h*H11) = 0, -4*h1*H11-4*H11*k^2*P1*(y^2-x*z)*(h1-y*k*P1) = 0]):
param:=convert(indets(eqs,name) minus {x,y,z},list);
param2:=zip(`=`,param,['r()'$6]);
eqskonk:=eval(eqs,param2);
sol:=solve(%, [x, y, z],explicit);

Try removing the following line, which contains the first occurrence of 'Section*:

<Section collapsed="false" MultipleChoiceAnswerIndex="-1" MultipleChoiceRandomizeChoices="false" TrueFalseAnswerIndex="-1" EssayAnswerRows="5" EssayAnswerColumns="60">

Then remove one of the tags </Section> at the very end of the worksheet.

Now you will have something. Maple still complains, but there is still a lot there.

You could try

with(plots):
conformal(z,z=-2*I..2+2*I,scaling=constrained):

plots:-conformal(z,z=-2*I..2+2*I,scaling=constrained)
conformal(z^2,z=-2*I..2+2*I,scaling=constrained):

plots:-conformal(z^2,z=-2*I..2+2*I,scaling=constrained)
display(Array([%%,%]));

Since it is indeed an automatic simplification, which is revealed by doing

'(a*b/c)^2*d';

(notice the unevaluation quotes) this can only be prevented by artificial means, like e.g.

``(a*b/c)^2*d;

expand(%); will give you back a^2*b^2*c^(-2)*d.

I suppose that a procedure could be written that somehow rewrote terms like a^2*b^2*c^(-2)*d as

``(a*b/c)^2*d;

###INSERTED later:

Since suggesting that a procedure could be written, I tried for a while and came up with the following, which most likely could be done in a more elegant way.

p2:=proc(u::algebraic) local u0,u1,u2,u3,u4;
    if type(u,`+`) then
       map(procname,u)
    elif type(u,`*`) and member(true,map(type,{op(u)},{name^2,name^(-2)})) then
       u0:=evalindets(u,function,freeze);
       u1:=evalindets(u0,{algebraic^2,algebraic^(-2)},x->``(sqrt(x,symbolic)));
       u2,u3:=selectremove(type,u1,specfunc(algebraic,``));
       u4:=thaw(``(eval(u2,``=(()->args)))^2*u3);
       evalindets(u4,specfunc(name,``),expand);
    else
       u
    end if
end proc;

u:=a^2*b^2/c^2*d+A^4*y^2*a/B^2*sin(x)+sin(y^2*a)+ln(x)*k^2/c^2+56*v^2+(x+y)^2/c^2;

p2(u);

which results in

(a*b/c)^2*d+(y/B)^2*A^4*a*sin(x)+sin(y^2*a)+(k/c)^2*ln(x)+56*v^2+((x+y)/c)^2

Taking hirnyk's infinite summation example

res1:=int(sum(x^(2*k+1), k = 1 .. infinity)*sqrt(1-x), x = 0 .. 1);

#Numerical check of the result
res1num:=evalf(Int(sum(x^(2*k+1), k = 1 .. infinity)*sqrt(1-x), x = 0 .. 1));
evalf(res1);

#This is not really an infinite summation example since Maple first computes the sum:

sum(x^(2*k+1), k = 1 .. infinity);
# and gets the expected x^3/(1-x^2).
#After that it integrates x^3/(1-x^2)*sqrt(1-x) from 0 to 1.

#Now using an inert summation:

res2:=int(Sum(x^(2*k+1), k = 1 .. infinity)*sqrt(1-x), x = 0 .. 1);
#We first see that Maple integrates term by term.
#Then we ask for the value of the inert sum (i.e. replacing Sum by sum):
res3:=value(res2);
#Checking:
evalf(res2);
#And the following which takes a while
evalf(res3);
#Result 40.93509538-3.479299454*I

#We see (Maple 14) that res3 or its numerical evaluation is wrong!

#Step by step:
igr:=combine(Sum(x^(2*k+1), k = 1 .. infinity)*sqrt(1-x));
IntegrationTools:-Expand(Int(igr,x=0..1));
applyop(Int,1,igr,x=0..1);
applyop(value,1,%);


You did say you wanted a table, but if you meant it to look like one you might try:

a:=plot(x^2,x=-2..2):
#Two variants of the definition of the list of lists of points [x,y]:
#M:=op(indets(a,listlist)):
M:=op([1,1],a):
interface(rtablesize=infinity);
Matrix(M);

This will work:

 

plotoversurface:=proc(p1,s1)
  local a,b,to3d,c,f:
  a:=plot3d([s1],x=-10..10,y=0..100,style=patchnogrid):
  b:=plot(p1,x=-10..10):
  f:=unapply([x,y,s1],x,y);
  to3d:=plottools:-transform(f):
  c:=to3d(b):
  plots:-display({a,c})
end proc:

Change the last line of the procedure 'discont' which reads like this

remove(type,disc,nonreal)

to

remove(hastype,disc,nonreal)

This can be done like this:

Discont:=subs(type=hastype,eval(discont));

The problem is that type nonreal does not include expressions like (1/2*I)/(Pi*_Z1).

I am not necessarily saying that it would be a good idea in general, though.

Converting your expression to 1D-input (I never, ever, use anything else) you get the result you presumably want.

T := RL/(j*omega*Cp*(RL-I/(omega*Cp))*(R/(j*omega*C[s]*(R-I/(omega*C[s])))+RL/(j*omega*Cp*(RL-I/(omega*Cp)))));
simplify(T);

#If your variable RL is actually R*L then:
T := R*L/(j*omega*Cp*(R*L-I/(omega*Cp))*(R/(j*omega*C[s]*(R-I/(omega*C[s])))+R*L/(j*omega*Cp*(R*L-I/(omega*Cp)))));
simplify(T);

What happens in 2D I don't care to speculate about.

To answer your last question, you could do like this:

works := proc(p) local res;
     if(p<0) then
         res:=convert(rtable(1..3, {1=2*p, 2=2.7, 3=p^2}), Vector);
     else
         res:=Vector([-1,2,p*p]);
     end if;
 CodeGeneration[C](res);
 end proc:
works(5);
cg0[0] = -1;
cg0[1] = 2;
cg0[2] = 25;

But then the converting is superfluous, because the translation is not on a procedure, but on the rtable, where (as you noticed) there is no problem:

works2 := proc(p) local res;
     if(p<0) then
         res:=rtable(1..3, {1=2*p, 2=2.7, 3=p^2});
     else
         res:=Vector([-1,2,p*p])
     end if;
 CodeGeneration[C](res)
 end proc:
works2(-5);
cg2[0] = -10;
cg2[1] = 0.27e1;
cg2[2] = 25;

From the help page 'Notes on Code Translation Using the CodeGeneration Package':

"The CodeGeneration functions can analyze some rtable type declarations and constructors within procedures.  Data types, dimensions and ranges are recognized, but most options are ignored.  The only initializer accepted is a list. "

Not even this works:

xpr_3 := proc (p)
     rtable(1 .. 2, {1 = 1, 2 = 1})
 end proc:
CodeGeneration[C](xpr_3);

But this does:

xpr_3 := proc (p)
     Vector([1e-3+4*p^2,-3*p,6,8*p^2,2*p,1666.666667])
 end proc;
CodeGeneration[C](xpr_3);

The following two versions both handle Pi without resorting to evalf.

f := proc(x) if is(x < 0) then x^2+1 else cos(x) end if end proc:
#Alternatively:
f:=x-> if is(x < 0) then x^2+1 else cos(x) end if;

f:=proc(x) piecewise(x < 0, x^2+1, cos(x)) end proc:
#Alternatively:
f:=x->piecewise(x < 0, x^2+1, cos(x));

The empty question deserves the empty answer.

Without seeing the procedure it is not possible to give the reason for the delayed evaluation.

The behavior, however, can be mimicked by the the following procedure, which just forces delay:

p:=proc() local cndtn1,cndtn2,bv1Lappr,bv1Rappr,Mi,bv1L,bv1R;
cndtn1 := -19882.77350*exp(0.9901951500e-2*bv1L)+2.172519170*exp(-1.009901952*bv1L)+200.*bv1L+19880. = -19882.77350*exp(0.9901951500e-2*bv1R)+2.172519170*exp(-1.009901952*bv1R)+200.*bv1R+19880.;
cndtn2 := -2.007965147*10^6*exp(0.9901951500e-2*bv1L)-2.151217913*exp(-1.009901952*bv1L)+2.008*10^6+100.*(bv1L-.6)^2+20000.*bv1L = -2.007965147*10^6*exp(0.9901951500e-2*bv1R)-2.151217913*exp(-1.009901952*bv1R)+2.00800015*10^6+100.*(bv1R-.6)^2+20000.*bv1R-(-19882.77350*exp(0.9901951500e-2*bv1R)+2.172519170*exp(-1.009901952*bv1R)+200.*bv1R+19880.)*(bv1R-bv1L);
bv1Lappr := -1.428147401;
Mi := -.712642354728244;
bv1Rappr := .6644399282;
#The delay is forced by using unevaluation quotes: ' ' around fsolve.
'fsolve'({cndtn1, cndtn2}, {bv1L, bv1R}, {bv1L = bv1Lappr .. Mi, bv1R = Mi .. bv1Rappr});
end proc:

#The two results from your post are reproduced with the following two commands:

p();

%;

Thanks to hirnyk for typing the numbers from your images. Bringing code in the form of images would make most people give up answering. It is much better to be able to copy and paste, as you can with my code above.

You could do like this, where you notice the use of the elementwise operations =~, <=~, op~, and convert~. Elementwise operations were introduced in Maple 13.

z := <yb,x1b,x2b>:
v1 := <v1y,v1x1,v1x2>:
v2 := <v2y,v2x1,v2x2>:
e1 := z =~ v1 + v2;
e2 := v1 <=~ UU*delta1;
e3 := v2 <=~ UU*delta2;

S:=op~(convert~({e1,e2,e3},set));
V:=op~(convert~({v1,v2},set));
solve(S,V);

In the case of equations I have been using the following extensions of convert for a while. They also work in earlier versions of Maple.

`convert/listeqs`:=proc(L::equation({Vector,Matrix}))
ListTools:-Flatten(convert(zip(`=`,lhs(L),rhs(L)),listlist))
end proc:
`convert/seteqs`:=proc(L::equation({Vector,Matrix})) convert(zip(`=`,lhs(L),rhs(L)),set) end proc:

First 149 150 151 152 153 154 155 Last Page 151 of 160