I am using "elsarticle" class and need to place two algorithms side by side. I am using minipage fucntion to do this but algorithms are not generated exactly side by side (a picture is attached for your reference). A working latex code is given as:
documentclass[3p]{elsarticle}
\usepackage{hyperref}
%\modulolinenumbers[5]
\usepackage[ruled,linesnumbered]{algorithm2e}
\usepackage{amsfonts}
\usepackage{threeparttable}
\usepackage{tabularx}
%\usepackage{cite}
\usepackage{mathtools}
\DeclarePairedDelimiter\ceil{\lceil}{\rceil}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{multirow}
\usepackage{algorithm}
\usepackage{algpseudocode}
\begin{document}
\begin{minipage}{0.5\textwidth}
\begin{algorithm}[H]
% \caption{(X,Y)-only co-Z addition with update ($ZADDU_{(X,Y)}$)}
\caption{ $ZADDU_{(X,Y)}$}
\label{alg1}
%\begin{multicols}{2} % and a label for \ref{} commands
\begin{algorithmic}[1]
\Require{ $R_1 = (X_1, Y_1, Z )$ and $R_2 = (X_2, Y_2, Z)$ }
\Ensure {$(R_3, R_1)\mspace{5mu} = \mspace{5mu}ZADDU_{(X,Y)}(R_1, R_2)$ $\mspace{15mu}$where $R_3= R_1 + R_2=
(X_3, Y_3, Z_3)$ and $R_1 = (\lambda^2{X_1}, \lambda^3 {Y_1}, Z_3)$ with $Z_3=\lambda Z$ for some $\lambda\neq0$}\\
% \tcc{\textbf{Phase A:}}
% $z := 0, R_1 := x$\;
% $R_2 := u_2$\;
%
% \tcc{\textbf{Phase B:}}
$B=(X_1-X_2)^2$;
$E_1 =X_1 U; E_2 = X_2 U$; $C =(Y_1 - Y_2)^2$\\
$D =Y_1 (E_1 - E_2)$; $X_3=C - E_1 - E_2$;
$Y_3=(Y_1 - Y_2)(E_1 - X_3 ) - D$;\\
${X_1}= E_1$; ${Y_1} = D$;
$R_3=(X_3, Y_3)$, $R_3=(X_1, Y_1)$\\
\Return{($R_3,R_1$)}\;
\end{algorithmic}
\end{algorithm}
\end{minipage}
\hfill
\begin{minipage}{0.5\textwidth}
\begin{algorithm}[H]
% \caption{(X,Y)-only conjugate co-Z addition ($ZADDC_{(X,Y)}$)}
\caption{$ZADDC_{(X,Y)}$}
% give the algorithm a caption
\label{alg1}
%\begin{multicols}{2} % and a label for \ref{} commands
\begin{algorithmic}[1]
\Require{ $R_1 = (X_1, Y_1, Z )$ and $R_2 = (X_2, Y_2, Z)$ }
\Ensure {$(R_3, \overline R_3)\mspace{5mu} = \mspace{5mu}ZADDC_{(X,Y)}(R_1, R_2)$$\mspace{10mu}$where $R_3= R_1 + R_2=
(X_3, Y_3, Z_3)$ and $\overline R_3 =R_1 - R_2= (\overline{X_3},\overline {Y_3}, Z_3)$ }\\
% \tcc{\textbf{Phase A:}}
% $z := 0, R_1 := x$\;
% $R_2 := u_2$\;
%
% \tcc{\textbf{Phase B:}}
$B=(X_1-X_2)^2$;
$E_1 =X_1 U; E_2 = X_2 U$; $C =(Y_1 - Y_2)^2$;\\
$D =Y_1 (E_1 - E_2)$; $X_3=C - V_1 - V_2$;
$Y_3=(Y_1 - Y_2)(E_1 - X_3 ) - D$; \\
$\overline{C} = (Y1 + Y2)^2$; $\overline{X_3}= \overline{C} - E_1 - E_2$; $\overline{Y_3} = (Y_1 + Y_2)(E_1 - \overline{X_3} ) - D$;\\
\Return{($R_3,\overline R_3$)}\;
\end{algorithmic}
\end{algorithm}
\end{minipage}
\end{document}
An output picture is attached, any help to align these algorithms side by side would be appreciated a lot.
A couple of problems:
missing \ in front of documentclass
incompatible package. Your document will produce the error
Command \listofalgorithms already defined. ...s}{\listof{algorithm}{\listalgorithmname}}
You should never ignore error messages. After an error latex only recovers enough to syntax check the rest of the document, not necessarily producing sensible output
you are placing two minipages with .5\textwidth each besides each other. This will fill the entire line leaving no space for all the additional spaces added by your unescaped line endings. Either make your minipages smaller or add % at the end of lines so they don't act like spaces
use unique labels for your algorithms
the hyperref package should be loaded as one of the last packages. Don't load it directly at the start of your preamble
and just from your picture I would guess that in your real document you are missing an empty line before the minipages
\documentclass[3p]{elsarticle}
%\modulolinenumbers[5]
\usepackage[ruled,linesnumbered]{algorithm2e}
\usepackage{amsfonts}
\usepackage{threeparttable}
\usepackage{tabularx}
%\usepackage{cite}
\usepackage{mathtools}
\DeclarePairedDelimiter\ceil{\lceil}{\rceil}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{multirow}
%\usepackage{algorithm}
\usepackage{algpseudocode}
\usepackage{hyperref}
\begin{document}
\noindent\begin{minipage}{0.5\textwidth}
\begin{algorithm}[H]
% \caption{(X,Y)-only co-Z addition with update ($ZADDU_{(X,Y)}$)}
\caption{ $ZADDU_{(X,Y)}$}
\label{alg1}
%\begin{multicols}{2} % and a label for \ref{} commands
\begin{algorithmic}[1]
\Require{ $R_1 = (X_1, Y_1, Z )$ and $R_2 = (X_2, Y_2, Z)$ }
\Ensure {$(R_3, R_1)\mspace{5mu} = \mspace{5mu}ZADDU_{(X,Y)}(R_1, R_2)$ $\mspace{15mu}$where $R_3= R_1 + R_2=
(X_3, Y_3, Z_3)$ and $R_1 = (\lambda^2{X_1}, \lambda^3 {Y_1}, Z_3)$ with $Z_3=\lambda Z$ for some $\lambda\neq0$}\\
% \tcc{\textbf{Phase A:}}
% $z := 0, R_1 := x$\;
% $R_2 := u_2$\;
%
% \tcc{\textbf{Phase B:}}
$B=(X_1-X_2)^2$;
$E_1 =X_1 U; E_2 = X_2 U$; $C =(Y_1 - Y_2)^2$\\
$D =Y_1 (E_1 - E_2)$; $X_3=C - E_1 - E_2$;
$Y_3=(Y_1 - Y_2)(E_1 - X_3 ) - D$;\\
${X_1}= E_1$; ${Y_1} = D$;
$R_3=(X_3, Y_3)$, $R_3=(X_1, Y_1)$\\
\Return{($R_3,R_1$)}\;
\end{algorithmic}
\end{algorithm}
\end{minipage}%
%\hfill
\begin{minipage}{0.5\textwidth}
\begin{algorithm}[H]
% \caption{(X,Y)-only conjugate co-Z addition ($ZADDC_{(X,Y)}$)}
\caption{$ZADDC_{(X,Y)}$}
% give the algorithm a caption
\label{alg2}
%\begin{multicols}{2} % and a label for \ref{} commands
\begin{algorithmic}[1]
\Require{ $R_1 = (X_1, Y_1, Z )$ and $R_2 = (X_2, Y_2, Z)$ }
\Ensure {$(R_3, \overline R_3)\mspace{5mu} = \mspace{5mu}ZADDC_{(X,Y)}(R_1, R_2)$$\mspace{10mu}$where $R_3= R_1 + R_2=
(X_3, Y_3, Z_3)$ and $\overline R_3 =R_1 - R_2= (\overline{X_3},\overline {Y_3}, Z_3)$ }\\
% \tcc{\textbf{Phase A:}}
% $z := 0, R_1 := x$\;
% $R_2 := u_2$\;
%
% \tcc{\textbf{Phase B:}}
$B=(X_1-X_2)^2$;
$E_1 =X_1 U; E_2 = X_2 U$; $C =(Y_1 - Y_2)^2$;\\
$D =Y_1 (E_1 - E_2)$; $X_3=C - V_1 - V_2$;
$Y_3=(Y_1 - Y_2)(E_1 - X_3 ) - D$; \\
$\overline{C} = (Y1 + Y2)^2$; $\overline{X_3}= \overline{C} - E_1 - E_2$; $\overline{Y_3} = (Y_1 + Y_2)(E_1 - \overline{X_3} ) - D$;\\
\Return{($R_3,\overline R_3$)}\;
\end{algorithmic}
\end{algorithm}
\end{minipage}%
\end{document}
Related
Can I simply ask the logical flow of the below Mathematica code? What are the variables arg and abs doing? I have been searching for answers online and used ToMatlab but still cannot get the answer. Thank you.
Code:
PositiveCubicRoot[p_, q_, r_] :=
Module[{po3 = p/3, a, b, det, abs, arg},
b = ( po3^3 - po3 q/2 + r/2);
a = (-po3^2 + q/3);
det = a^3 + b^2;
If[det >= 0,
det = Power[Sqrt[det] - b, 1/3];
-po3 - a/det + det
,
(* evaluate real part, imaginary parts cancel anyway *)
abs = Sqrt[-a^3];
arg = ArcCos[-b/abs];
abs = Power[abs, 1/3];
abs = (abs - a/abs);
arg = -po3 + abs*Cos[arg/3]
]
]
abs and arg are being reused multiple times in the algorithm.
In a case where det > 0 the steps are
po3 = p/3;
b = (po3^3 - po3 q/2 + r/2);
a = (-po3^2 + q/3);
abs1 = Sqrt[-a^3];
arg1 = ArcCos[-b/abs1];
abs2 = Power[abs1, 1/3];
abs3 = (abs2 - a/abs2);
arg2 = -po3 + abs3*Cos[arg1/3]
abs3 can be identified as A in this answer: Using trig identity to a solve cubic equation
That is the most salient point of this answer.
Evaluating symbolically and numerically may provide some other insights.
Using demo inputs
{p, q, r} = {-2.52111798, -71.424692, -129.51520};
Copyable version of trig identity notes - NB a, b, p & q are used differently in this post
Plot[x^3 - 2.52111798 x^2 - 71.424692 x - 129.51520, {x, 0, 15}]
a = 1;
b = -2.52111798;
c = -71.424692;
d = -129.51520;
p = (3 a c - b^2)/3 a^2;
q = (2 b^3 - 9 a b c + 27 a^2 d)/27 a^3;
A = 2 Sqrt[-p/3]
A == abs3
-(b/3) + A Cos[1/3 ArcCos[
-((b/3)^3 - (b/3) c/2 + d/2)/Sqrt[-(-(b^2/9) + c/3)^3]]]
Edit
There is also a solution shown here
TRIGONOMETRIC SOLUTION TO THE CUBIC EQUATION, by Alvaro H. Salas
Clear[a, b, c]
1/3 (-a + 2 Sqrt[a^2 - 3 b] Cos[1/3 ArcCos[
(-2 a^3 + 9 a b - 27 c)/(2 (a^2 - 3 b)^(3/2))]]) /.
{a -> -2.52111798, b -> -71.424692, c -> -129.51520}
10.499
As in the title, in MATLAB, I need the feasible region (bounds of all feasible solutions) of
x_0 + x_1 e_1 + ... + x_n e_n
and
y_0 + y_1 e_1 + ... + y_n e_n
where all unknown e_i are in the interval [-1, 1]. I would prefer the solution to not depend on non-standard 3rd party functions.
Below is my quick-and-dirty attempt, but the complexity grows O(2^n), where n is the number of e_i. Any thoughts?
x0 = 3;
x = [1; -3; 0];
y0 = -1;
y = [3; -2; 4];
% Get all permutations of noise symbol extremities
terms = size(x, 1);
xx = zeros(2^terms, 1);
yy = zeros(2^terms, 1);
for j = 1:2^terms
e = double(bitget(j - 1, 1:terms))';
e(e == 0) = -1;
xx(j) = x0 + sum(x .* e);
yy(j) = y0 + sum(y .* e);
end
k = convhull(xx, yy);
plot(xx(k), yy(k));
% First generate all possible permutations for [-1, 1] for n terms. This is similar to what you have done but uses a matlab function
all_e = de2bi(0:(2^terms-1), terms).';
all_e(all_e == 0) = -1;
% Multiply corresponding values of x and y with those of e
xx = x0 + arrayfun(#(z) sum(x .* all_e(:, z)), 1:(2^terms));
yy = x0 + arrayfun(#(z) sum(y .* all_e(:, z)), 1:(2^terms));
You can read more about the function de2bi here
A method to find the absolute minimum and maximum bounds is as follows:
max_e = double(x >= 0);
min_e = double(~max_e);
max_e(max_e == 0) = -1;
min_e(min_e == 0) = -1;
absMax = x0 + sum(x .* max_e);
absMin = x0 + sum(x .* min_e);
Similarly you could do for y
Actually i have two intersecting circles as specified in the figure
i want to find the area of each part separately using Monte carlo method in Matlab .
The code doesn't draw the rectangle or the circles correctly so
i guess what is wrong is my calculation for the x and y and i am not much aware about the geometry equations for solving it so i need help about the equations.
this is my code so far :
n=1000;
%supposing that a rectangle will contain both circles so :
% the mid point of the distance between 2 circles will be (0,6)
% then by adding the radius of the left and right circles the total distance
% will be 27 , 11 from the left and 16 from the right
% width of rectangle = 24
x=27.*rand(n-1)-11;
y=24.*rand(n-1)+2;
count=0;
for i=1:n
if((x(i))^2+(y(i))^2<=25 && (x(i))^2+(y(i)-12)^2<=100)
count=count+1;
figure(2);
plot(x(i),y(i),'b+')
hold on
elseif(~(x(i))^2+(y(i))^2<=25 &&(x(i))^2+(y(i)-12)^2<=100)
figure(2);
plot(x(i),y(i),'y+')
hold on
else
figure(2);
plot(x(i),y(i),'r+')
end
end
Here are the errors I found:
x = 27*rand(n,1)-5
y = 24*rand(n,1)-12
The rectangle extents were incorrect, and if you use rand(n-1) will give you a (n-1) by (n-1) matrix.
and
first If:
(x(i))^2+(y(i))^2<=25 && (x(i)-12)^2+(y(i))^2<=100
the center of the large circle is at x=12 not y=12
Second If:
~(x(i))^2+(y(i))^2<=25 &&(x(i)-12)^2+(y(i))^2<=100
This code can be improved by using logical indexing.
For example, using R, you could do (Matlab code is left as an excercise):
n = 10000
x = 27*runif(n)-5
y = 24*runif(n)-12
plot(x,y)
r = (x^2 + y^2)<=25 & ((x-12)^2 + y^2)<=100
g = (x^2 + y^2)<=25
b = ((x-12)^2 + y^2)<=100
points(x[g],y[g],col="green")
points(x[b],y[b],col="blue")
points(x[r],y[r],col="red")
which gives:
Here is my generic solution for any two circles (without any hardcoded value):
function [ P ] = circles_intersection_area( k1, k2, N )
%CIRCLES_INTERSECTION_AREA Summary...
% Adnan A.
x1 = k1(1);
y1 = k1(2);
r1 = k1(3);
x2 = k2(1);
y2 = k2(2);
r2 = k2(3);
if sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2)) >= (r1 + r2)
% no intersection
P = 0;
return
end
% Wrapper rectangle config
a_min = x1 - r1 - 2*r2;
a_max = x1 + r1 + 2*r2;
b_min = y1 - r1 - 2*r2;
b_max = y1 + r1 + 2*r2;
% Monte Carlo algorithm
n = 0;
for i = 1:N
rand_x = unifrnd(a_min, a_max);
rand_y = unifrnd(b_min, b_max);
if sqrt((rand_x - x1)^2 + (rand_y - y1)^2) < r1 && sqrt((rand_x - x2)^2 + (rand_y - y2)^2) < r2
% is a point in the both of circles
n = n + 1;
plot(rand_x,rand_y, 'go-');
hold on;
else
plot(rand_x,rand_y, 'ko-');
hold on;
end
end
P = (a_max - a_min) * (b_max - b_min) * n / N;
end
Call it like: circles_intersection_area([-0.4,0,1], [0.4,0,1], 10000) where the first param is the first circle (x,y,r) and the second param is the second circle.
Without using For loop.
n = 100000;
data = rand(2,n);
data = data*2*30 - 30;
x = data(1,:);
y = data(2,:);
plot(x,y,'ro');
inside5 = find(x.^2 + y.^2 <=25);
hold on
plot (x(inside5),y(inside5),'bo');
hold on
inside12 = find(x.^2 + (y-12).^2<=144);
plot (x(inside12),y(inside12),'g');
hold on
insidefinal1 = find(x.^2 + y.^2 <=25 & x.^2 + (y-12).^2>=144);
insidefinal2 = find(x.^2 + y.^2 >=25 & x.^2 + (y-12).^2<=144);
% plot(x(insidefinal1),y(insidefinal1),'bo');
hold on
% plot(x(insidefinal2),y(insidefinal2),'ro');
insidefinal3 = find(x.^2 + y.^2 <=25 & x.^2 + (y-12).^2<=144);
% plot(x(insidefinal3),y(insidefinal3),'ro');
area1=(60^2)*(length(insidefinal1)/n);
area3=(60^2)*(length(insidefinal2)/n);
area2= (60^2)*(length(insidefinal3)/n);
I took this picture
Which image processing technique removes the swirling(typical low-light imaging artifacts) and creates a clear image?
There is different techniques for filtering out the artifacts from image. Some are based on machine learning and some use the pattern recognition.
I found this method> Optimization based pattern artifact removal from an image .
This is how it works in summary> An input image 'I' is decomposed into a latent natural image 'L' and a pattern artifact image 'E', where I = L + E. Pattern artifacts have unnatural spectrum peaks, and the such kind of peaks are separated into 'E'.
This code cannot deal with complex patterns.
Here is the matlab code for the function>
function [L, E] = imdecpattern( Y, lambda, tol, nite )
%IMDECPATTERN recovers a degraded image with a pattern artifact
% by decomposing the image into the latent image and the pattern image.
%
% [L, E] = IMDECPATTERN( Y )
% [L, E] = IMDECPATTERN( Y, lambda, tol, nite )
%
% arguments
% Y : input image
% L : latent image
% E : artifact image
% lambda : decomposition degree (default lambda=3)
% tol : the tolerance of a constraint Y = L + E (default tolerance=0)
% nite : the number of iterations to solve the problem.
%
%
%
% This program solves the following equation
%
% min_{l,e} |Dl|2,1 + lambda |Fe|c,1
% s.t. | y - (l+e) |2 <= tol, 1'l = 0
%
% where y is an observed image, l is the latent image, e is the artifact image,
% D is differential filtering and F is Fourier transformation.
%
%
% REFERENCE
%
% K. Shirai, S. Ono, and M. Okuda, ``Minimization of mixed norm for frequency
% spectrum of images and its application of pattern noise decomposition,''
% EUSIPCO, 5pages, 2017.
%
%
% parameters
%
if ~exist( 'lambda', 'var' ) || isempty( lambda )
lambda = 3; % mainly controls decomposition degree
end
if ~exist( 'tol', 'var' ) || isempty( tol )
tol = 0; % tolerance of the l2 ball related to noise reduction
end
% for ADMM
if ~exist( 'nite', 'var' ) || isempty( nite )
nite = 30; % number of iterations
end
rho = 1; % step size
%
% proximity operators
%
% mixed l2,1 norm
% is directly written in the ADMM algorithm
% mixed lc,1 norm
prox_lc1 = #(V,gamma) V.*(1 - gamma./max(gamma,abs(V)));
% l2 ball projection centered at V with the radius V-Y
prox_l2ball = #(V,V_Y,tol) V + V_Y * (tol/max(tol,norm(V_Y(:)))); % V_Y = V - Y
% which corresponds to ( norm(V_Y(:)) <= tol ) ? ( V ) : ( Y + V_Y*(tol/norm(V_Y(:)) );
[sy,sx,sc] = size( Y );
N = sy*sx; % number of pixels
% % unitary Fourier transform, but the following non-unitary version is faster.
% F = #(X) fft2(X)/sqrt(N); Ft = #(X) sqrt(N)*ifft2(X);
%
% non-unitary Fourier transform
lambda = sqrt(N) * lambda;
F = #(X) fft2(X); Ft = #(X) real(ifft2(X));
Zeros = zeros(sy,sx,sc);
Ones = ones(sy,sx,sc);
% initialization of variables
L = Y; E = Zeros;
% aux variables Z and Lagrangian-multiplier variables U
Zlh = Zeros; Ulh = Zeros;
Zlv = Zeros; Ulv = Zeros;
Ze = Zeros; Ue = Zeros;
Z = Zeros; U = Zeros;
% filters
% circular differential filters
Dh = [0,-1,1];
Dv = [0;-1;1];
% laplacian filter
DhDh_DvDv = [0,-1,0;-1,4,-1;0,-1,0];
% pre-computation of inverse filters
FA11 = 1 + repmat( psf2otf( DhDh_DvDv, [sy,sx] ), [1,1,sc] );
FA22 = 1 + Ones;
FA12 = Ones;
FA21 = Ones;
idetFA = 1./(FA11.*FA22 - FA12.*FA21); % determinant
iFA11 = FA22 .* idetFA; iFA12 = -FA12 .* idetFA;
iFA21 = -FA21 .* idetFA; iFA22 = FA11 .* idetFA;
% % weighted version
% sigma = 0.5;
% FW = Ones;
% FW = repmat( psf2otf( fspecial( 'gaussian', 2*ceil(3*sigma)+1, sigma ), [sy,sx] ), [1,1,sc] );
% FW = fftshift(FW);
for t = 1:nite
%
% solve l and e
%
IZU = (Z - U);
Fbl = fft2( IZU...
+ imfilter( Zlh - Ulh, Dh, 'corr','circular' )...
+ imfilter( Zlv - Ulv, Dv, 'corr','circular' ) );
Fbe = fft2( IZU + Ft( Ze - Ue ) );
L = real( ifft2( iFA11.*Fbl + iFA12.*Fbe ) );
E = real( ifft2( iFA21.*Fbl + iFA22.*Fbe ) );
%
% solve z_l and u_l
%
Vlh = imfilter( L, Dh, 'conv','circular' ) + Ulh;
Vlv = imfilter( L, Dv, 'conv','circular' ) + Ulv;
% prox of l2,1 norm
Vl_norm = sqrt(Vlh.*Vlh + Vlv.*Vlv);
Scale = 1 - (1/rho) ./ max(1/rho, Vl_norm);
Zlh = Vlh .* Scale;
Zlv = Vlv .* Scale;
Ulh = Vlh - Zlh; % update u_l
Ulv = Vlv - Zlv;
%
% solve z_e and u_e
%
Ve = F( E ) + Ue;
gamma = (lambda/rho);
% gamma = (lambda/rho) * FW; % weighted version
Ze = prox_lc1( Ve, gamma );
% the constraint coresponding to mean(e)=0
Ze(1,1,:) = 0;
Ue = Ve - Ze; % update u_e
%
% solve z and u
%
V = (L + E) + U;
dVY = V - Y;
for c = 1:sc
Z(:,:,c) = prox_l2ball( Y(:,:,c), dVY(:,:,c), tol );
% % Actually, this version is faster than the above
% dVYc = dVY(:,:,c);
% norm_dVY = norm( dVYc(:) );
% if ( norm_dVY <= tol )
% Z(:,:,c) = V(:,:,c);
% else
% Z(:,:,c) = Y(:,:,c) + dVY(:,:,c) * (tol/norm_dVY);
% end
end
U = V - Z; % update U
end
end
This is the test result>
I would like to know whats wrong with my code. I am trying to solve system of non-linear equations (initially in wolfram but the command was too long) in Mathematica:
Reduce[Pi*(h^2 + 2*R*(R - r))/sqrt (h^2 + (R - r)^2) - 2*x*Pi/3*h*R -
x*Pi/3*h*r == 0 &&
Pi*(h^2 + 2*r*(r - R))/sqrt (h^2 + (R - r)^2) + 2*Pi*r -
x*Pi/3*h*R - 2*x*Pi/3*h*r == 0 &&
Pi*h*(r + R)/sqrt (h^2 + (R - r)^2) - x*Pi/3*R^2 - x*Pi/3*R*r -
x*Pi/3*r^2 == 0 && -Pi/3*h*(R^2 + R*r + r^2) + 1 == 0, {R, r, h,
x}];
Do you know how to retype it and solve these equations? I tried to type it according to documentation, but I evidently made some mistake...
These are the original equations (in LaTeX, I dont know if they will show correctly here:
\begin{equation*}
\frac{\partial}{\partial R} L(R, r, h, \lambda) = \frac{\pi(h^2 + 2R(R-r))}{\sqrt{h^2 + (R - r)^2}} - 2\lambda \frac{\pi}{3}hR - \lambda \frac{\pi}{3}hr= 0
\end{equation*}
\begin{equation*}
\frac{\partial}{\partial r} L(R, r, h, \lambda) = \frac{\pi(h^2 + 2r(r-R))}{\sqrt{h^2 + (R - r)^2}} + 2\pi r - \lambda \frac{\pi}{3}hR - 2\lambda \frac{\pi}{3}hr= 0
\end{equation*}
\begin{equation*}
\frac{\partial}{\partial h} L(R, r, h, \lambda) = \frac{\pi h(r + R)}{\sqrt{h^2 + (R - r)^2}} - \lambda \frac{\pi}{3}R^2 - \lambda \frac{\pi}{3}Rr - \lambda \frac{\pi}{3}r^2= 0
\end{equation*}
\begin{equation*}
\frac{\partial}{\partial \lambda} L(R, r, h, \lambda) = - \frac{\pi}{3} h (R^2 + Rr + r^2) + 1 = 0
\end{equation*}
edit:
I corrected pi to PI, now it started evaluating so maybe it was the mistake...It just takes a very long time...
You have to learn at least the basics. Go to Help->Documentation Center and click on the book in the search bar. There is everything explained from the very start.
As already pointed out in the comments, all functions and built-in symbols start with a capital letter. Therefore your call should be
Reduce[Pi*(h^2 + 2*R*(R - r))/Sqrt[h^2 + (R - r)^2] - 2*x*Pi/3*h*R -
x*Pi/3*h*r == 0 &&
Pi*(h^2 + 2*r*(r - R))/Sqrt[h^2 + (R - r)^2] + 2*Pi*r -
x*Pi/3*h*R - 2*x*Pi/3*h*r == 0 &&
Pi*h*(r + R)/Sqrt[h^2 + (R - r)^2] - x*Pi/3*R^2 - x*Pi/3*R*r -
x*Pi/3*r^2 == 0 && -Pi/3*h*(R^2 + R*r + r^2) + 1 == 0, {R, r, h,
x}]