Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7960339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:43:42+00:00 2026-06-04T04:43:42+00:00

I am trying to solve the next equation with C++ help: 3sin(sqrt(x)) + 0.35x

  • 0

I am trying to solve the next equation with C++ help: 3sin(sqrt(x)) + 0.35x – 3.8 = 0
The area with solution is [2, 3]

I wrote next code:

float f(float x)
{
    return (3 * sin(sqrt(x))) + (0.35 * x) - 3.8; //this is equation i am trying to solve
}

float g(float x, float(*f_ptr)(float)) 
{
    const float CONST = 0.1f; //const used to solve equation

    return CONST * f_ptr(x) + x;
}

void Task4_CalculateSomething()
{
    float x0, //starting aproximation
        xk, //current aproximation
        a = 2, //left barrier
        b = 3, //right barrier
        epsilon = 0.001; //allowed error

    const float REAL_SOLUTION = 2.2985; //real solution of selected equation

    printf("Setup starting aproximation: ");
    scanf("%f", &x0);

    do
    {
        xk = g(x0, f); //calc current aproximation

        if (fabs(xk - x0) < epsilon) //if Xn - Xn-1 fits the allowed error, the solution must be found
            break; //then we exit
        else
            x0 = xk; //else reset x values
    }
    while (fabs(a - x0) > epsilon && fabs(b - x0) > epsilon);

    printf("Found solution: %f\nReal solution: %f\n", xk, REAL_SOLUTION);
}

But it gives me weird results like -1.#IND00 which i don’t even know what is it.
And i can’t find any error there…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T04:43:44+00:00Added an answer on June 4, 2026 at 4:43 am

    Try using another algorithm like this:

    1. Write the derivative of the function: der=1.5*cos(sqrt((x))/sqrt(x)+.35
    2. next value is xk=x0-mysinc(x0)/der(x0)

    in few steps will fall into the solution… or make your variable CONST have a dynamic value of -1/der(x).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to find a solution for the next problem with help of
I'm trying to get a regexp to solve the next problem: I have some
I'm trying to solve the problem here but I don't know why my code
I'm trying to solve next task: Given a set of items, each with a
I am trying to solve the following problem but cannot find an elegant solution.
i am trying to copy a png file using the next code $cty2 =
I'm trying to help my son solve a math problem. This seems like a
I am trying to solve Knight Tour Problem using recursive Backtracking. Can someone help
I am trying to solve SPOJ problem 5: find the next largest integer palindrome
I'm trying to solve a system of equation with the following form: a5 +

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.