Solving a modular exponentiation with unknown power [closed] - c++

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Guys I what is the fastest algorithm to solve a modular equation in the format of a^b = c mod p where p is a really big prime and b is unknown.
e.g.:
2^k = 15 mod 30903154482632612361920641803533
I already tried trial and error using boost library in C++ but it would take very long time to reach the answer.

You're trying to solve what is called a discrete logarithm. If there was an efficient solution to this, I imagine whoever discovered it would wreak chaos on cryptographic systems long before it would be posted here.
You will find quite a couple of algorithms on Wikipedia with varying time complexity. Some of these are quite easy to implement. See The computational complexity of discrete log for the best space complexity.

Related

Suppose you have an array of N elements. You need to find for how many i, Ai + A(i+1) is a square number. Is this question trivial? If so how? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I just wanted to know if the above question is trivial or not. More importantly, how can you recognize if an algorithm is trivial?
It depends what do you mean by trivial. If you talk about complexity, it is O(n*M(N)) where M(N) is the complexity of the underlying multiplication algorithm with N maximum of the array's values and n is the length of the array.
If you talk about implementation, it is one loop with one check that the sum of the neighbors is a perfect square. If the elements fit into int, double etc. you have sqrt function in the standard library. If your elements are arbitrary length integers or float point numbers, you either need to use an appropriate library or implement the handling of these numbers on your own, which might be not trivial.
This understanding should help you to answer your last question

How to draw conclusions of performance comparisons between CPLEX, GuRoBi and SAS solvers [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
Are there guidelines to estimate beforehand which solver should be used for a mathematical optimization project?
Specifically this leads me to the following sub-questions:
How do performance benchmarks translate to probable or even possible optimization-performance-limits - specifically I mean maximum variable numbers for LPs and MILPs? (I am very much aware that this depends on the optimization problem, but there could to be a number(-range) from personal experience. The benchmark I am referring to is by H. Mittelmann: http://plato.asu.edu/ftp/milpc.html.)
Is it a fair conclusion to say CPLEX is 1.42 times slower than GUROBI, and if you are using CPLEX, but not switching to GUROBI, that you are wasting your company's resources (disregarding investments)?
Is it a fair conclusion to state that SAS is an incalculable risk for an optimization-project, because it fails 3 out of 87 calculation-runs when GUROBI doesn't?
I am aware that this question is awkward, but I think it has practical relevance (at least for me). Thanks in advance for answers.

Interior Point Method(Path following) vs Simplex [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
What are pros and cons of these two LP methods ?
I can only think of less iterations in Interior Point Method (when LPP is sufficiently large).
I'm going to list some features of both algorithms to explain what differentiates them.
Simplex
provides a basic solution, useful for branch and bound solvers in integer programming
easy to warm (or hot) start from a suboptimal solution, also necessary for integer programming
very high iteration speed mainly due to preservation of sparse data structures, but sometimes requires many iterations to reach optimality
memory efficient
numerically very stable
Interior Point
iteration count independent of problem size
often faster to reach optimality
easier to parallelize (Cholesky factorization)
In summary, IPM is the way to go for pure LPs, while for reoptimization-heavy applications like (mixed) integer programming the Simplex is better suited. One may also combine both approaches and perform a Simplex-like cross-over after the IPM found an optimal solution to get a basic one.
Often, it is a good idea to try both methods and decide then what works best, because performance is very much problem dependent.

Multiplicaton of big integers (factorial) [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I accidentally saw on Internet that functional programming language SML allows to do arbitrary precision integer arithmetic. I had written big integer arithmetic on C++ before and I decided(for curiosity) to compare my implementation with SML's by computing factorial of big numbers. I found out that SML program works about 15 times faster than mine. My implementation uses elementary school multiplication algorithm. But as I know the fast algorithms (such as FFT or Karatsuba's algorithm) worked better than elementary school multiplication when multipliers aren't much different. In this case they are, because (n-1)! is much greater than n. My question is what are the other possible reasons that the SML program works so faster.
Three possible reasons:
It uses multiple CPU cores (easy to test)
It uses SIMD instructions
It uses GPU (rare, but not unheard of)

How can I tell if an algorithm is efficient? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
Relatively new to C++ but I am very interested in the algorithmic aspect of programming.
Is there a general framework for deciding if an algorithm is efficient? i.e. the quickest possible?
I am trying to write pseudocode on paper before implementing but there are probably many different ways to solve any given problem.
Would be very keen to learn best practice for constructing / analysing algorithms.
Thanks, and Happy New Year!
Yes you can start with the Wikipedia article explaining the Big O notation, which in a nutshell is a way of describing the "efficiency" (upper bound of complexity) of different type of algorithms. Or you can look at an earlier answer where this is explained in simple english