Kitonum

21435 Reputation

26 Badges

17 years, 24 days

MaplePrimes Activity


These are answers submitted by Kitonum

From the help:
"Important: The evalb command does not simplify expressions. It may return false for a relation that is true. In such a case, apply a simplification to the relation before using evalb."

Your example:

restart;
f := x + 1 = (x^2 - 1)/(x - 1):
evalb(simplify(f));

                                     true


See help for details.
 

This is not a surface but a curve as the intersection of two surfaces (the cylinder  (y-1)^2+z^2=1  and the plane  x=1 ):


 

restart;
plots:-intersectplot((y-1)^2+z^2=1, x=1, x=0..2, y=0..2, z=0..1, thickness=2, axes=normal, scaling=constrained);

 

 


 

Download plot.mw

I don't see any point in solving such a simple problem with Maple. We get the answer immediately only by looking at the drawing without any calculations. SK=KB, KO=1/3*KB so  cos(SKB) = 1/3 .

              

 

The code for the pic.

restart;
local O;
with(plottools): with(plots):
A:=[0,0,0]: B:=[1/2,sqrt(3)/2,0]: C:=[1,0,0]: S:=[1/2,sqrt(3)/6,sqrt(2/3)]: K:=[1/2,0,0]: O:=[1/2,sqrt(3)/6,0]:
AB:=line(A,B): BC:=line(C,B): AC:=line(A,C): AS:=line(A,S): BS:=line(B,S): CS:=line(C,S): KS:=line(K,S): SO:=line(S,O): KB:=line(K,B):
T:=textplot3d([[A[],"A"], [B[],"B"], [C[],"C"], [S[],"S"], [K[],"K"], [O[],"O"]], font=[times,bold,18], align={left,above}):  
display(AB,BC,AC,AS,BS,CS,KS,SO,KB,T, color=black, axes=none, orientation=[-50,75], scaling=constrained);

 

restart;
M:=2*p*q*r*s*t/(u*v*w); 
simplify(M, {p*q/(u*v)=K});

 

We can of course use  map , but the code will be a little more cumbersome:

A:=[1,2,3]:
B:=[7,8,9]:
map(f@op, [seq([A[i],B[i]],i=1..nops(A))]);

                        [f(1, 7), f(2, 8), f(3, 9)]

restart;
sum((-1)^n/n*x^n, n=1..infinity) assuming x>-1, x<=1;

                                         -ln(1+x)


Edit. You can use the  parametric  option as well:

restart;
sum((-1)^n/n*x^n, n=1..infinity, parametric);

                 

 

We can use splines for smoothing. You didn’t provide a list of 11 points for your curve, so I restored it by eye.


 

restart;
L:=[[0,0],[0.1,-0.0005],[0.2,-0.0025],[0.3,-0.007],[0.4,-0.013],[0.5,-0.02],[0.6,-0.03],[0.7,-0.04],[0.8,-0.043],[0.9,-0.032],[1,0]]:
P:=plot(L, color=red, axes=box);
CurveFitting:-Spline(L, x);
FineCurve:=plot(%, x=0..1, color=blue);
plots:-display(P, FineCurve);

 

piecewise(x < .1, -0.250185043220809e-2*x-.249814956779191*x^3, x < .2, 0.499629913558381e-3-0.999629913558381e-2*x-0.749444870337572e-1*(x-.1)^2-.250925216104047*(x-.1)^3, x < .3, 0.400259060509133e-2-0.325129530254567e-1*x-.150222051864971*(x-.2)^2+.253515821195379*(x-.2)^3, x < .4, 0.948556662877686e-2-0.549518887625895e-1*x-0.741673055063576e-1*(x-.3)^2+.236861931322531*(x-.3)^3, x < .5, 0.120717967696741e-1-0.626794919241851e-1*x-0.310872610959834e-2*(x-.4)^2-.700963546485501*(x-.4)^3, x < .6, 0.221650717703349e-1-0.843301435406698e-1*x-.213397790055249*(x-.5)^2+.566992254619472*(x-.5)^3, x < .7, 0.359999603478812e-1-.109999933913135*x-0.433001136694071e-1*(x-.6)^2+1.43299452800761*(x-.6)^3, x < .8, 0.129690845647519e-1-0.756701208067884e-1*x+.386598244732877*(x-.7)^2+.701029633350074*(x-.7)^3, x < .9, -0.611443337122314e-1+0.226804171402892e-1*x+.596907134737899*(x-.8)^2+2.76288693859209*(x-.8)^3, -.234453607021068+.224948452245632*x+1.42577321631553*(x-.9)^2-4.75257738771842*(x-.9)^3)

 

 

 

 


 

Download FineCurve.mw

For some reason  assuming  does not always work. Use  assume=even  instead:

restart;
expr := Sum((-1)^n - 1, n = 1 .. infinity):
simplify(op(1,expr), assume=even);

                                        0

 

Edit. Probably something related to the levels of calculations here. For example, the following option works:

restart;
expr := Sum((-1)^n - 1, n = 1 .. infinity):
op(1,expr);
simplify(%) assuming n::even;

 

What you want to do is easy using the commands  plottools:-rectangle , plots:-inequal  and  plots:-textplot :


 

restart;
with(plots): with(plottools):
P1:=rectangle([-1.5,1.5],[2.5,-1.5], style=line):
A:=x^2+y^2<=1: notA:=x^2+y^2>1:
B:=(x-1)^2+y^2<=1: notB:=(x-1)^2+y^2>=1:
AminusB:={A,notB}:
AorB:={{A},{B}}:
AandB:={A,B}:
AB:=textplot([[-0.5,1.2,"A"],[1.5,1.2,"B"]], font=[times,bold,16]):

display(P1, inequal(AorB, x=-1.5..3,y=-2..1.5, color="LightBlue"), AB, scaling=constrained, axes=none, title='A' union 'B', titlefont=[times,bold,16]);

 

display(P1, inequal(AandB, x=-1.5..3,y=-2..1.5, color="LightBlue"), AB, scaling=constrained, axes=none, title='A' intersect 'B', titlefont=[times,bold,16]);

 

display(P1, inequal(AminusB, x=-1.5..3,y=-2..1.5, color="LightBlue"), AB, scaling=constrained, axes=none, title='A' minus 'B', titlefont=[times,bold,16]);

 

 


 

Download Venn.mw

Use  style=line  option for the surfaces:

plots:-display(plot3d(2*(1-x^2-y^2), x=-2..2, y=-3..3, style=line, view=0..2, grid=[20,30]), plot3d(0, x=-2..2, y=-3..3, style=line, grid=[20,30]), plots:-spacecurve([cos(t),sin(t)+1/2,0],t=0..2*Pi, color=black, thickness=2), scaling=constrained, axes=none);

                     

Use additional graphic options that can significantly improve the quality of plotting. The plot size can be changed with  size  option, and the style (including size) of the legends is controlled by  legendstyle  option. As an example, look at the plotting 4 basic trigonometric functions on one plot by default and using additional options:


 

restart;
# By default
plot([sin(x),cos(x),tan(x),cot(x)], x=-2*Pi..2*Pi, y=-4..4, legend=[sin(x),cos(x),tan(x),cot(x)], scaling=constrained);

 

# With additional options
plot([sin(x),cos(x),tan(x),cot(x),seq([-2*Pi+Pi/2*k,t,t=-4..4],k=0..8)], x=-2*Pi..2*Pi, y=-4..4, legend=[sin(x),cos(x),tan(x),cot(x),"vertical asymptotes"$9], linestyle=[1$4,3$9], legendstyle=[font=[times,18]], color=[red,blue,green,gold, black$9], thickness=[2$4,0$9], discont, scaling=constrained, size=[900,600]);

 

 


Additionally, I replaced the vertical lines that Maple draws by default at break points with vertical dashed black lines and indicated them in the legends. The colors of the graphs have also been changed.

Download options.mw

I did not find a command in Maple for expanding a function into a Fourier series. But here's a simple procedure that does it for a function on the segment  -Pi .. Pi . I leave it to you as a simple exercise to modify it for a function given on an arbitrary segment.
 

restart;
Fourier:=proc(f::algebraic,N::nonnegint)
local a,b,k;
a:=k->`if`(k=0,1/(2*Pi)*int(f,x=-Pi..Pi),(1/Pi)*int(f*cos(k*x),x=-Pi..Pi));
assume(n,nonnegint);
print('a'[0]=a(0), 'a'[n]=a(n));
b:=k->(1/Pi)*int(f*sin(k*x),x=-Pi..Pi);
print('b'[n]=b(n));

a(0)+add(a(k)*cos(k*x)+b(k)*sin(k*x),k=1..N);

end proc:

# Example of use

Fourier(abs(x), 5);
plot([abs(x),%], x=-Pi..Pi, color=[blue,red], size=[800,400], scaling=constrained);

a[0] = (1/2)*Pi, a[n] = 2*((-1)^n-1)/(Pi*n^2)

 

b[n] = 0

 

(1/2)*Pi-4*cos(x)/Pi-(4/9)*cos(3*x)/Pi-(4/25)*cos(5*x)/Pi

 

 

 


Edit.

Download Fourier_series1.mw

Here's another easy way. Thу  ZigZag  procedure arranges the matrix indices in zigzag order. The matrix can be arbitrary (not necessarily square).

restart;

ZigZag:=proc(M,N)
local L, P;
uses ListTools;
L:=[seq(seq([i,j],i=1..M),j=1..N)];
P:=[ListTools:-Categorize((x,y)->x[1]+x[2]=y[1]+y[2], L)];
[seq(`if`(k::odd,op(P[k]),op(Reverse(P[k]))),k=1..M+N-1)];
end proc:


Examples of use

ZigZag(3,3);

[[1, 1], [1, 2], [2, 1], [3, 1], [2, 2], [1, 3], [2, 3], [3, 2], [3, 3]]

(1)

Matrix(4,6,{seq((op(ZigZag(4,6)[k]))=k,k=1..4*6)});

Matrix(4, 6, {(1, 1) = 1, (1, 2) = 2, (1, 3) = 6, (1, 4) = 7, (1, 5) = 14, (1, 6) = 15, (2, 1) = 3, (2, 2) = 5, (2, 3) = 8, (2, 4) = 13, (2, 5) = 16, (2, 6) = 21, (3, 1) = 4, (3, 2) = 9, (3, 3) = 12, (3, 4) = 17, (3, 5) = 20, (3, 6) = 22, (4, 1) = 10, (4, 2) = 11, (4, 3) = 18, (4, 4) = 19, (4, 5) = 23, (4, 6) = 24})

(2)

 


 

Download ZigZag.mw

See the  Large Operators  palette :

                               

 

In Maple we can use the  extrema  command for symbolic calculation of the  maximum  or the  minimum . The  extrema  command employs the method of Lagrange multipliers. Of course, this method is not universal and can fail if the extremum is reached at the points where differentiability is violated.

 

restart:
f:=(x-2*y)/(5*x^2-2*x*y+2*y^2):
V:=extrema(f, {2*x^2 - y^2 + x*y=1}, {x,y}, s);
s;
s1:=convert(s,list);
simplify(eval~(f, s1)); # Check

{-(1/4)*2^(1/2), (1/4)*2^(1/2)}

 

{{x = -(1/3)*6^(1/2), y = -(1/6)*6^(1/2)-(1/2)*2^(1/2)}, {x = -(1/3)*6^(1/2), y = -(1/6)*6^(1/2)+(1/2)*2^(1/2)}, {x = (1/3)*6^(1/2), y = (1/6)*6^(1/2)-(1/2)*2^(1/2)}, {x = (1/3)*6^(1/2), y = (1/6)*6^(1/2)+(1/2)*2^(1/2)}}

 

[{x = -(1/3)*6^(1/2), y = -(1/6)*6^(1/2)-(1/2)*2^(1/2)}, {x = -(1/3)*6^(1/2), y = -(1/6)*6^(1/2)+(1/2)*2^(1/2)}, {x = (1/3)*6^(1/2), y = (1/6)*6^(1/2)-(1/2)*2^(1/2)}, {x = (1/3)*6^(1/2), y = (1/6)*6^(1/2)+(1/2)*2^(1/2)}]

 

[(1/4)*2^(1/2), -(1/4)*2^(1/2), (1/4)*2^(1/2), -(1/4)*2^(1/2)]

(1)

 


We see that the maximum  sqrt(2)/4  is reached at two points. At the same time, we also learned everything about the minimum.

 

Download extrema.mw

First 53 54 55 56 57 58 59 Last Page 55 of 289