Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
I need help in coding (using Microsoft Visual studio C++) for Adams Moulton method for variable step size. Can any one help me to find my mistake 


What I have tried:

I am stuck in finding the maximum error.

void FNMAXE(double A, double B, double TEMP[DIM][DIM])
//double A,B,TEMP[DIM][DIM];
{
	int i, j;
	double TMP;//Fex[10][DIM];
			   //void SOLN();

	for (i = 1; i <= PO; i++)
 {
		SOLN(i + 2, Fex);
		for (j = 1; j <= EQN; j++)
 {
			TMP = A + B * fabs(Fex[i + 2][j]);
			TEMP[i][j] = fabs(Y[t][i + 2][j] - Fex[i + 2][j]) / TMP;
		
		}
	}
}



Here is the command for finding the Max Error

I am getting the maximum error for this problem

K[p][1] = Y[t][p][2];
K[p][2] = 2. * Y[t][p][2] - Y[t][p][1];

is,

FCN=757
1.000000e-02
TOTAL STEPS = 39
SUCCESS STEPS = 39
FAILURE STEPS = 0
MAX ERROR = 7.91476569e-01
AVERAGE ERROR = 2.16145282e-01
XEND = 1.89352261e+01

and to find the max error, the formula is |(ynew-yold)/(A+B*y(old))|.

Am i giving the correct command for finding the Max error
Posted
Updated 22-Jun-22 23:31pm
v3
Comments
Rick York 22-Jun-22 23:44pm    
We can't find a mistake in code we can't see.
Dave Kreskowiak 22-Jun-22 23:45pm    
You're not going to get an answer to this unless you add your code to your question. Nobody can help you with your code unless you show it.
Patrice T 23-Jun-22 0:12am    
you have a secret error in your secret code.
CPallini 23-Jun-22 2:02am    
I do have a fix for your code. However it is confidential and I cannot share it here.
Hira Soomro 23-Jun-22 2:10am    
Same here Sir. Can you just give me a hint on how to tackle that maximum error part? I somehow managed to get the successful number of steps. only stuck on the Maximum Error part after LTE.

1 solution

Quote:
Can any one help me to find my mistake
Quote:
Actually code is bit confidential as it belongs to my research work.

We cannot help you fix a problem with your code if we cannot see the code you have written: that would be like you asking the garage to fix your car engine, but not letting them know what make, model, or year it is, and refusing to bring it to the garage!

So, it's going to be up to you.
Fortunately, you have a tool available to you which will help you find out what is going on: the debugger. If you don't know how to use it then a quick Google for "Visual Studio debugger" should give you the info you need.

Put a breakpoint on the first line in the function, and run your code through the debugger. Then look at your code, and at your data and work out what should happen manually. Then single step each line checking that what you expected to happen is exactly what did. When it isn't, that's when you have a problem, and you can back-track (or run it again and look more closely) to find out why.

Sorry, but we can't do that for you - time for you to learn a new (and very, very useful) skill: debugging!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900