Group Abstract Group Abstract

Message Boards Message Boards

0
|
8.8K Views
|
4 Replies
|
1 Total Like
View groups...
Share
Share this post:

[?] Control the precision of the result with FindMinimum?

Posted 8 years ago
POSTED BY: Joao Porto
4 Replies

This gives 0.:

FindMinimum[
 {(r[1] - s[1])^2 + (r[2] - s[2])^2 + (r[3] - s[3])^2,
  r[1]^2 + r[2]^2 <= R^2, L + 2 r[3] >= 0,
  2 r[3] <= L,
  (Sin[?] (xT - s[1]) + Cos[?] s[2])^2 + (Cos[?] (Cos[?] (-xT + s[1]) + 
          Sin[?] s[2]) + Sin[?] (xz - s[3]))^2 <= R^2,
  2 Cos[?] Sin[?] (xT - s[1]) + 2 Cos[?] (xz - s[3]) <=  L + 2 Sin[?] Sin[?] s[2],
  2 Sin[?] Sin[?] s[2] <= L + 2 Cos[?] Sin[?] (xT - s[1]) + 2 Cos[?] (xz - s[3])},
 {{r[1], 0}, {s[1], xT}, {r[2], 0}, {s[2], 0}, {r[3], 0}, {s[3], xz}},
 PrecisionGoal -> 100, AccuracyGoal -> 100]
(*
{0.`, {r[1] -> 0.10396492820425005`, s[1] -> 0.10396492820425005`, 
  r[2] -> 0.04034535330283793`, s[2] -> 0.04034535330283793`, 
  r[3] -> 0.15050819950441896`, s[3] -> 0.15050819950441896`}} 
*)

This gives an odd error (a bug?):

FindMinimum[
 {(r[1] - s[1])^2 + (r[2] - s[2])^2 + (r[3] - s[3])^2,
  r[1]^2 + r[2]^2 <= R^2, L + 2 r[3] >= 0,
  2 r[3] <= L,
  (Sin[?] (xT - s[1]) + Cos[?] s[2])^2 + (Cos[?] (Cos[?] (-xT + s[1]) + 
          Sin[?] s[2]) + Sin[?] (xz - s[3]))^2 <= R^2,
  2 Cos[?] Sin[?] (xT - s[1]) + 2 Cos[?] (xz - s[3]) <=  L + 2 Sin[?] Sin[?] s[2],
  2 Sin[?] Sin[?] s[2] <= L + 2 Cos[?] Sin[?] (xT - s[1]) + 2 Cos[?] (xz - s[3])},
 {{r[1], 0}, {s[1], xT}, {r[2], 0}, {s[2], 0}, {r[3], 0}, {s[3], xz}},
 PrecisionGoal -> 100, AccuracyGoal -> 100,
 WorkingPrecision -> $MachinePrecision]

LibraryFunction::cfsa: Argument 1.000000000000000157806333833570613362021`15.653559774527023*^-500 at position 3 should be a machine-size real number.

POSTED BY: Michael Rogers
Posted 8 years ago

My guess as to what to set WorkingPrecision was wrong. If you use WorkingPrecision -> 50 rather than WorkingPrecision -> 40, you'll get zero.

POSTED BY: Jim Baldwin
Posted 8 years ago

For specific issues you'll need to give specifics on f[x] and g[y]. But in the meantime you might want to increase WorkingPrecision to, say, 40 (something larger than the default value) and have and constants in f[x] and g[y] as rational numbers. And you might want to try Minimize rather than FindMinimum.

POSTED BY: Jim Baldwin
Posted 8 years ago

@ Jim Baldwin: Sure, I revised the question for clarity, and provided an explicit example. Note that in this example defining the constants as rational number does not solve the problem.

POSTED BY: Joao Porto
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard