13579 Reputation

24 Badges

11 years, 124 days

MaplePrimes Activity

These are answers submitted by Kitonum

This can be done in many ways. Here is a simple procedure with a for-loop that solves the problem:

P:=proc(A::Matrix, j::posint, a::numeric)
local i, m, n;
for i from 1 to m do
if A[i,j]>a then return i fi;
end proc:

A:=<1,2,1.1; 3,4,2.1; 5,6,3.1>;

To draw this circle centered at point  H  and radius  R , you do not need to know any angles. Simply write the appropriate parametric equations and use  plot3d  command:

 a := 3:
 b := 4:
 h := 5:
 point(A, 0, 0, 0):
 point(B, a, 0, 0):
 point(C, a, b, 0):
 point(DD, 0, b, 0):
 point(S, 0, 0, h):
 sphere(s, [A, B, C, S], [x,y,z], 'centername' = m); 
plane(p, [S, A, B], [x, y, z]); 
n:=coordinates(projection(H, m, p)); 
R := distance(H, S);
S1:=plot3d(n+r*~([cos(t),0,sin(t)]), r=0..R, t=0..2*Pi, style=surface,  color=pink):
S2:=plots:-spacecurve(n+[R*cos(t),0,R*sin(t)], t=0..2*Pi, color="VioletRed", thickness=2):
S3:=plottools:-sphere([3/2, 2, 5/2], 5*sqrt(2)*(1/2), color="LightGreen", transparency=0.7):
plots:-display(S1,S2,S3, axes=normal, orientation=[20,70], lightmodel=light1);



T := (f,k) -> 1/k!*diff(f,[x$k]);

Examples of use:

T(sin(3*x), 5);
T(sin(3*x), k);

In my opinion, Maple simplifies the expression quite well. But what is your main goal? If you want a simple way to calculate this expression for specific parameters values  a, b, c, d  and a specific  n , then here is a simple procedure for this:

simplify(rsolve({f(n+1)-((a-1)*(b-1)+(c+d))*f(n)-c*d*f(n-1)=0, f(0)=a,f(1)=a*(b - 1)+c},f));
end proc:	

Examples of use:

Sol(2,1,4,3,100); ``;
seq(Sol(2,1,4,3,k), k=1..20); ``;

f := x -> 3*x + 2:
g := D(f):


local pq, pr, v, cv, T;
uses LinearAlgebra, plots, plottools;
pq:=arrow(p,q-p, width=0.1, color=red);
pr:=arrow(p,r-p, width=0.1, color=red);
cv:=arrow(p,v, width=0.1, color=green);
T:=polygon([p,q,r], color=yellow);
display(pq,pr,cv,T, scaling=constrained, axes=normal, lightmodel=light1);
end proc:

Example of use:

P([3,3,2], [3,4,5], [4,3,4]);


If one solution is enough, then you can do so

local a, b, c, d;
for a from 1 to floor(sqrt(n/4)) do
for b from a to floor(sqrt((n-a^2)/3)) do
for c from b to floor(sqrt((n-a^2-b^2)/2)) do
for d from c to floor(sqrt(n-a^2-b^2-c^2)) do
if n=a^2+b^2+c^2+d^2 then return [a,b,c,d] fi;
od: od: od: od:
end proc:

Example of use:

 [4, 8, 8, 316]

It is not recommended to use some variable and indexed variable with the same name in the same code. Therefore, I replaced, for example, t[n]  by  t||n  and so on. Some other corrections and additions were also made. The resulting approximate solution is quite accurate.

t||0:=0: w||0:=0.5: h:=0.2: ex||0:=0.5: e||0:=0:

for n from 1 to 10 do
t||n:=n*h; ex||n:=eval(rhs(ex),t=t||n);

printf(" i | t[i] |(Taylor)w[i] |(exact)y[i] |Error | \n ");
for i from 0 to 10 do
printf("%2.2f| %5.2f  | %5.6f| %5.6f  |  %5.6f | \n", i, t||i, w||i ,ex||i,e||i) ;

A:=plot(rhs(ex), t=0..2, color=red):
B:=plot([seq([h*k,w||k], k=0..10)], style=point,color=blue):
plots:-display(A,B, legend=["Exact solution","Approximate solution"], view=0..6);

The final results as a table and a plot:


Unfortunately, it is not possible to obtain an explicit parameterization of the intersection curve, since finding x1,y1,z1 coordinates as functions of the parameter  theta  leads to the solution of an equation of a high degree. But we can get a numerical solution in the form of a procedure. This procedure  Curve  returns the coordinates of the point on the intersection curve for the specified values  theta, x, y, z :



R1 := 3: R2 := 1: DR := 4: g := R2 + DR:

f1 := h -> sqrt(R1^2 - h^2);
f2 := h -> sqrt(g^2 - h^2);
f3 := h -> (1 - h/g)*f1(h*R1/g) + h*f2(h)/g;
f4 := h -> sqrt(1/2*g - 1/2*h);
f5 := h -> (1 - h/g)*f3(h) + h*f4(h)/g;
gg := h -> piecewise(h < 0, f1(h), 0 <= h, f5(h)); # Radius depending on the z-position h
cir := (h, phi, R) -> <sin(phi)*R, cos(phi)*R, h>; # a circle at the hight h with radius R
#The plane is placed inside the drop.
n := (x, y, z) -> <x, y, z>/sqrt(x^2 + y^2 + z^2);

# the following lines show, how it looks like:
dro1 := plot3d(cir(h, phi, gg(h)), h = -R1 .. g, phi = 0 .. 2*Pi, scaling = constrained, orientation = [-60, 72, 0]);
plotDropWithPlane := (x, y, z) -> display(dro1, arrow(Vector([0, 0, 0]), 2*R1*n(x, y, z), 0.2, 0.4, 0.1, cylindrical_arrow, fringe = blue, color = "Green"), implicitplot3d(x*x1 + y*y1 + z*z1 = 0, x1 = -R1 .. R1, y1 = -R1 .. R1, z1 = -R1 .. g, color = blue));
Plot1:=plotDropWithPlane(3, 1, 2);

f1 := proc (h) options operator, arrow; sqrt(R1^2-h^2) end proc


f2 := proc (h) options operator, arrow; sqrt(g^2-h^2) end proc


f3 := proc (h) options operator, arrow; (1-h/g)*f1(h*R1/g)+h*f2(h)/g end proc


f4 := proc (h) options operator, arrow; sqrt((1/2)*g-(1/2)*h) end proc


f5 := proc (h) options operator, arrow; (1-h/g)*f3(h)+h*f4(h)/g end proc


proc (h) options operator, arrow; piecewise(h < 0, f1(h), 0 <= h, f5(h)) end proc


proc (h, phi, R) options operator, arrow; `<,>`(sin(phi)*R, cos(phi)*R, h) end proc


proc (x, y, z) options operator, arrow; `<,>`(x, y, z)/sqrt(x^2+y^2+z^2) end proc



proc (x, y, z) options operator, arrow; plots:-display(dro1, plottools:-arrow(Vector([0, 0, 0]), 2*R1*n(x, y, z), .2, .4, .1, cylindrical_arrow, fringe = blue, color = "Green"), plots:-implicitplot3d(x*x1+y*y1+z*z1 = 0, x1 = -R1 .. R1, y1 = -R1 .. R1, z1 = -R1 .. g, color = blue)) end proc



gg1 := h -> f1(h): # for h<0
gg2 := h -> f5(h): # for h>=0

local hPlane, theta1, theta2, theta0, h0, Sol1, Sol2, R1, R2, h1, h2;
hPlane:=(x1,y1)->solve(x*x1 + y*y1 + z*z1, z1);
theta1,theta2:=sort([arctan(x,-y), arctan(-x,y)])[];
Sol1:=fsolve({gg1(h)=R, x*R*cos(theta)+y*R*sin(theta)+z*h=0}, {R=0..5,h=-5..5});
Sol2:=fsolve({gg2(h)=R, x*R*cos(theta)+y*R*sin(theta)+z*h=0}, {R=0..5,h=-5..5});
R1:=eval(R,Sol1); R2:=eval(R,Sol2); h1:=eval(h,Sol1); h2:=eval(h,Sol2);
if h0<=0 then return
piecewise(theta>=theta1 and theta<=theta2,[R1*cos(theta),R1*sin(theta),h1], [R2*cos(theta),R2*sin(theta),h2]) else
piecewise(theta>=theta1 and theta<=theta2,[R2*cos(theta),R2*sin(theta),h2],[R1*cos(theta),R1*sin(theta),h1]) fi;
end proc:

# Example of calculating the coordinates of a point on this curve

[.9683428665, 1.677219044, -2.291123822]


# The plotting of this curve
Plot2:=plots:-display(plottools:-curve([seq(Curve(t,3,1,2), t=-evalf(Pi)..evalf(Pi),0.05)]), color=red, thickness=4, scaling=constrained);







Maple does not implement the solution of irrational inequalities with parameters. Here is a simpler example:

solve(sqrt(x-a)<x, x);

              Warning, solutions may have been lost

To calculate the values of derivatives of any order at a point, use  D  instead of  diff :

sum((D@@k)(f)(0), k=1..2);


As a workaround, use exact arifmetic:

answer := 5*exp(15/2*t);
response := subs(a = exp(1), 5*a^(15/2*t));
a := subs(t = Pi, answer);
b := subs(t = Pi, response);


In order for Maple to solve this example step by step, we need to help it a little. To do this, first make the change  x=sin(t) . Maple shows a step-by-step solution, and in the end we do the inverse change and final simplification for a multiple argument:

A:=Int(x^2 * sqrt(1-x^2), x):
B:=IntegrationTools:-Change(A, x=sin(t));
subs(t=arcsin(x), -(1/32)*sin(4*t)+(1/8)*t);


U minus C;

# Or in prefix notation

See the help page  Sets and Lists

If you already know the desired final result, then the easiest way is:

simplify(sin(4*Pi*w)/sin(2*Pi*w) - 2*cos(2*Pi*w));

Output :            0

The commands proposed in other answers are selected based on the already known result.

2 3 4 5 6 7 8 Last Page 4 of 212