Kitonum

21525 Reputation

26 Badges

17 years, 74 days

MaplePrimes Activity


These are answers submitted by Kitonum

The problem is that Maple does not implement work with piecewise-functions where the number of variables is greater than 1. For example, Maple cannot convert the sum of such functions into some new piecewise-function. Therefore, we have to do something manually. You have 2 variables  lambda[1]  and  lambda2 . Straight lines  (1 - alpha)*lambda[1] - lambda[2]=0  and  -(1 + alpha)*lambda[1] + lambda[2]=0  divide the entire plane  (lambda[1], lambda2)  into 4 regions  R1, R2, R3, R4. In your example,  alpha=0.01 is very small and therefore the regions  R1  and  R3  will be very narrow. Therefore, for better drawing, I took  alpha=0.3 .We define the functions  U1  and  U2  in terms of these regions, and we define the operations on the functions using procedures (for example for `-` sign we use the procedure  `p-`  below) :
 

restart;
alpha := 0.3;
e1:=(1 - alpha)*lambda[1] - lambda[2]:
e2:=-(1 + alpha)*lambda[1] + lambda[2]:
R1:=e1<=0 and e2<=0;
R2:=e1<=0 and e2>0;
R3:=e1>0 and e2>0;
R4:=e1>0 and e2<=0;
U1 := piecewise(R1,0,R2,0,R3,5,R4,5);
U2 := piecewise(R1,0,R2,5,R3,5,R4,0);
`p-`:=(U1,U2)->piecewise(seq(`if`(type(i,odd),op(i,U1),op(i,U1)-op(i,U2)),i=1..nops(U1)));
U:=`p-`(U1,U2);
A:=plots:-inequal([{e1<=0,e2<=0},{e1<=0,e2>0},{e1>0,e2>0},{e1>0,e2<=0}], lambda[1]=-3..3, lambda[2]=-3..3, optionsfeasible=[[color="Pink"],[color="LightBlue"],[color="LightGreen"],[color="Yellow"]],labels=[lambda[1], lambda[2]]):
B:=plots:-textplot([[2.3,2.3,"R1"],[-2,2,"R2"],[-2.3,-2.3,"R3"],[2,-2,"R4"]]):
plots:-display(A,B);
plot3d(U, lambda[1]=-3..3, lambda[2]=-3..3, numpoints=10000);
 

alpha := .3

 

R1 := `and`(.7*lambda[1]-lambda[2] <= 0, -1.3*lambda[1]+lambda[2] <= 0)

 

R2 := .7*lambda[1]-lambda[2] <= 0 and 0 < -1.3*lambda[1]+lambda[2]

 

R3 := `and`(0 < .7*lambda[1]-lambda[2], 0 < -1.3*lambda[1]+lambda[2])

 

R4 := -1.3*lambda[1]+lambda[2] <= 0 and 0 < .7*lambda[1]-lambda[2]

 

U1 := piecewise(`and`(.7*lambda[1]-lambda[2] <= 0, -1.3*lambda[1]+lambda[2] <= 0), 0, .7*lambda[1]-lambda[2] <= 0 and 0 < -1.3*lambda[1]+lambda[2], 0, `and`(0 < .7*lambda[1]-lambda[2], 0 < -1.3*lambda[1]+lambda[2]), 5, -1.3*lambda[1]+lambda[2] <= 0 and 0 < .7*lambda[1]-lambda[2], 5)

 

U2 := piecewise(`and`(.7*lambda[1]-lambda[2] <= 0, -1.3*lambda[1]+lambda[2] <= 0), 0, .7*lambda[1]-lambda[2] <= 0 and 0 < -1.3*lambda[1]+lambda[2], 5, `and`(0 < .7*lambda[1]-lambda[2], 0 < -1.3*lambda[1]+lambda[2]), 5, -1.3*lambda[1]+lambda[2] <= 0 and 0 < .7*lambda[1]-lambda[2], 0)

 

`p-` := proc (U1, U2) options operator, arrow; piecewise(seq(`if`(type(i, odd), op(i, U1), op(i, U1)-op(i, U2)), i = 1 .. nops(U1))) end proc

 

piecewise(.7*lambda[1]-lambda[2] <= 0 and -1.3*lambda[1]+lambda[2] <= 0, 0, .7*lambda[1]-lambda[2] <= 0 and 0 < -1.3*lambda[1]+lambda[2], -5, 0 < .7*lambda[1]-lambda[2] and 0 < -1.3*lambda[1]+lambda[2], 0, 0 < .7*lambda[1]-lambda[2] and -1.3*lambda[1]+lambda[2] <= 0, 5)

 

 

 

 


 

Download piecewise.mw

restart;
sol:=msolve(x^2=-1, 5);
map2(eval, x, [sol]);

                                    sol := {x = 2}, {x = 3}
                                              [2, 3]

restart;
A:=[seq(a||i,i=1..4)];
B:=[seq(b||i,i=1..4)];
Matrix(4,8, {seq((i,2*i-1)=A[i], i=1..4), seq((i,2*i)=B[i], i=1..4)});

                             

 

Use the continuous option:

restart;
F:=int( 1/(1+x^n), x=0..1, continuous);
convert(F, hypergeom);

                                

                              

Use the Student:-VectorCalculus package and the LineInt command for this:

restart;
with(Student:-VectorCalculus):
LineInt(VectorField(<x^2-y^2+x, -2*x*y-y>), Path(<t^2, t>, t = 0 .. 1));
LineInt(VectorField(<x^2-y^2+x, -2*x*y-y>), Path(<t^2, t>, t = 0 .. 1),output=plot,fieldoptions=[fieldstrength = fixed]);

                     

 

The expression for your function can be greatly simplified to the fraction  (x-4)/x  by reducing the numerator and denominator by  x^2-9 . But at the same time you lose information that the original expression in points  x=-3  and  x=3  will be  0/0  (these will be the points of removable discontinuity) .
For better plotting, it is useful to increase the range on the x-axis, it is reasonable to limit the range on the y-axis. Additionally, the horizontal asymptote, vertical asymptote and points of removable discontinuity are shown in blue on the plot below:

restart;
f:=x->(x^3 - 4*x^2 - 9*x + 36)/(x^3 - 9*x);
g:=unapply(simplify(f(x)),x);
Lines:=plot([f(x), [0,t, t=-10..10],1], x=-7..7, y=-6..7, linestyle=[1,3,3], thickness=[2,0,0], color = [red,blue$2], discont ):
Points:=plot([[-3,g(-3)],[3,g(3)]], style=point, symbol=circle, color=blue, symbolsize=14):
plots:-display(Lines,Points);

                   

Addition. If we write  (x - 4)/x = 1 - 4/x , then we see that the graph of your function will be symmetrical about the point  (0, 1)  (this graph is called a hyperbola).

a. To plot a semicircle graph, it is better to use parametric equations, which make it easy to plot any part of the circle.
b. Obviously, the rotation results in a ball of radius 2 centered at the origin.
c. To calculate the volume of this ball, you can use the explicit equation of the given semicircle and the penultimate formula from your list.
 

restart;
plot([2*cos(t),2*sin(t),t=0..Pi], scaling=constrained);
f(x):=sqrt(4-x^2):
Pi*int(f(x)^2, x=-2..2);

                    

 

 

 

I'm guessing that the original expression is missing the parentheses (for the numerator and denominator), as well as the multiplication signs. Using the indication in the problem statement, we first find the tangency points, and then the tangent lines at these points:

restart;
f:=x-> (x^3+9*x^2-9*x-1)/(x^4+1):
solve(D(f)(x)=0.5);
L:=select(type,[%], realcons); # the tangency points
Lines:=map(p->f(p)+0.5*(x-p), L); # the tangency lines

plot([f(x),Lines[]], x=-6..6,-4..10, color=[red,blue,green,brown,cyan], scaling=constrained, legend=[f(x),Lines[]]); 

0.4396034712, 1.545359967, 1.135924545 + 3.219224078 I, 0.07028667536 + 0.8729569266 I, -0.8928416048, -3.504544275,  0.07028667536 - 0.8729569266 I, 1.135924545 - 3.219224078 I
 L := [0.4396034712, 1.545359967, -0.8928416048, -3.504544275]
     Lines := [-3.239253622 + 0.5 x, 0.7602488505 + 0.5 x, 8.699886068 + 0.5 x, 2.397905593 + 0.5 x]

          

You can use the Student:-Calculus1:-Roots command for this:

restart;
f(x) := 2.0*cos(1.5*x + 4.0) + 2.2:
g(x) := 2.0*cos(1.6*x + 3.85) + 2.0:
Student:-Calculus1:-Roots(f(x)=g(x), x=-1..4);             

                                                    [-0.7967442905, 3.834531623]

In Maple we can use the integral test (see wiki  https://en.wikipedia.org/wiki/Convergence_tests ):

int(1/k^(2-cos(1/k)), k=1..infinity);

                                          

 

In the list of your equations, you missed  eqn8 . Additionally, you can use the  fsolve  command rather than the  solve  one :

restart;
eqn1 := W__1 + W__2 + W__3 + W__4 = 4;            
eqn2 := W__1*zeta__1 + W__2*zeta__2 + W__3*zeta__3 + W__4*zeta__4 = 0;
eqn3 := W__1*zeta__1^2 + W__2*zeta__2^2 + W__3*zeta__3^2 + W__4*zeta__4^2 = 2/3;
eqn4 := W__1*zeta__1^3 + W__2*zeta__2^3 + W__3*zeta__3^3 + W__4*zeta__4^3 = 0;
eqn5 := W__1*zeta__1^4 + W__2*zeta__2^4 + W__3*zeta__3^4 + W__4*zeta__4^4 = 2/5;
eqn6 := W__1*zeta__1^5 + W__2*zeta__2^5 + W__3*zeta__3^5 + W__4*zeta__4^5 = 0;
eqn7 := W__1*zeta__1^6 + W__2*zeta__2^6 + W__3*zeta__3^6 + W__4*zeta__4^6 = 2/7;
eqn8 := W__1*zeta__1^7 + W__2*zeta__2^7 + W__3*zeta__3^7 + W__4*zeta__4^7 = 0;

fsolve({eqn1, eqn2, eqn3, eqn4, eqn5, eqn6, eqn7, eqn8}, {W__1, W__2, W__3, W__4, zeta__1, zeta__2, zeta__3, zeta__4});

  {W__1 = 1.620164810, W__2 = 0.3798351902, W__3 = 1.620164810, W__4 = 0.3798351902, zeta__1 = -0.1911644819, zeta__2 = 0.8495280449, zeta__3 = 0.1911644819, zeta__4 = -0.8495280449}


Edit.  You can also get exact symbolic solutions by using the  explicit option. But there will be 24 such solutions:

Sys:={eqn1, eqn2, eqn3, eqn4, eqn5, eqn6, eqn7, eqn8}:
solve(Sys, explicit);
evalf([%]);
nops(%);

 

Always use the add command when summing a finite number of specific terms. The  sum  command is usually used to sum an infinite number of terms or a finite, but not predetermined (a symbolic summation).

restart;
U[0] := x^2;
for k from 0 to 1 do U[k+1] := add(U[s]*(diff(U[k-s], x)), s = 0 .. k) end do;

# U[0]*(diff(U[0], x));
                            
# U[1];

                           

Addition. Below are 2 simple examples where the sum  command is needed:

restart;
sum(1/k^4, k=1..infinity);
sum(k^4, k=1..n);
simplify(%);

 

It seems the method _d01ajc is only suitable for real-valued functions. Remove this option and the error disappears. In your example, some logarithms will be from negative numbers. Below is a simple example with a similar error:

evalf(Int(ln(x-2), x=0..1, method=_d01ajc));
evalf(Int(ln(x-2), x=0..1));

Error, (in evalf/int) unable to obtain a real result
                  0.3862943611 + 3.141592654 I
 

We have to give names for each root. Replace the last line of your code with the following line:

assign(seq(z[i] = sol1[i], i = 1 .. 4));

 

First 28 29 30 31 32 33 34 Last Page 30 of 290