Kitonum

21890 Reputation

26 Badges

17 years, 245 days

MaplePrimes Activity


These are replies submitted by Kitonum

nops(L1)  means the number of elements of the list  L1

Fragment of the code

for i from 1 to n do

U[1, i]:=L1[i]; U[2, i]:=L2[i]; U[i, 1]:=M1[i]; U[i, 2]:=M2[i];

od;

 specifies the first two lines and columns of the matrix  U .

Axel Vogt, I do not understand this statement :

"I think for that example over the _Reals_ the solution is

piecewise(x < 0, 4-4/365*(-11315*x+133225)^(1/2), 0<=x, 0) ;" 

A number or set of numbers  are  the roots of the equation, but you write a function that depends on x.

Your example in the real domain can be easily solved as above by the change:

restart;

eq1:= 2-2*(-31/365*x+1)^(1/2)-2*(2-2*(-31/365*x+1)^(1/2)-31/365*x)^(1/2)=0:

eq2:=-31/365*x+1=t^2:

simplify(algsubs(eq2, eq1)) assuming t>=0;

sol:=solve(%, useassumptions) assuming t>=0;

L:=convert(sol, list);

x:=unapply(solve(eq2, x), t);

'RealRange'(x(L[2]), x(L[1]));  # All roots of the equation eq1 in real domain

This equation can be solved by hand, if you select a perfect square under external root. If the variable  x  does not belong to the segment from 0 to 365/31, the complex numbers (in particular negative numbers) will be under the roots. If we keep in mind the principal value of the square root, it is easy to check that any number  x>=0  (in particular, x=12) is the root. Any other numbers (real or complex, including negative numbers) are not roots.

Axel Vogt, I do not understand this statement :

"I think for that example over the _Reals_ the solution is

piecewise(x < 0, 4-4/365*(-11315*x+133225)^(1/2), 0<=x, 0) ;" 

A number or set of numbers  are  the roots of the equation, but you write a function that depends on x.

Your example in the real domain can be easily solved as above by the change:

restart;

eq1:= 2-2*(-31/365*x+1)^(1/2)-2*(2-2*(-31/365*x+1)^(1/2)-31/365*x)^(1/2)=0:

eq2:=-31/365*x+1=t^2:

simplify(algsubs(eq2, eq1)) assuming t>=0;

sol:=solve(%, useassumptions) assuming t>=0;

L:=convert(sol, list);

x:=unapply(solve(eq2, x), t);

'RealRange'(x(L[2]), x(L[1]));  # All roots of the equation eq1 in real domain

This equation can be solved by hand, if you select a perfect square under external root. If the variable  x  does not belong to the segment from 0 to 365/31, the complex numbers (in particular negative numbers) will be under the roots. If we keep in mind the principal value of the square root, it is easy to check that any number  x>=0  (in particular, x=12) is the root. Any other numbers (real or complex, including negative numbers) are not roots.

VolMike ,

you are right!

VolMike ,

you are right!

@Carl Love 

Thanks for your interest and  improvements in the algorithm.

Comparison of timing of all three variants for a large number  10^11  ( Factoring1  is Joe Riel's modification).
 

t:=time():

Factoring(10^11):

time()-t;

     53.290

 

t:=time():

Factoring1(10^11):

time()-t;

      8.923

 

t:=time():

Factorings(10^11):

time()-t;

      3.666

@Markiyan Hirnyk

Thanks for the shown attempts! Unfortunately, the result is incorrect and does not satisfy the assigned objective . Waiting for your third and subsequent attempts.

 

@Markiyan Hirnyk

Thanks for the shown attempts! Unfortunately, the result is incorrect and does not satisfy the assigned objective . Waiting for your third and subsequent attempts.

 

@Markiyan Hirnyk

If you know of another way to solve this problem (for example, as integer programming problem), please show your code.

 

@Markiyan Hirnyk

If you know of another way to solve this problem (for example, as integer programming problem), please show your code.

 

@Markiyan Hirnyk 

 Use the toolbar for a larger view.

@Markiyan Hirnyk 

 Use the toolbar for a larger view.

@Axel Vogt 

assume(n, posint):

is(n^2 mod n =0);

           FAIL

@Axel Vogt 

assume(n, posint):

is(n^2 mod n =0);

           FAIL

@Joe Riel 

Thanks for the helpful comments and improving of the procedure. Your modification works 2 times faster.

First 123 124 125 126 127 128 129 Last Page 125 of 134