Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Math and Science (http://www.chiefdelphi.com/forums/forumdisplay.php?f=70)
-   -   numerical computation challenge (http://www.chiefdelphi.com/forums/showthread.php?t=116891)

Ether 15-05-2013 07:50

numerical computation challenge
 

Find the area between these two curves, accurate to 6 decimal places:


y=10*ln(x+1)/exp(x+1)

x=10*ln(y+1)/exp(y+1)


Use whatever computer tools you want. Show your work.



Michael Hill 15-05-2013 12:56

Re: numerical computation challenge
 
I think I solved it....

I got 0.536594(7|8)
My strategy was to use the fact that it was symmetric about x=y.

I took the initial y=... function and rotated it by pi/4 (45 degrees) using the transformation matrix:
Code:

[y']  [cos(pi/4)  sin(pi/4)] [y]
[  ] = [                    ] [ ]
[x']  [cos(pi/4) -sin(pi/4)] [x]

That allows me to essentially take the integral above the new y' and simply multiply it by 2. I used MATLAB to get it.

Code:

clear

xmin = eval(evalin(symengine, 'numeric::solve(0==y-10*log(y+1)/exp(y+1), y=-0.5..0.5)'));
xmax = eval(evalin(symengine, 'numeric::solve(0==y-10*log(y+1)/exp(y+1), y=0.5..2)'));

error = 1;
stepsize = 3000000;
prevsum = 0;
while (abs(error > 0.000000001))
    stepsize = stepsize + 10000;
    th = pi/4
    x0min = xmin;
    x0max = xmax;
    y0min = xmin;
    y0max = xmax;

    x0 = linspace(x0min,x0max,stepsize);
    y0 = linspace(y0min,y0max,stepsize);
    y = 10*log(x0+1)./exp(x0+1);
    x = 10*log(y0+1)./exp(y0+1);
    xp = x*cos(th) + y0*sin(th);
    yp = y*cos(th) - x0*sin(th);
    xp0 = x/cos(th);
    plot(x0,y,x,y0,xp,yp);
    axis equal
    axis square
    grid on
    sum = 0;
    for i=1:stepsize-1
        sum = sum + (xp0(i+1)-xp0(i))*yp(i);
    end
    sum = sum*2;
    error = sum - prevsum;
    disp('step size');
    disp(stepsize);
    disp('sum');
    disp(sum);
    disp('error');
    disp(error);
end


MechEng83 15-05-2013 13:05

Re: numerical computation challenge
 
Quote:

Originally Posted by Michael Hill (Post 1275088)
I took the initial y=... function and rotated it by pi/4 (45 degrees) using the transformation matrix:
Code:

y'    [cos(pi/2) sin(pi/2)] [y]
  =
x'    [cos(pi/2) -sin(pi/2)] [x]

That allows me to essentially take the integral above the new y' and simply multiply it by 2.

Rather than going through the trouble of transforming it, I just subtracted the integral of y=x, as that's the symmetry line.

I got 0.536595 for the area -- found the second intercept at .95012, then just took the integral from 0 to .95012 of [10*ln(x)/exp(x)-x] and multiplied by 2.

Ether 15-05-2013 13:29

Re: numerical computation challenge
 
2 Attachment(s)

Nice job guys. The key was using the y=x symmetry line.

In the attached graph, the red and green lines are the two curves. The cyan line y=x is the axis of symmetry. If you subtract the cyan line from the red curve, you get the black curve.

I used Maxima to find the X-axis intercept of the black curve, and then numerically integrate the black curve from zero to that value and double it.

Michael Hill 15-05-2013 22:14

Re: numerical computation challenge
 
Of course I go the complicated route. This transcends to my ideas for robots as well. I need to learn to be more elegant. :-P


All times are GMT -5. The time now is 12:23.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi