Message Boards Message Boards

0
|
4837 Views
|
6 Replies
|
3 Total Likes
View groups...
Share
Share this post:

Problems with accuracy/precision of determinante, numerics

Problems with accuracy of determinant, multilayer stack, optics

Hi. I would like to calculate the imaginary part of a determinant as function of a parameter (in the attached example it is nR). The curve should cross the zero at some point, and later I would like to get the root of this function.

However, when I plot the function using Plot (see file attached), the resulting curve is extremely noise, which will presumably screw up my root search.

Could anyone help me and explain how to increase the precision of the calculation, such that the curve gets smooth? I thought that Mathematica is capable of calculating stuff to arbitrary precision, but I did not manage to implement that. What is the trick?

Regards,

Markus Hi. I would like to calculate the imaginary part of a deternimant as function of a parameter.

Attachments:
POSTED BY: Markus Schmidt
6 Replies

Pefect, now everything is clear.

Thanks a lot,
Markus

POSTED BY: Markus Schmidt

Thank you very much, it works. I understand now that rational numbers are key to increase accuracy. Just two more questions: 1. is there a way to transform a machine number to a number with arbitrary precision? I would like to important value into the nb and what to use them as numbers with arbitrary precision. 2. How does it behave with complex number?

Again thanks for the help.

POSTED BY: Markus Schmidt

Yes. Check the reference documentation on SetPrecision; you can do e.g.SetPrecision[1.45,67]. Also it will work on complex as well as real approximate numbers. Can also be used on exact numbers (behaves slightly like N but with some differences that make N preferable for most tasks).

One caveat about SetPrecision though. Any "error" between the initial decimal and it's underlying binary representation is going to remain. The example below might show what I mean.

In[1]:= SetPrecision[1.45,67]                                                   

(* Out[1]= 1.449999999999999955591079014993738383054733276367187500000000000000 *)
POSTED BY: Daniel Lichtblau

It's probably working just fine. The part that looks wrong is inside Plot where possibly low precision is being used. Instead try this.

(1) Do not set $MinPrecision or $MaxPrecision.

(2) ListPlot[Table[Im[fdis[[Lambda]0t, nR, d1t, d2t, d3t]], {nR, N[19/10, 100], 1999/1000, 1/1000}]]!

Alternatively:

Plot[Im[fdis[\[Lambda]0t, nR, d1t, d2t, d3t]], {nR, N[19/10, 100], 
  1999/1000}, WorkingPrecision -> 70]

These look smooth to me.

POSTED BY: Daniel Lichtblau

Thanks for the reply and the suggestion. I tried that, but it did not work (see files attached). I really do not know what it is the problem here. Is there any way to define that all numbers treated in the nb ought to have arbitary precision rather than being machine numbers?

Markus

Attachments:
POSTED BY: Markus Schmidt

Could remove the machine numbers e.g. use 145/100 instead of 1.45.

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

Group Abstract Group Abstract