Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Integral Programming need help

Posted on 1999-07-23
Medium Priority
Last Modified: 2012-05-04
I need to solve this

phi = integral(0 - infinity) lnR(v)^1/2
                              --------------  dv

I have this so far

/* This file contains the declerations for Nummethods.


typedef double (*FunctionPtr)(double);

double RectangleMethod(
            FunctionPtr FPtr,
            double a,
            double b,
            int n);
NumMethods.cpp :
/*this file contains the definition of some numerical methods.

#include "NumMethods.h"

Rectangle Method approximates the defintie integral of a function using the rectangle method with altitudes at the idpoints of the subintervals.

double RectangleMethod(FunctionPtr FPtr,double Left, double Right, int n)
      DeltaX = (Right - Left) / n,
      MidPt = Left + DeltaX / 2.0,
      Sum = 0.0;
      for (int i = 1; i <=n; i++)
       Sum += FPtr(MidPt);
       MidPt += DeltaX;
       return Sum * DeltaX;

Calculus.cpp :
#include <math.h>
#include <iostream.h>
double F(double x)

return x * x +1 ;


#include "NumMethods.h"

int main(void)
      cout<< "\nThis program approxximates the definated integral of a"
                  "\n\tfunction using the rectangle method.\n";
                  cout<< "\nEnter the endpoints (a & b) of the integral: ";
                  cin >> a >> b;
            while ( a >= b);
                  cout<< "Enter the number of rectangles to be used: ";
                  ApproximateInt = RectangleMethod(F, a, b, n);
                  cout << "--> An Approximation to the integral using"
                         << n << " recatangles is " << ApproximateInt << "\n\n";
                  cout << "\nChange the number of rectangles (y or n)? ";
                  cin >> Answer;
                  while ((Answer == 'y')  || (Answer == 'Y'));
                  cout << "\nchange the starting interval (y or n)? ";
                  cin>> Answer ;
                  while ((Answer == 'y') || (Answer == 'Y'));
                  return 0;
This solve for a simple integral function of x^2 + 1
Question by:kimbola
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
LVL 84

Expert Comment

ID: 1200902
Have you tried changing F to your function?
Are you having problems hear v=v0?
LVL 14

Accepted Solution

AlexVirochovsky earned 400 total points
ID: 1200903
You must simple change  you
double F(double x)
 if (v0 != x)
   return sqrt(ln(x))/(v0*v0 - x*x);
return 0;//for example

and in you main programm must be something as
double v0;
cout << "\n Input v0 ";
cin >> v0;
Good Luck, Alex


Author Comment

ID: 1200904
the thing is that R(v) is a sixth degree polynomial and must be solved first.  In other words R(v) and v are not the same variable.
LVL 84

Expert Comment

ID: 1200905
If your problem is in solving R(v), we may be better able to help you if you'd let us know what difficulty you're having.

LVL 14

Expert Comment

ID: 1200906
I agree with ozo, but from text of Q i uderstand(and mistake) , that
F = ln(v)^1/2
What is true definition?

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question