# Tag Info

14

The "canonical" way in Mathematica is f[x_, y_] := x^2 + y^2 g[x_, y_] := x^4 + 4 x y + 2 y^4 - 8 Maximize[{f[x, y], g[x, y] == 0}, {x, y}] If you want to make explicit usage of the Lagrange multiplier: ss = N@Solve[Grad[f[x, y] + λ g[x, y], {x, y}] == 0 && g[x, y] == 0, {x, y, λ}, Reals] gives the {x, y} coordinates of the maxs and mins. ...

1

Creating a Table won't help you. You need to create an array (list) for your individual variables like eVars = Array[e,n] where n is some fixed integer. Then you need to create an appropriate objective function, that mixes all the components together in the way you want them to interact and yield a real value, not some kind of vector. From a ...

5

Suppose λ[ω_, θ_, ϕ_] := Sin[ω - θ] Cos[ϕ] l[θ_, ϕ_] := 10 Sin[θ] Sin[ϕ] then Plot3D[{(ω /. Last@FindMaximum[λ[ω, θ, ϕ], {ω, π}]), l[θ, ϕ]}, {θ, 0, π/4}, {ϕ, 0, π/4}] The desired answer is the orange surface when it is above the blue surface, which is obtained from Plot3D[If[(ω /. Last@FindMaximum[λ[ω, θ, ϕ], {ω, π}]) > l[θ, ϕ], (ω ...

8

For the first question: you can use ForAll (as you used $\forall$!) also in Mathematica. Once you have acquired a region, you can minimize argument constrained on it: ArgMin[{n, Resolve[ForAll[m, m >= n && Element[n, Integers], m^2 0.2 (1 - 0.2^2)^m < 1 && m > 0]]}, n] 227 If you take a hard look at the statement ...

1

RegionPlot3D[-a + b + c > 0 && -a + b + c^2 > 0 && a > 1 && b > 0 && c > 0, {a, -10, 20}, {b, -10, 10}, {c, -10, 10}, AxesLabel -> {a, b, c}]

2

expr1 = Sum[50/10000*1/4*1/4*n*97/100*Exp[-h1*1/4*n], {n, 1, 4}] - Sum[1/2*1/4*n*97/100*(Exp[-h1*1/4*(n - 1)] - Exp[-h1*1/4*n]), {n, 1, 4}]; expr2 = Sum[77/10000*1/4*1/4*n*97/100*Exp[-h1*1/4*n], {n, 1, 4}] + Sum[77/10000*1/4*1/4*n*94/100*Exp[-h2*1/4*n], {n, 5, 8}] - Sum[1/2*1/4*n*97/100*(Exp[-h1*1/4*(n - 1)] - Exp[-h1*1/4*n]), {n, 1, 4}] + ...

4

What you want to do is called "event location" and is realized with NDSolve using WhenEvent. In principle you give it a predicate that is true when the spaceship is at periapsis and NDSolve uses a root finding method to figure out exactly when this happens. G = 6.672*10^-11; m[1] = 6.4185*10^23; m[2] = 100; p[1] = {0, 0}; p[2] = {1000000, 1000000}; v[1] = ...

3

G = 6672*10^-14; m[1] = 64185*10^19; m[2] = 100; p[1] = {0, 0}; p[2] = {10^6, 10^6}; v[1] = {0, 2500}; v[2] = {0, 0}; tmax = 1000; soln = NDSolve[{ x[1]''[t] == -(G m[1] (x[1][t] - x[2][t]))/ Norm[{x[1][t], y[1][t]} - {x[2][t], y[2][t]}]^3, y[1]''[t] == -(G m[1] (y[1][t] - y[2][t]))/ Norm[{x[1][t], y[1][t]} - {x[2][t], y[2][t]}]^3, ...

3

WhenEvent is not supported by FindMinimum. It is supported by methods such as NDSolve and ParametricNDSolve which produce interpolation functions themselves. So without a more specific function to work with I can suggest you to do the following (I am doing something similar right now) Write your interpolation as a result of one of the Solve methods so that ...

7

from the documentation of WhenEvent: WhenEvent expressions can be used in NDSolve, NDSolveValue, ParametricNDSolve, ParametricNDSolveValue, DSolve, and DSolveValue. so I think no, you can't use WhenEvent within FindMinimum. You might be able to do some things similar to what WhenEvent can be used for with the EvaluationMonitor or StepMonitor options ...

4

According to the documentation, for the Nelder-Mead method, "Tolerance" is the tolerance for accepting constraint violations I think you actually meant to use either PrecisionGoal or AccuracyGoal, as per the documentation under NMaximize, depending on whether you want relative or absolute convergence criteria. Indeed, if you set AccuracyGoal to a ...

0

I see a different behavior when I try to evaluate your fit. First, your fitting model also seems to depend on a parameter l that is not included in the fit. I wonder if you had a separate definition for l that you did not include in your question. Since I don't have that definition, I will simply let the fitting routine find the best fit value for l as ...

0

Your function contains an undefined parameter l. If we use it as a variable instead: f[zr_, z0_, l_, x_] := l zr/Pi (1 + ((x + z0)/zr)^2) we get z = FindFit[data, f[zr, z0, l, x], {zr, z0, l}, x] (* {zr -> 0.175467, z0 -> -0.935304, l -> 6.7936*10^-7} *) Plot[f[zr, z0, l, x] /. z, {x, 0, 2}, Evaluated -> True, Epilog -> Point@data] ...

Top 50 recent answers are included