Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. HOW TO SOLVE IMPLIED EQUATIONS IN QT ?

HOW TO SOLVE IMPLIED EQUATIONS IN QT ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 490 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    ALEX_1
    wrote on last edited by ALEX_1
    #1

    Hello everyone, can you help me with how to solve implicit equations in qt; In the code I'm working on I need to solve several implicit equations, I also need to know if qt has tools to solve this type of equations.

    Attached image of an implicit equation, I need to solve f based on the rest of the parameters
    ecuacion.JPG

    JonBJ 1 Reply Last reply
    0
    • A ALEX_1

      Hello everyone, can you help me with how to solve implicit equations in qt; In the code I'm working on I need to solve several implicit equations, I also need to know if qt has tools to solve this type of equations.

      Attached image of an implicit equation, I need to solve f based on the rest of the parameters
      ecuacion.JPG

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @ALEX_1 said in HOW TO SOLVE IMPLIED EQUATIONS IN QT C++?:

      in qt c++

      Qt is a toolkit/function library. It is not a language, and there is no such thing as "Qt C++".
      Your question seems to be a pure C++ one. Qt does not address this area.

      1 Reply Last reply
      1
      • VRoninV Offline
        VRoninV Offline
        VRonin
        wrote on last edited by VRonin
        #3

        If it's not possible to solve analytically (i.e. pen and paper or wolfram) you need a root finding algorithm. Qt does not deal with this stuff but boost (the most popular C++ library after std) does:

        #include <boost/math/tools/roots.hpp>
        double solve_for_F(double var_epsilon_D, double var_Re, double starting_guess=0.5)
            using namespace boost::math;
            tools::eps_tolerance<double> tol(std::numeric_limits<double>::digits / 2);
            const int maximumIterations = 1000;
            boost::uintmax_t maxIter(maximumIterations); //maximum number of attempts
            try{
                const std::pair<double, double> Result = tools::bracket_and_solve_root(
                    [var_epsilon_D,var_Re](double var_f) -> double {
                        return (1.0/sqrt(f))+2.0*log10((var_epsilon_D/3.7)+(2.5/(var_Re*sqrt(f))));
                    }
                    , starting_guess, 2.0, false, tol, maxIter, optim_policy());
                if (maxIter >= maximumIterations)
                    return 0.0; //failed to find
                return (Result.first + Result.second) / 2.0;
            }
            catch (evaluation_error) {
                return 0.0; // Evaluation Error
            }
            catch (std::underflow_error) {
                return 0.0; // Underflow Error
            }
            catch (std::underflow_error) {
                return 0.0; // Overflow Error
            }
            catch (std::domain_error) {
                return 0.0; // Domain Error
            }
        }
        

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        1 Reply Last reply
        5

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved