Fortran solving for unknown upper bound of the integral [closed] - fortran

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I am trying to implement an algorithm in Fortran that involves solving for the boundary limit of the integral.
For example, I want to find a given the following integral: integral_(0-t) exp(t) dt = 1/2. which fortran should solve for t.
how would one go about solving this in Fortran? Thanks for your suggestions.

Your specific example can be easily solved exactly using logarithms, but I take it that you meant that simply as an illustrative example. If f(t) is your integrand and k is the target value then you are trying to find a root of the function
g(t) = integral_0^t f(u)du - k
You could try Newton's method to find that root. Newton's method requires that you can evaluate g(t) -- which you can by any numerical integration method, and also that you can evaluate its derivative g'(t) -- but this is even easier since by the Fundamental Theorem of Calculus, g'(t) = f(t) (assuming f is continuous).
Newton's method doesn't always converge and it tends to do better if the seed value is close to the root. You could try a preliminary bisection approach which gets you tolerably close to the root followed by Newton's method to refine it.

Related

Algorithm for solving sparse linear system in C++ [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 2 months ago.
Improve this question
I need to solve the heat equation for 2D object using C++. I've found many sources explaining the mathematics behind it. I am using the Crank-Nicholson scheme, but given that I need a 1001 x 1001 discretization, the resulting linear system is huge and memory would blow in case of a "traditional" implementation.
Therefore, I am recurring to methods for solving sparse linear systems. I have been looking online and cannot find any source explaining an algorithm to solve this sparse system efficiently. I've found several packages that do solve it (like csparse, eigen, SciPy under-the-hood implementation), but found no theoretical explanation to really code it myself. For the moment I am trying to do "reverse engineering" on the source code of SuperLU.
What I am looking for is an algorithm that you may know to solve sparse linear systems.
Thanks in advance

What does the logarithm code look like in C++? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 2 years ago.
Improve this question
I can't search what does the logarithm code look like in C++? What the code of the logarithm function looks like in C++ in the library cmath? Exactly the code. I don't need to figure out how I can get the logarithm. I want to know how this algorithm works.
You would be very disappointed. On modern processors, the C++ compiler inserts the assembly instruction that obtains it from the floating-point ALU. There is no code.
That is implementation specific and therefore can vary from system to system.
Since there are several ways to compute a logarithm, a good book on this kind of algorithm is a good start.

Solving a modular exponentiation with unknown power [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
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.

C/C++ library with map()/mapto() function? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
What I'm searching for is a function which allows mapping a certain numeric value of a certain numeric range onto another. I did find a way to create this function manually, which has the basic calculation output = output_start + ((output_end - output_start) / (input_end - input_start)) * (input - input_start), however I find it rather bothersome to always create it myself, search through my old projects to find it or to create a header file only for this function.
I'd imagine it's such a basic function that it should be somewhere in the C/C++ Standard libraries or at least in one of the mainstream 3rd party libraries, however I couldn't find it.
You are looking for a linear transformation function, that for every number in the range [input_start, input_end] computes a number in the range [output_start, output_end] using a proportionality factor (i.e. (output_end - output_start) / (input_end - input_start) in order to cover the full range).
Unfortunately, this simple function doesn't exist in the standard library (e.g. neither in cmath nor numeric). Anyway, when using such a transformation, most frequently you'd like to compute the proportionality factor only once.
So the easiest way would be to create your own function for this. In C++ you could create a class, which computes the factor at construction.

What's a good convex optimization library? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
I am looking for a C++ library, and I am dealing with convex objective and constraint functions.
I am guessing your problem is non-linear. Where i work, we use SNOPT, Ipopt and another proprietary solver (not for sale). We have also tried and heard good things about Knitro.
As long as your problem is convex, all these solvers work well.
They all have their own API, but they all ask for the same information : values, first and second derivatives.
Assuming your problems are nonlinear, you can use free and open-sourced OPT++, available from Sandia Lab. I have used it in one project in C++ and it was easy to use and worked well.
From what I know, the CPLEX solver is the best convex optimization solver. Its the state of the art in LP solvers. Does convex optimization really well. While looking for it, I see that its IBM's software now. You can find it here : http://www-01.ibm.com/software/integration/optimization/cplex/