Kitonum

21530 Reputation

26 Badges

17 years, 82 days

MaplePrimes Activity


These are answers submitted by Kitonum


 

restart

NULL

"f(x):=18*log10(x);"

proc (x) options operator, arrow, function_assign; 18*log10(x) end proc

(1)

"g(x):=1/(2) x^(3)-8*x^(2)+(69/(2))^()*x-27;"

proc (x) options operator, arrow, function_assign; (1/2)*x^3-8*x^2+(69/2)*x-27 end proc

(2)

plot([f(x), g(x)], x = -1 .. 11, -30 .. 25, size = [800, 500])

 

NULL

sort([RootFinding:-Analytic(f(x)-g(x), re = 0 .. 12, im = -1 .. 1)])

[0.372146548487319e-1, 1.00000000000000, 4.50616492819266, 10.0000000000000]

(3)

``


 

Download intersect_curve_new.mw

restart;
f:=unapply(int(diff(Y1(x), x), x)+C1, x);
solve({Y1(0) = f(0)}, {C1});

                                    f := x -> Y1(x) + C1
                                           {C1 = 0}

For drawing arrows see help on  plots:-arrow

restart;
with(plots): with(plottools):
S:=seq(seq(disk([x,y], 0.05, color=blue), x=-1..6), y=-1..3):
T:=textplot([[0,0,"(0,0)",align=[left,below]],[1,1,"(1,1)",align=[right,above]],[2,1,"(2,1)",align=[right,above]]], font=[times,18]):
display(S,T, scaling=constrained, size=[800,500],axes=none);

                           

Two-argument  arctan(y,x)  returns the polar angle  phi  of a point  A(x,y) in the range  -Pi < phi <= Pi

Examples:

restart;
arctan(1,sqrt(3)), arctan(-1,sqrt(3)), arctan(-1,-sqrt(3)), arctan(0,-1);  

                                 


See help on  ?arctan  for details  .

Example:

combs := combinat:-choose({a, b, c, d, e}, 3);

     combs := {{a, b, c}, {a, b, d}, {a, b, e}, {a, c, d}, {a, c, e}, {a, d, e}, {b, c, d}, {b, c, e}, {b, d, e}, {c, d, e}}

What functions are you talking about? Inside contourplot command, you simply calculate the sum of the values of one function  BesselJ  in a finite number of points, and skip one  sum command, since you have a double sum:

restart;
sum(sum(BesselJ(n,r),n=0..5),r=-10..10);

                 1+2*BesselJ(0, 10)+2*BesselJ(2, 10)+2*BesselJ(4, 10)+2*BesselJ(0, 9)+2*BesselJ(2, 9)+2*BesselJ(4, 9)+2*BesselJ(0, 8)+2*BesselJ(2, 8)+2*BesselJ(4, 8)+2*BesselJ(0, 7)+2*BesselJ(2, 7)+2*BesselJ(4, 7)+2*BesselJ(0, 6)+2*BesselJ(2, 6)+2*BesselJ(4, 6)+2*BesselJ(0, 5)+2*BesselJ(2, 5)+2*BesselJ(4, 5)+2*BesselJ(0, 4)+2*BesselJ(2, 4)+2*BesselJ(4, 4)+2*BesselJ(0, 3)+2*BesselJ(2, 3)+2*BesselJ(4, 3)+2*BesselJ(0, 2)+2*BesselJ(2, 2)+2*BesselJ(4, 2)+2*BesselJ(0, 1)+2*BesselJ(2, 1)+2*BesselJ(4, 1)


Of course, you can plot  a  contourplot for the function of two variables  BesselJ(n,r)  in appropriate ranges for n and r without any problem:

plots:-contourplot(BesselJ(n,r), n=0..5, r=-10..10, grid=[200,200]);

                  

 

Maple finds both real and complex solutions. The  select  command helps to select real roots:
 

restart;

F := -1 - y - exp(x);
G := x^2 + y*(exp(x) - 1);
sol1 := solve({F, G}, {x, y});
sol2:=allvalues(sol1);
``;
select(p->type(eval(x,p),realcons) and type(eval(y,p),realcons),[sol2])[];

-1-y-exp(x)

 

x^2+y*(exp(x)-1)

 

{x = RootOf(-(exp(_Z))^2+_Z^2+1), y = -1-exp(RootOf(-(exp(_Z))^2+_Z^2+1))}

 

{x = 0, y = -2}, {x = RootOf(-(exp(_Z))^2+_Z^2+1, 0.8091750422e-1+1.468988335*I), y = -1-exp(RootOf(-(exp(_Z))^2+_Z^2+1, 0.8091750422e-1+1.468988335*I))}, {x = RootOf(-(exp(_Z))^2+_Z^2+1, 0.8091750422e-1-1.468988335*I), y = -1-exp(RootOf(-(exp(_Z))^2+_Z^2+1, 0.8091750422e-1-1.468988335*I))}

 

``

 

{x = 0, y = -2}

(1)

 


Edit. Of course, you can immediately get the solution (as float number) you want using  fsolve  command:

sol := fsolve({F, G}, {x, y});

                                       sol := {x = 0., y = -2.000000000}

 

Download solve.mw

@Zeineb  What you want to calculate is called a (matrix) norm. Carl showed one way (the  infinity-norm). But there are other formulas for calculating a norm, and Maple has a suitable command. See help on  ?LinearAlgebra:-Norm .

 

Obviously, the function  g  depends not only on x, but also on p , so  g(x,p)=max{h(x,p),f(x,p) . It is useful to use graphic illustration to obtain this dependence. First, we plot a red line  x-p=x^2+p*x . It is easy to check that above this line (pink area) we have  g(x,p)=x^2+p*x, and below (blue area)  g(x,p)=x-p


 

restart;
eq:=x-p=x^2+p*x;
f:=unapply(solve(eq, p), x);
P1:=plot(f, 0..10, p=-1..1, color=red, thickness=3):
P2:=plots:-inequal(p>f(x),x=0..10,p=-1..1,color="LightPink",optionsexcluded = [color = "LightBlue"],nolines):
T:=plots:-textplot([[5,0.3,g(x,p)=x^2+p*x],[1,-0.7,g(x,p)=x-p]], font=[times,bold,16]):
plots:-display(P1,P2,T, size=[800,400]);

g:=unapply(piecewise(p>=f(x),x^2+p*x,x-p), x,p);
Sol:=unapply(int(g(x,p), x=0..10), p);

# Examples of use
Sol(2), Sol(1), Sol(0), Sol(-2);

eq := x-p = p*x+x^2

 

f := proc (x) options operator, arrow; -x*(x-1)/(x+1) end proc

 

 

g := proc (x, p) options operator, arrow; piecewise(-x*(x-1)/(x+1) <= p, p*x+x^2, x-p) end proc

 

proc (p) options operator, arrow; 50*p-60*p*piecewise(-p < 90/11, 0, 1)+1000/3-(850/3)*piecewise(-p < 90/11, 0, 1)+piecewise(And(p <= 3-2*2^(1/2), 0 < p), (1/8)*piecewise(-signum((p^2-6*p+1)^(1/2)/(p-3+(p^2-6*p+1)^(1/2))) = 1, 1, 0)*p^2*(p^2-6*p+1)^(1/2)-(3/4)*piecewise(-signum((p^2-6*p+1)^(1/2)/(p-3+(p^2-6*p+1)^(1/2))) = 1, 1, 0)*p*(p^2-6*p+1)^(1/2)-(1/12)*piecewise(-signum((p^2-6*p+1)^(1/2)/(p-3+(p^2-6*p+1)^(1/2))) = 1, 1, 0)+(1/12)*piecewise(-signum((p^2-6*p+1)^(1/2)/(p-3+(p^2-6*p+1)^(1/2))) = 1, 1, 0)*p^3-(3/4)*piecewise(-signum((p^2-6*p+1)^(1/2)/(p-3+(p^2-6*p+1)^(1/2))) = 1, 1, 0)*p^2+(1/8)*piecewise(-signum((p^2-6*p+1)^(1/2)/(p-3+(p^2-6*p+1)^(1/2))) = 1, 1, 0)*(p^2-6*p+1)^(1/2)-(1/24)*piecewise(-signum((p^2-6*p+1)^(1/2)/(p-3+(p^2-6*p+1)^(1/2))) = 1, 1, 0)*(p^2-6*p+1)^(3/2)+(3/4)*piecewise(-signum((p^2-6*p+1)^(1/2)/(p-3+(p^2-6*p+1)^(1/2))) = 1, 1, 0)*p+(1/12)*piecewise(signum((p^2-6*p+1)^(1/2)/(p-3+(p^2-6*p+1)^(1/2))) = 1, 1, 0)+(3/4)*piecewise(signum((p^2-6*p+1)^(1/2)/(p-3+(p^2-6*p+1)^(1/2))) = 1, 1, 0)*p*(p^2-6*p+1)^(1/2)-(1/8)*piecewise(signum((p^2-6*p+1)^(1/2)/(p-3+(p^2-6*p+1)^(1/2))) = 1, 1, 0)*p^2*(p^2-6*p+1)^(1/2)+(3/4)*piecewise(signum((p^2-6*p+1)^(1/2)/(p-3+(p^2-6*p+1)^(1/2))) = 1, 1, 0)*p^2-(3/4)*piecewise(signum((p^2-6*p+1)^(1/2)/(p-3+(p^2-6*p+1)^(1/2))) = 1, 1, 0)*p-(1/8)*piecewise(signum((p^2-6*p+1)^(1/2)/(p-3+(p^2-6*p+1)^(1/2))) = 1, 1, 0)*(p^2-6*p+1)^(1/2)-(1/12)*piecewise(signum((p^2-6*p+1)^(1/2)/(p-3+(p^2-6*p+1)^(1/2))) = 1, 1, 0)*p^3+(1/24)*piecewise(signum((p^2-6*p+1)^(1/2)/(p-3+(p^2-6*p+1)^(1/2))) = 1, 1, 0)*(p^2-6*p+1)^(3/2), 0)+piecewise(And(p <= 3-2*2^(1/2), -90/11 < p), (1/12)*piecewise(-signum((p^2-6*p+1)^(1/2)/(-p+(p^2-6*p+1)^(1/2)+3)) = 1, 1, 0)*p^3-(3/4)*piecewise(-signum((p^2-6*p+1)^(1/2)/(-p+(p^2-6*p+1)^(1/2)+3)) = 1, 1, 0)*p^2-(1/8)*piecewise(-signum((p^2-6*p+1)^(1/2)/(-p+(p^2-6*p+1)^(1/2)+3)) = 1, 1, 0)*(p^2-6*p+1)^(1/2)+(1/24)*piecewise(-signum((p^2-6*p+1)^(1/2)/(-p+(p^2-6*p+1)^(1/2)+3)) = 1, 1, 0)*(p^2-6*p+1)^(3/2)+(3/4)*piecewise(-signum((p^2-6*p+1)^(1/2)/(-p+(p^2-6*p+1)^(1/2)+3)) = 1, 1, 0)*p-(1/8)*piecewise(-signum((p^2-6*p+1)^(1/2)/(-p+(p^2-6*p+1)^(1/2)+3)) = 1, 1, 0)*p^2*(p^2-6*p+1)^(1/2)+(3/4)*piecewise(-signum((p^2-6*p+1)^(1/2)/(-p+(p^2-6*p+1)^(1/2)+3)) = 1, 1, 0)*p*(p^2-6*p+1)^(1/2)+(1/8)*piecewise(signum((p^2-6*p+1)^(1/2)/(-p+(p^2-6*p+1)^(1/2)+3)) = 1, 1, 0)*p^2*(p^2-6*p+1)^(1/2)-(3/4)*piecewise(signum((p^2-6*p+1)^(1/2)/(-p+(p^2-6*p+1)^(1/2)+3)) = 1, 1, 0)*p*(p^2-6*p+1)^(1/2)-(1/12)*piecewise(signum((p^2-6*p+1)^(1/2)/(-p+(p^2-6*p+1)^(1/2)+3)) = 1, 1, 0)*p^3+(3/4)*piecewise(signum((p^2-6*p+1)^(1/2)/(-p+(p^2-6*p+1)^(1/2)+3)) = 1, 1, 0)*p^2+(1/8)*piecewise(signum((p^2-6*p+1)^(1/2)/(-p+(p^2-6*p+1)^(1/2)+3)) = 1, 1, 0)*(p^2-6*p+1)^(1/2)-(1/24)*piecewise(signum((p^2-6*p+1)^(1/2)/(-p+(p^2-6*p+1)^(1/2)+3)) = 1, 1, 0)*(p^2-6*p+1)^(3/2)-(3/4)*piecewise(signum((p^2-6*p+1)^(1/2)/(-p+(p^2-6*p+1)^(1/2)+3)) = 1, 1, 0)*p-(1/12)*piecewise(-signum((p^2-6*p+1)^(1/2)/(-p+(p^2-6*p+1)^(1/2)+3)) = 1, 1, 0)+(1/12)*piecewise(signum((p^2-6*p+1)^(1/2)/(-p+(p^2-6*p+1)^(1/2)+3)) = 1, 1, 0), 0) end proc

 

1300/3, 1150/3, 667/2, 2863/12+(17/12)*17^(1/2)

(1)

 


 

Download int.mw


Here's another solution that is slightly more cumbersome but gives more compact results:


 

restart;
eq:=x-p=x^2+p*x;
f:=unapply(solve(eq, p), x);
plot(f, 0..10, p=-1..1);
maximize(f(x), x=0..10, location);
M:=expand~([%])[];
p1:=f(0); p2:=M[1];
x1,x2:=solve(eq, x);
g:=unapply(piecewise(p>=p2,x^2+p*x,p<p2 and p>p1,piecewise(x>x2 and x<x1,x-p,x^2+p*x),p<=p1,piecewise(x<=x1,x-p,x^2+p*x)), x,p);
Sol:=unapply(simplify(int(g(x,p), x=0..10)), p);

# Examples of use
Sol(2), Sol(1), Sol(0), Sol(-2);
 

eq := x-p = p*x+x^2

 

f := proc (x) options operator, arrow; -x*(x-1)/(x+1) end proc

 

 

-(1/2)*(sqrt(2)-1)*(sqrt(2)-2)*sqrt(2), {[{x = sqrt(2)-1}, -(1/2)*(sqrt(2)-1)*(sqrt(2)-2)*sqrt(2)]}

 

M := -2*sqrt(2)+3, {[{x = sqrt(2)-1}, -2*sqrt(2)+3]}

 

p1 := 0

 

p2 := -2*sqrt(2)+3

 

x1, x2 := -(1/2)*p+1/2+(1/2)*sqrt(p^2-6*p+1), -(1/2)*p+1/2-(1/2)*sqrt(p^2-6*p+1)

 

g := proc (x, p) options operator, arrow; piecewise(-2*sqrt(2)+3 <= p, p*x+x^2, 0 < p and p < -2*sqrt(2)+3, piecewise(-(1/2)*p+1/2-(1/2)*sqrt(p^2-6*p+1) < x and x < -(1/2)*p+1/2+(1/2)*sqrt(p^2-6*p+1), x-p, p*x+x^2), p <= 0, piecewise(x <= -(1/2)*p+1/2+(1/2)*sqrt(p^2-6*p+1), x-p, p*x+x^2)) end proc

 

proc (p) options operator, arrow; piecewise(p < -90/11, 50-10*p, p <= 0, (1/12)*(p^2-6*p+1)^(3/2)-(1/12)*p^3+(3/4)*p^2+(197/4)*p+4001/12, p < -2*2^(1/2)+3, (1/6)*(p^2-6*p+1)^(3/2)+50*p+1000/3, -2*2^(1/2)+3 <= p, 50*p+1000/3) end proc

 

1300/3, 1150/3, 667/2, (17/12)*17^(1/2)+2863/12

(1)

 


 

Download int1.mw

Edit.


 

restart;
P:=proc()
uses combinat;
Matrix(2,3,randperm([$1..6]));
end proc:

# Examples
seq(P(), i=1..10);

Matrix(2, 3, {(1, 1) = 4, (1, 2) = 6, (1, 3) = 2, (2, 1) = 3, (2, 2) = 1, (2, 3) = 5}), Matrix(2, 3, {(1, 1) = 5, (1, 2) = 1, (1, 3) = 2, (2, 1) = 4, (2, 2) = 6, (2, 3) = 3}), Matrix(2, 3, {(1, 1) = 3, (1, 2) = 5, (1, 3) = 2, (2, 1) = 6, (2, 2) = 1, (2, 3) = 4}), Matrix(2, 3, {(1, 1) = 6, (1, 2) = 1, (1, 3) = 5, (2, 1) = 4, (2, 2) = 2, (2, 3) = 3}), Matrix(2, 3, {(1, 1) = 5, (1, 2) = 3, (1, 3) = 2, (2, 1) = 4, (2, 2) = 6, (2, 3) = 1}), Matrix(2, 3, {(1, 1) = 5, (1, 2) = 2, (1, 3) = 1, (2, 1) = 4, (2, 2) = 6, (2, 3) = 3}), Matrix(2, 3, {(1, 1) = 6, (1, 2) = 4, (1, 3) = 3, (2, 1) = 5, (2, 2) = 1, (2, 3) = 2}), Matrix(2, 3, {(1, 1) = 5, (1, 2) = 6, (1, 3) = 3, (2, 1) = 2, (2, 2) = 1, (2, 3) = 4}), Matrix(2, 3, {(1, 1) = 1, (1, 2) = 2, (1, 3) = 4, (2, 1) = 3, (2, 2) = 6, (2, 3) = 5}), Matrix(2, 3, {(1, 1) = 2, (1, 2) = 1, (1, 3) = 5, (2, 1) = 3, (2, 2) = 6, (2, 3) = 4})

(1)

 


 

Download RM.mw

algsubs is not a generalization of  subs, at least because  subs  allows multiple substitutions to be made at once, which  algsubs  does not:

restart:
subs([a=c,b=d],a=b);
algsubs([a=c,b=d],a=b);

                                                          c = d
     Error, invalid input: algsubs expects its 1st argument, p, to be of type algebraic = algebraic, but received [a = c, b = d]

We can easily get both solutions if we make the change  y(x)=Y(x)^2 . Then our original equation splits into two equations, the first equation gives the obvious zero solution, and the second equation gives  Y(x)=x , that is  y(x)=x^2 :


 

restart:
ode := diff(y(x),x)=2*sqrt(y(x));
Change:=y(x)=Y(x)^2;
eval(ode,Change);
simplify(%) assuming Y(x)>=0;
Ode:=factor((lhs-rhs)(%))/2;
ic:=Y(0)=0;
``;
sol1:=eval(Change,Y(x)=0);
sol2:=eval(Change,dsolve([op(2,Ode),ic],Y(x)));

diff(y(x), x) = 2*y(x)^(1/2)

 

y(x) = Y(x)^2

 

2*Y(x)*(diff(Y(x), x)) = 2*(Y(x)^2)^(1/2)

 

2*Y(x)*(diff(Y(x), x)) = 2*Y(x)

 

Y(x)*(diff(Y(x), x)-1)

 

Y(0) = 0

 

``

 

y(x) = 0

 

y(x) = x^2

(1)

 


 

Download difeq1.mw

Edit.


 

restart;

assume(0 < a, 0 < L, a < L);

M := piecewise(0 <= x and x < a, P*x*(L-a)/L, a <= x and x < L, P*a*(L-x)/L);
ode := diff(y(x), `$`(x, 2)) = M/(E*I__0);
ic := y(0) = 0, y(L) = 0;
sol := factor(dsolve([ode, ic], y(x))); assign(sol); y1 := y(x);

M := piecewise(0 <= x and x < a, P*x*(L-a)/L, a <= x and x < L, P*a*(L-x)/L)

 

ode := diff(y(x), x, x) = piecewise(0 <= x and x < a, P*x*(L-a)/L, a <= x and x < L, P*a*(L-x)/L)/(E*I__0)

 

ic := y(0) = 0, y(L) = 0

 

sol := y(x) = piecewise(x < 0, -P*a*(2*L-a)*(L-a)*x/(6*L*E*I__0), x < a, -P*x*(L-a)*(2*L*a-a^2-x^2)/(6*L*E*I__0), x < L, -P*a*(L-x)*(2*L*x-a^2-x^2)/(6*L*E*I__0), L <= x, -P*a*(L-a)*(L+a)*(L-x)/(6*L*E*I__0))

 

piecewise(x < 0, -(1/6)*P*a*(2*L-a)*(L-a)*x/(L*E*I__0), x < a, -(1/6)*P*x*(L-a)*(2*L*a-a^2-x^2)/(L*E*I__0), x < L, -(1/6)*P*a*(L-x)*(2*L*x-a^2-x^2)/(L*E*I__0), L <= x, -(1/6)*P*a*(L-a)*(L+a)*(L-x)/(L*E*I__0))

(1)

Y:=eval(y1, [a=1,L=2,E=3,I__0=4,P=5]);
plot(Y, x=0..3);
minimize(Y, x=0..3);
maximize(Y, x=0..3);

Y := piecewise(x < 0, -5*x*(1/48), x < 1, -5*x*(-x^2+3)*(1/144), x < 2, -(1/144)*(5*(2-x))*(-x^2+4*x-1), 2 <= x, -5/24+5*x*(1/48))

 

 

-5/72

 

5/48

(2)

 


 

Download eval.mw

restart;
n:=2:
plots:-animate(plots:-display@plottools:-sphere,[r], r=0..n, frames=100, axes=normal);

                     

Edit.

Just normalize this vector.
An example:

restart;
V := RandomTools:-Generate(('Vector[row]')(integer(range = -3 .. 10, exclude = {0}), 4));
V/add(V);

Vector[row](4, {(1) = 9, (2) = 3, (3) = 6, (4) = 9})

 

Vector[row](%id = 18446745446184201382)

(1)

 


 

Download RV.mw

First 47 48 49 50 51 52 53 Last Page 49 of 290