0
$\begingroup$

I am trying to see if the two graphs intersect each other or not. If they intersect, I want to know the points too. One is an exponential function in and the other is a polynomial function in two variables $x$ and $y$. I was using Solve to do the same before when both were polynomial functions. Now, Solve just returns the arguments.

Solve[4 + 0.2 Exp[-x] == (-0.38 x^2 - 
    x (0.05 (0.2 - 1.6 y) + 0.2 (-2.9 - 0.2 y)) - 
    0.8 y (0.15 - 0.2 y + 0.9 (-3 + 2 y)))/(0.2 x + 0.8 y) && x >= 0 &&
   y >= 0, {x, y}]

Can you please guide me with this?

$\endgroup$
5
  • $\begingroup$ Using subscripts is not a very good idea; why not just use x and y? Also, you are now solving a transcendental equation, and Solve[] is not very good at those. If you are plotting them anyway, have a look at MeshFunctions. $\endgroup$ Mar 31, 2019 at 0:00
  • $\begingroup$ @J.M.isslightlypensive, thank you for the advice. I have renamed the variables. I will also look at MeshFunctions $\endgroup$
    – gaganso
    Mar 31, 2019 at 0:17
  • $\begingroup$ The example here might be of use. $\endgroup$ Mar 31, 2019 at 0:21
  • 1
    $\begingroup$ See if you can make use of Solve[4 + 0.2 Exp[-x] == (-0.38 x^2 - x (0.05 (0.2 - 1.6 y) + 0.2 (-2.9 - 0.2 y)) - 0.8 y (0.15 - 0.2 y + 0.9 (-3 + 2 y)))/(0.2 x + 0.8 y), {y}] $\endgroup$
    – Michael E2
    Mar 31, 2019 at 13:28
  • 1
    $\begingroup$ Yes, Solve[] is a bit cleaner here. NSolve[] replaces e^m with 2.71828^m. $\endgroup$
    – mjw
    Mar 31, 2019 at 17:46

2 Answers 2

2
$\begingroup$

You can use Contourplot more directly to show the solutionrange of f1[x]==f2[x,y]

ContourPlot[f1[x] == f2[x, y] , {x, -c, c}, {y, -c, c} , FrameLabel -> {x, y}]

enter image description here

This contour equals the solution of NSolve[f1[x] == f2[x, y] , {x, y}]

$\endgroup$
1
  • $\begingroup$ Yes, very nice! This clearly shows where the solution is! The place of discontinuity is where the denominator equals zero: p = ContourPlot[f1[x] == f2[x, y], {x, -c, c}, {y, -c, c}, FrameLabel -> {x, y}]; q = ContourPlot[.2 x + .8 y == 0, {x, -c, c}, {y, -c, c}, ContourStyle -> Red]; Show[p, q] $\endgroup$
    – mjw
    Mar 31, 2019 at 17:49
1
$\begingroup$

I believe there is no solution when both $x\ge 0$ and $y\ge0$.

Here are some quick plots:

 c = 3;
 f1[x_] = 4 + Exp[-x];
 f2[x_, y_] = (-0.38 x^2 - x (0.05 (0.2 - 1.6 y) + 0.2 (-2.9 - 0.2 y)) 
               - 0.8 y (0.15 - 0.2 y + 0.9 (-3 + 2 y)))/(0.2 x + 0.8 y);
 ContourPlot[{f2[x, y]}, {x, 0, c}, {y, 0, c}, 
   Contours -> 10, FrameLabel -> {x, y}]
 Plot[f1[x], {x, 0, c}, AxesLabel -> {x, 4 + Exp[-x]}]

enter image description here

At the innermost contour shown, $f_2(x,y) = 2$ and the value of $f_2(x,y)$ along the other contours decreases as $x$ and $y$ increase. The function $f_1(x,y)=4+\exp(-x)$ is bounded between $4$ and $5$ for $x\ge0$.

Also,

 f2[10^-30, 10^-30] 

returns

2.61.

If you relax the conditions $\{x\ge0,y\ge0\}$, Mathematica will return solutions:

 NSolve[4. + 0.2 Exp[-x] == (-0.38 x^2 
        -x (0.05 (0.2 - 1.6 y) + 0.2 (-2.9 - 0.2 y)) 
        -0.8 y (0.15 - 0.2 y + 0.9 (-3 + 2 y)))/(0.2 x + 0.8 y), 
        {x, y}]

does give a complicated expression for $y$ as a function of $x$.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.