0

I would like to use FindRoot for a problem of this type:

{f[x, y] == 0, g[x, y] == 0, 0 < y < x < 10}

My problem is that the interval is dependent on $ x, y $, so I don't know if it is possible to tell FindRoot to restrict its search. I tried including the inequality into the "equation" part as such :

FindRoot[{f[x, y] == 0, g[x, y] == 0, y < x}, {{x, 2, 0, 10}, {y, 1, 0, 10}}]

But of course this returns an error since FindRoot should take only equations.

Is there a way to do it or I have to program it myself from scratch?

To make myself clearer, I really need to find these solutions numerically, as there is no hope of finding them analytically. Here is the type of function I need to find the roots of, as per request:

f[m1_, m2_] := (2 l1)/(Sqrt[A] Sqrt[sp[m1, m2]]) ((EllipticK[sm[m1,m2]/sp[m1, m2]] (m1 - m2))/(m1 l1^2) + ((T^2 + Tc^2) - (m1 - m2)/(m1 l1^2)) EllipticPi[-((m1 l1^2)/sp[m1, m2]), sm[m1, m2]/sp[m1, m2]])

g[m1_,m2_] := (2 l2)/(Sqrt[A] Sqrt[sp[m1, m2]]) ((EllipticK[sm[m1, m2]/sp[m1, m2]] (m2 - m1))/(m2 l2^2) + ((T^2 - Tc^2) - (m2 - m1)/(m2 l2^2)) EllipticPi[-((m2 l2^2)/sp[m1, m2]), sm[m1, m2]/sp[m1, m2]])

Where l1, l2, A, sm[m1, m2], sp[x, y], T, Tc are numerical parameters/rational functions that are fixed. Not sure if this will be of much help.

Including the full definition of the functions is too long, I will try to produce a minimal working example that exhibits the same behavior as my functions.

Frotaur
  • 285
  • 1
  • 8
  • Have you tried NSolve? – MarcoB Dec 11 '20 at 16:56
  • I did, doesn't work for the type of functions I am using, which are defined Piecewise with transcendental functions... – Frotaur Dec 11 '20 at 16:58
  • 1
    Please share a sample of your specific functions then, so we avoid wild guesses. – MarcoB Dec 11 '20 at 17:00
  • I'll try to grab a subset of the function then, because it is defined piecewise and it has ALOT of components, close to 50 line of code to define – Frotaur Dec 11 '20 at 17:03
  • Thank you for adding a sample, but you are still missing the values of parameters. Let me be clearer: problems with code are typically solved by executing that code. If we don't have those values, we can't run your sample, and we can't help you. So please make sure that you include enough information for the code to be executed. – MarcoB Dec 11 '20 at 17:27
  • 1
    Possible duplicate: https://mathematica.stackexchange.com/questions/10279/findroot-domain-restriction -- For instance, how does FindMinimum[{f[x, y]^2 + g[x, y]^2, y < x}, {{x, 2, 0, 10}, {y, 1, 0, 10}}] work for you? You didn't include the full definitions, so I can't test & adjust. – Michael E2 Dec 11 '20 at 17:44
  • 2
    MWE: `f[m1_, m2_] := m1^2 - 3 m1 m2 + m2^2 - 1; g[m1_, m2_] := m1^2 + m2^2 - 2;

    FindMinimum[{f[x, y]^2 + g[x, y]^2, y < x}, {{x, 1, 0, 10}, {y, 2, 0, 10}}]`

    – Michael E2 Dec 11 '20 at 17:52
  • I'll try to include a MWE that reproduces my problem. The problem is that the functions I have pasted have apparent singularities, so I must define them piecewise to differentiate special case, e.g. m1=m2. For @MichaelE2 : I think your MWE does works with FindMinimum because you have only polynomials, no transcendental functions, but I'm not sure. I will try it. – Frotaur Dec 11 '20 at 18:37

1 Answers1

2

@Michael E2 has provide a good advice to do this. Here we review the other methods.

Since we doesn't know sp and other values in the original question,so here we only use the simple example take from the link in comment.

Clear[equations, conditions];
equations = {x y == z^3 - x, x y z == 2, x^2 + y^2 + z^3 == 5};
conditions = {-1 < x < 1, -3 < y < x - x^3, y < z < x};
terms = First /@ SubtractSides /@ equations

(* terms : {x + x y - z^3, -2 + x y z, -5 + x^2 + y^2 + z^3} *)

NMinimize[{0, terms^2 == 0, conditions}, {x, y, z}] NMinimize[{0, Total[terms^2] == 0, conditions}, {x, y, z}] NMinimize[{Total[terms^2], conditions}, {x, y, z}] FindMinimum[{Total[terms^2], conditions}, {x, y, z}]

{0., {x -> 0.832027, y -> -2.32619, z -> -1.03335}}

{0., {x -> 0.832027, y -> -2.32619, z -> -1.03335}}

{8.74548*10^-18, {x -> 0.832027, y -> -2.32619, z -> -1.03335}}

{1.13829*10^-14, {x -> 0.832027, y -> -2.32619, z -> -1.03335}}

cvgmt
  • 72,231
  • 4
  • 75
  • 133