Equation Solution – Wrong result from FindRoot

Light Background: I am trying to find coexistence under reduced pressure ($ p_r $) of a van der Waals fluid at a reduced temperature of 0.85, this requires the solution of the following system of equations, $ p_r $ is the only control variable:

  1. $ p_r = – (3 / v_r ^ 2) + (8 * 0,85) / (- 1 + 3 v_r) $

Of course, the above equation is a cubic number in vr, and you get three positive roots for certain values ​​of $ 0 <pr <1 $, I call the smallest of these roots $ v_ {r, 1} $ Up
to $ v_ {r, 3} $, Then the second equation to be satisfied is the following integral equation:

  1. $ int_ {v_ {r, 1}} ^ {v_ {r, 3}} left (- (3 / v_r ^ 2) + frac {(8 * 0,85)} {(- 1 + 3 v_r )} right) dv_r = p_r (v_ {r, 3} -v_ {r, 1}) $

The integral turns out to be an analytical solution. To simplify matters, I write:

$ int_ {v_ {r, 1}} ^ {v_ {r, 3}} left (- (3 / v_r ^ 2) + frac {(8 * 0,85)} {(- 1 + 3 v_r )} right) dv_r = frac {3} {v_ {r, 3}} – frac {3} {v_ {r, 1}} + frac {8 * 0,85} {3} , , Log ( frac {-1 + 3 v_ {r, 3}} {- 1 + 3 v_ {r, 1}}) $

To do this, I introduce the following module in Mathematica:

f(pr_, tr_) := Module({vr1, vr2, vr3},
  sol = Sort(vr /. NSolve(pr == -(3/vr^2) + (8*tr)/(-1 + 3 vr), vr));
  vr1 = sol((1)); vr2 = sol((2)); vr3 = sol((3));
  Re((3/vr + 8/3 tr Log(-1 + 3 vr) /. 
      vr -> vr3) - (3/vr + 8/3 tr Log(-1 + 3 vr) /. vr -> vr1) - 
    pr*(vr3 - vr1) )
  )

Then I plan f(pr,0.85) to find a graphical solution:

Diagram (f (pr, 0.85), {pr, 0.4, 0.55})

Enter image description here

So it is clear that the solution is pr = 0.505 (also independently tested).

But watch what happens when I use FindRoot:

FindRoot(f(pr, 0.8), {pr, 0.4, 0.1, 0.6}, Method -> "Newton")

I get:

{pr -> 0.530736}

I tried to change the method and the search intervals without success.

Can someone help me please?

File (libmagic) that reports the wrong MIME type on Debian

I have one on a Debian Buster server .avi file that is certainly an avi video.

However, file reports an incorrect result:

$ file -i "myfile.avi"
myfile.avi: image/x-tga; charset=binary

What could be the reason?

The same file on my PC (rsynced) is reported correctly as a video.

Looking for a solution, I saw the following:

$ sudo apt remove libmagic1 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 php7.3-cgi : Depends: libmagic1 but it is not going to be installed
              Depends: php7.3-cli but it is not going to be installed
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.

Does this thing help me solve my problem?

Python – wrong structure in my code! does not fall under any circumstances

I need to create a Python program with WHILE and IF to find out if an input number is prime or not.

Below is my code.
I can not find where this is my fault, because if I enter a value over 2, this does not fall under the conditions I have dealt with.

I know that this is a rookie mistake. I think the mistake lies in the placement of the lines inside the structures. In the code I deal with the divisions of the entered number from 1 to itself. I do not know how to format my code here on the site so I can post it in text and image.

Numero = int(input("Digite um numero inteiro: "))
if Numero == 2:
        print("Seu numero 2 é primo")
ContadorDeDivisores = 0
Divisor = 1
cont = 0
if Numero > 2:
    while cont < Numero:
            if Numero % Divisor == 0:
                ContadorDeDivisores = ContadorDeDivisores + 1
                Divisor = Divisor + 1
                cont = cont + 1
    if ContadorDeDivisores > 2:
        print("Seu numero",Numero,"não é primo")
    else:
        print("Seu numero",Numero,"é primo")

while Numero == 0 or Numero == 1:
    print("O numero que você quer verificar se é primo tem que ser maior ou igual a 2")
    Numero = int(input("Digite novamente um numero inteiro: "))
    if Numero == 2:
        print("Seu numero 2 é primo")
    if Numero > 2:
        while cont < Numero:
            if Numero % Divisor == 0:
                ContadorDeDivisores = ContadorDeDivisores + 1
                Divisor = Divisor + 1
                cont = cont + 1
        if ContadorDeDivisores > 2:
            print("Seu numero",Numero,"não é primo")
        else:
            print("Seu numero",Numero,"é primo")

my code

Right or wrong: your life is without flowers?

Report abuse

more details