• Status: Solved
• Priority: Medium
• Security: Public
• Views: 505

# Integral Programming need help

I need to solve this

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

I have this so far
NumMethods.h:

/* 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)
{
double
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";
int
n;

double
a,
b,
ApproximateInt;

char

do
{
do
{
cout<< "\nEnter the endpoints (a & b) of the integral: ";
cin >> a >> b;
}
while ( a >= b);

do
{
cout<< "Enter the number of rectangles to be used: ";
cin>>n;

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)? ";
}

cout << "\nchange the starting interval (y or n)? ";
}

return 0;

}

This solve for a simple integral function of x^2 + 1
0
kimbola
• 2
• 2
1 Solution

Commented:
Have you tried changing F to your function?
Are you having problems hear v=v0?
0

Commented:
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

0

Author Commented:
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.
0

Commented:
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.

0

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

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.