[Scilab-users] ticks_mark property in Scilab 6.0.1

classic Classic list List threaded Threaded
13 messages Options
Patrice MÉGRET Patrice MÉGRET
Reply | Threaded
Open this post in threaded view
|

[Scilab-users] ticks_mark property in Scilab 6.0.1

Dear all,

 

Since Scilab 6.0.1 the ticks_mark property seems to be broken: the following code works as expected in Scilab 5.5.2 but does not display the formatted ticks in Scilab 6.0.1.

 

// test of ticks_format property
// PM 2019-01-08
 
x = [0:%pi/100:2*%pi]
plot2d(x,sin(x))
xgrid
 
af=gca()
// ticks_format ok, in Scilab 5.5.2 and broken in Scilab 6.0.1
af.ticks_format = ["%.1e","%.2f","%.1f"]  //x-axis in exp notation with 1 decimal place and y-axis with 2 decimal places

 

 

There is a bug 14790 reported Scilab's Bug Tracker.

 

For publication it is generally vital to have a specified number of decimal places on the axes.

So, will this be be solved in the next release or is there a clue to get the good behavior without using ticks_format?

 

Thanks a lot.

 

Patrice MEGRET   


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
fmiyara fmiyara
Reply | Threaded
Open this post in threaded view
|

[Scilab-users] improve accuracy of roots


Dear all,

Consider this code:

// Define polynomial variable
p = poly(0, 'p', 'roots');

// Define fourth degree polynomial
R = (1 + p)^4;

// Find its roots
z = roots(R)

The result (Scilab 6.0.1) is

  z  =

   -1.0001886
   -1. + 0.0001886i
   -1. - 0.0001886i
   -0.9998114

It should be something closer to

   -1.
   -1.
   -1.
   -1.

Using these roots

C = coeff((p-z(1))*(p-z(2))*(p-z(3))*(p-z(4)))

yield seemingly accurate coefficients
  C  =

    1.   4.   6.   4.   1.


but

C - [1  4  6 4 1]

shows the actual error:

ans  =

    3.775D-15   1.243D-14   1.155D-14   4.441D-15   0.

This is acceptable for the coefficients, but the error in the roots is
too large. Somehow the errors cancel out when  assembling back the
polynomial but each individual zero should be closer to the theoretical
value

Is there some way to improve the accuracy?

Regards,

Federico Miyara




---
El software de antivirus Avast ha analizado este correo electrónico en busca de virus.
https://www.avast.com/antivirus

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Christophe Dang Ngoc Chan Christophe Dang Ngoc Chan
Reply | Threaded
Open this post in threaded view
|

Re: improve accuracy of roots

Hello,

> De : users [mailto:[hidden email]] De la part de Federico Miyara
> Envoyé : jeudi 10 janvier 2019 00:32
>
> // Define fourth degree polynomial
> R = (1 + p)^4;
>
> // Find its roots
> z = roots(R)
> [...]
> but the error in the roots is too large.

The help page mentions that:
"This implies that just representing the coefficients as IEEE doubles changes the roots."
https://help.scilab.org/docs/6.0.1/en_US/roots.html

> Is there some way to improve the accuracy?

The "f" option does not work so I have no clue here, sorry.

Regards

--
Christophe Dang Ngoc Chan
Mechanical calculation engineer

Public
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error), please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Denis Crété Denis Crété
Reply | Threaded
Open this post in threaded view
|

Re: improve accuracy of roots

In reply to this post by fmiyara
Hello,
I tried this correction to the initial roots z:

z-4*(1+z).^4 ./([ones(z),z,z.^2,z.^3]*(C(2:5).*(1:4))')
 ans  =

  -1. - 1.923D-13i
  -1. + 1.189D-12i
  -1. - 1.189D-12i
  -1. - 1.919D-13i

// Evaluation of new error, (and defining Z as the intended root, i.e. here Z=-1):
z2=z-4*(z-Z).^4 ./([ones(z),z,z.^2,z.^3]*(C(2:5).*(1:4))')
z2 - Z
 ans  =

   2.233D-08 - 1.923D-13i
  -2.968D-08 + 1.189D-12i
  -2.968D-08 - 1.189D-12i
   2.131D-08 - 1.919D-13i

The factor 4 in the correction is a bit obscure to me, but it seems to work also for R=(3+p)^4, again with an accuracy on the roots of a ~2E-8.

HTH
Denis

-----Message d'origine-----
De : users [mailto:[hidden email]] De la part de Federico Miyara
Envoyé : jeudi 10 janvier 2019 00:32
À : [hidden email]
Objet : [Scilab-users] improve accuracy of roots


Dear all,

Consider this code:

// Define polynomial variable
p = poly(0, 'p', 'roots');

// Define fourth degree polynomial
R = (1 + p)^4;

// Find its roots
z = roots(R)

The result (Scilab 6.0.1) is

  z  =

   -1.0001886
   -1. + 0.0001886i
   -1. - 0.0001886i
   -0.9998114

It should be something closer to

   -1.
   -1.
   -1.
   -1.

Using these roots

C = coeff((p-z(1))*(p-z(2))*(p-z(3))*(p-z(4)))

yield seemingly accurate coefficients
  C  =

    1.   4.   6.   4.   1.


but

C - [1  4  6 4 1]

shows the actual error:

ans  =

    3.775D-15   1.243D-14   1.155D-14   4.441D-15   0.

This is acceptable for the coefficients, but the error in the roots is
too large. Somehow the errors cancel out when  assembling back the
polynomial but each individual zero should be closer to the theoretical
value

Is there some way to improve the accuracy?

Regards,

Federico Miyara




---
El software de antivirus Avast ha analizado este correo electrónico en busca de virus.
https://www.avast.com/antivirus

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Denis Crété
mottelet mottelet
Reply | Threaded
Open this post in threaded view
|

Re: improve accuracy of roots

Hi,

This behavior has already been discussed here :

http://bugzilla.scilab.org/show_bug.cgi?id=15349

S.

Le 10/01/2019 à 14:32, CRETE Denis a écrit :

> Hello,
> I tried this correction to the initial roots z:
>
> z-4*(1+z).^4 ./([ones(z),z,z.^2,z.^3]*(C(2:5).*(1:4))')
>   ans  =
>
>    -1. - 1.923D-13i
>    -1. + 1.189D-12i
>    -1. - 1.189D-12i
>    -1. - 1.919D-13i
>
> // Evaluation of new error, (and defining Z as the intended root, i.e. here Z=-1):
> z2=z-4*(z-Z).^4 ./([ones(z),z,z.^2,z.^3]*(C(2:5).*(1:4))')
> z2 - Z
>   ans  =
>
>     2.233D-08 - 1.923D-13i
>    -2.968D-08 + 1.189D-12i
>    -2.968D-08 - 1.189D-12i
>     2.131D-08 - 1.919D-13i
>
> The factor 4 in the correction is a bit obscure to me, but it seems to work also for R=(3+p)^4, again with an accuracy on the roots of a ~2E-8.
>
> HTH
> Denis
>
> -----Message d'origine-----
> De : users [mailto:[hidden email]] De la part de Federico Miyara
> Envoyé : jeudi 10 janvier 2019 00:32
> À : [hidden email]
> Objet : [Scilab-users] improve accuracy of roots
>
>
> Dear all,
>
> Consider this code:
>
> // Define polynomial variable
> p = poly(0, 'p', 'roots');
>
> // Define fourth degree polynomial
> R = (1 + p)^4;
>
> // Find its roots
> z = roots(R)
>
> The result (Scilab 6.0.1) is
>
>    z  =
>
>     -1.0001886
>     -1. + 0.0001886i
>     -1. - 0.0001886i
>     -0.9998114
>
> It should be something closer to
>
>     -1.
>     -1.
>     -1.
>     -1.
>
> Using these roots
>
> C = coeff((p-z(1))*(p-z(2))*(p-z(3))*(p-z(4)))
>
> yield seemingly accurate coefficients
>    C  =
>
>      1.   4.   6.   4.   1.
>
>
> but
>
> C - [1  4  6 4 1]
>
> shows the actual error:
>
> ans  =
>
>      3.775D-15   1.243D-14   1.155D-14   4.441D-15   0.
>
> This is acceptable for the coefficients, but the error in the roots is
> too large. Somehow the errors cancel out when  assembling back the
> polynomial but each individual zero should be closer to the theoretical
> value
>
> Is there some way to improve the accuracy?
>
> Regards,
>
> Federico Miyara
>
>
>
>
> ---
> El software de antivirus Avast ha analizado este correo electrónico en busca de virus.
> https://antispam.utc.fr/proxy/2/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/www.avast.com/antivirus
>
> _______________________________________________
> users mailing list
> [hidden email]
> https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users
> _______________________________________________
> users mailing list
> [hidden email]
> https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users


--
Stéphane Mottelet
Ingénieur de recherche
EA 4297 Transformations Intégrées de la Matière Renouvelable
Département Génie des Procédés Industriels
Sorbonne Universités - Université de Technologie de Compiègne
CS 60319, 60203 Compiègne cedex
Tel : +33(0)344234688
http://www.utc.fr/~mottelet

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
fmiyara fmiyara
Reply | Threaded
Open this post in threaded view
|

Re: improve accuracy of roots

In reply to this post by Denis Crété

Denis,

Thank you.

If this were really a general solution it would be great, since it improves the root accuracy by several orders, but I don't fully get the rationale behind this method.

It seems you are trying to apply a variant of the Raphson-Newton method, aren't you?

However, in cases like this, in which there are repeated roots, the derivative approaches zero as you get closer to the root, but the polynomial goes to zero faster.

In that case the factor 4 may imlpy that the next approximation gets closer to the actual root. But this is speculation. It   could also overshoot.

Regards,

Federico Miyara



On 10/01/2019 10:32, CRETE Denis wrote:
Hello,
I tried this correction to the initial roots z:

z-4*(1+z).^4 ./([ones(z),z,z.^2,z.^3]*(C(2:5).*(1:4))')
 ans  =

  -1. - 1.923D-13i
  -1. + 1.189D-12i
  -1. - 1.189D-12i
  -1. - 1.919D-13i

// Evaluation of new error, (and defining Z as the intended root, i.e. here Z=-1):
z2=z-4*(z-Z).^4 ./([ones(z),z,z.^2,z.^3]*(C(2:5).*(1:4))') 
z2 - Z
 ans  =

   2.233D-08 - 1.923D-13i
  -2.968D-08 + 1.189D-12i
  -2.968D-08 - 1.189D-12i
   2.131D-08 - 1.919D-13i

The factor 4 in the correction is a bit obscure to me, but it seems to work also for R=(3+p)^4, again with an accuracy on the roots of a ~2E-8.

HTH
Denis 

-----Message d'origine-----
De : users [[hidden email]] De la part de Federico Miyara
Envoyé : jeudi 10 janvier 2019 00:32
À : [hidden email]
Objet : [Scilab-users] improve accuracy of roots


Dear all,

Consider this code:

// Define polynomial variable
p = poly(0, 'p', 'roots');

// Define fourth degree polynomial
R = (1 + p)^4;

// Find its roots
z = roots(R)

The result (Scilab 6.0.1) is

  z  =

   -1.0001886
   -1. + 0.0001886i
   -1. - 0.0001886i
   -0.9998114

It should be something closer to

   -1.
   -1.
   -1.
   -1.

Using these roots

C = coeff((p-z(1))*(p-z(2))*(p-z(3))*(p-z(4)))

yield seemingly accurate coefficients
  C  =

    1.   4.   6.   4.   1.


but

C - [1  4  6 4 1]

shows the actual error:

ans  =

    3.775D-15   1.243D-14   1.155D-14   4.441D-15   0.

This is acceptable for the coefficients, but the error in the roots is 
too large. Somehow the errors cancel out when  assembling back the 
polynomial but each individual zero should be closer to the theoretical 
value

Is there some way to improve the accuracy?

Regards,

Federico Miyara




---
El software de antivirus Avast ha analizado este correo electrónico en busca de virus.
https://www.avast.com/antivirus

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users




Libre de virus. www.avast.com

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
fmiyara fmiyara
Reply | Threaded
Open this post in threaded view
|

Re: improve accuracy of roots

In reply to this post by Denis Crété

Denis,

I've found the correction here,

https://en.wikipedia.org/wiki/Newton%27s_method

It is useful to accelerate convergence in case of multiple roots, but I
guess it is not valid to apply it once to improve accuracy because of
the risk of overshoot.

Regards,

Federico Miyara


On 10/01/2019 10:32, CRETE Denis wrote:

> Hello,
> I tried this correction to the initial roots z:
>
> z-4*(1+z).^4 ./([ones(z),z,z.^2,z.^3]*(C(2:5).*(1:4))')
>   ans  =
>
>    -1. - 1.923D-13i
>    -1. + 1.189D-12i
>    -1. - 1.189D-12i
>    -1. - 1.919D-13i
>
> // Evaluation of new error, (and defining Z as the intended root, i.e. here Z=-1):
> z2=z-4*(z-Z).^4 ./([ones(z),z,z.^2,z.^3]*(C(2:5).*(1:4))')
> z2 - Z
>   ans  =
>
>     2.233D-08 - 1.923D-13i
>    -2.968D-08 + 1.189D-12i
>    -2.968D-08 - 1.189D-12i
>     2.131D-08 - 1.919D-13i
>
> The factor 4 in the correction is a bit obscure to me, but it seems to work also for R=(3+p)^4, again with an accuracy on the roots of a ~2E-8.
>
> HTH
> Denis
>
> -----Message d'origine-----
> De : users [mailto:[hidden email]] De la part de Federico Miyara
> Envoyé : jeudi 10 janvier 2019 00:32
> À : [hidden email]
> Objet : [Scilab-users] improve accuracy of roots
>
>
> Dear all,
>
> Consider this code:
>
> // Define polynomial variable
> p = poly(0, 'p', 'roots');
>
> // Define fourth degree polynomial
> R = (1 + p)^4;
>
> // Find its roots
> z = roots(R)
>
> The result (Scilab 6.0.1) is
>
>    z  =
>
>     -1.0001886
>     -1. + 0.0001886i
>     -1. - 0.0001886i
>     -0.9998114
>
> It should be something closer to
>
>     -1.
>     -1.
>     -1.
>     -1.
>
> Using these roots
>
> C = coeff((p-z(1))*(p-z(2))*(p-z(3))*(p-z(4)))
>
> yield seemingly accurate coefficients
>    C  =
>
>      1.   4.   6.   4.   1.
>
>
> but
>
> C - [1  4  6 4 1]
>
> shows the actual error:
>
> ans  =
>
>      3.775D-15   1.243D-14   1.155D-14   4.441D-15   0.
>
> This is acceptable for the coefficients, but the error in the roots is
> too large. Somehow the errors cancel out when  assembling back the
> polynomial but each individual zero should be closer to the theoretical
> value
>
> Is there some way to improve the accuracy?
>
> Regards,
>
> Federico Miyara
>
>
>
>
> ---
> El software de antivirus Avast ha analizado este correo electrónico en busca de virus.
> https://www.avast.com/antivirus
>
> _______________________________________________
> users mailing list
> [hidden email]
> http://lists.scilab.org/mailman/listinfo/users
> _______________________________________________
> users mailing list
> [hidden email]
> http://lists.scilab.org/mailman/listinfo/users
>
>

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Denis Crété Denis Crété
Reply | Threaded
Open this post in threaded view
|

Re: improve accuracy of roots

Thank you Frederico!
According to the page you refer to, the method seems to converge more rapidly with this factor equal to the multiplicity of the root.
About overshoot, it is well known to occur for |x|^a where a <1. But for a>1, the risk of overshoot with the Newton-Raphson method seems to be very small...
Best regards
Denis

[@@ THALES GROUP INTERNAL @@]

Unité Mixte de Physique CNRS / THALES
1 Avenue Augustin Fresnel
91767 Palaiseau CEDEx - France
Tel : +33 (0)1 69 41 58 52 Fax : +33 (0)1 69 41 58 78
e-mail :
 [hidden email] <mailto:%[hidden email]>
 http://www.trt.thalesgroup.com/ump-cnrs-thales
 http://www.research.thalesgroup.com


-----Message d'origine-----
De : users [mailto:[hidden email]] De la part de Federico Miyara
Envoyé : samedi 12 janvier 2019 07:52
À : Users mailing list for Scilab
Objet : Re: [Scilab-users] improve accuracy of roots


Denis,

I've found the correction here,

https://en.wikipedia.org/wiki/Newton%27s_method

It is useful to accelerate convergence in case of multiple roots, but I
guess it is not valid to apply it once to improve accuracy because of
the risk of overshoot.

Regards,

Federico Miyara


On 10/01/2019 10:32, CRETE Denis wrote:

> Hello,
> I tried this correction to the initial roots z:
>
> z-4*(1+z).^4 ./([ones(z),z,z.^2,z.^3]*(C(2:5).*(1:4))')
>   ans  =
>
>    -1. - 1.923D-13i
>    -1. + 1.189D-12i
>    -1. - 1.189D-12i
>    -1. - 1.919D-13i
>
> // Evaluation of new error, (and defining Z as the intended root, i.e. here Z=-1):
> z2=z-4*(z-Z).^4 ./([ones(z),z,z.^2,z.^3]*(C(2:5).*(1:4))')
> z2 - Z
>   ans  =
>
>     2.233D-08 - 1.923D-13i
>    -2.968D-08 + 1.189D-12i
>    -2.968D-08 - 1.189D-12i
>     2.131D-08 - 1.919D-13i
>
> The factor 4 in the correction is a bit obscure to me, but it seems to work also for R=(3+p)^4, again with an accuracy on the roots of a ~2E-8.
>
> HTH
> Denis
>
> -----Message d'origine-----
> De : users [mailto:[hidden email]] De la part de Federico Miyara
> Envoyé : jeudi 10 janvier 2019 00:32
> À : [hidden email]
> Objet : [Scilab-users] improve accuracy of roots
>
>
> Dear all,
>
> Consider this code:
>
> // Define polynomial variable
> p = poly(0, 'p', 'roots');
>
> // Define fourth degree polynomial
> R = (1 + p)^4;
>
> // Find its roots
> z = roots(R)
>
> The result (Scilab 6.0.1) is
>
>    z  =
>
>     -1.0001886
>     -1. + 0.0001886i
>     -1. - 0.0001886i
>     -0.9998114
>
> It should be something closer to
>
>     -1.
>     -1.
>     -1.
>     -1.
>
> Using these roots
>
> C = coeff((p-z(1))*(p-z(2))*(p-z(3))*(p-z(4)))
>
> yield seemingly accurate coefficients
>    C  =
>
>      1.   4.   6.   4.   1.
>
>
> but
>
> C - [1  4  6 4 1]
>
> shows the actual error:
>
> ans  =
>
>      3.775D-15   1.243D-14   1.155D-14   4.441D-15   0.
>
> This is acceptable for the coefficients, but the error in the roots is
> too large. Somehow the errors cancel out when  assembling back the
> polynomial but each individual zero should be closer to the theoretical
> value
>
> Is there some way to improve the accuracy?
>
> Regards,
>
> Federico Miyara
>
>
>
>
> ---
> El software de antivirus Avast ha analizado este correo electrónico en busca de virus.
> https://www.avast.com/antivirus
>
> _______________________________________________
> users mailing list
> [hidden email]
> http://lists.scilab.org/mailman/listinfo/users
> _______________________________________________
> users mailing list
> [hidden email]
> http://lists.scilab.org/mailman/listinfo/users
>
>

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Denis Crété
fmiyara fmiyara
Reply | Threaded
Open this post in threaded view
|

Re: improve accuracy of roots


Denis,

What I meant is that convergence is a limiting process. On average, as the number of iterations rises you´ll be closer to the limit, bu there is no guarantee that any single iteration will bring you any closer; it may be a question of luck. Maybe (though it would require a proof, it is not self-evident for me) in the exact case of a single multiple root as (x - a)^n the convergence process is monotonous, but what if you have (x - a1)* ... * (x  - an) where ak are all very similar but not identical, say, with relative differences of the order of those reported by the application of the regular version  of roots.    
Regards,

Federico Miyara


On 14/01/2019 13:47, CRETE Denis wrote:
Thank you Frederico!
According to the page you refer to, the method seems to converge more rapidly with this factor equal to the multiplicity of the root. 
About overshoot, it is well known to occur for |x|^a where a <1. But for a>1, the risk of overshoot with the Newton-Raphson method seems to be very small...
Best regards
Denis 

[@@ THALES GROUP INTERNAL @@]

Unité Mixte de Physique CNRS / THALES
1 Avenue Augustin Fresnel
91767 Palaiseau CEDEx - France
Tel : +33 (0)1 69 41 58 52 Fax : +33 (0)1 69 41 58 78 
e-mail : 
 [hidden email] [hidden email]
 http://www.trt.thalesgroup.com/ump-cnrs-thales
 http://www.research.thalesgroup.com


-----Message d'origine-----
De : users [[hidden email]] De la part de Federico Miyara
Envoyé : samedi 12 janvier 2019 07:52
À : Users mailing list for Scilab
Objet : Re: [Scilab-users] improve accuracy of roots


Denis,

I've found the correction here,

https://en.wikipedia.org/wiki/Newton%27s_method

It is useful to accelerate convergence in case of multiple roots, but I 
guess it is not valid to apply it once to improve accuracy because of 
the risk of overshoot.

Regards,

Federico Miyara


On 10/01/2019 10:32, CRETE Denis wrote:
Hello,
I tried this correction to the initial roots z:

z-4*(1+z).^4 ./([ones(z),z,z.^2,z.^3]*(C(2:5).*(1:4))')
  ans  =

   -1. - 1.923D-13i
   -1. + 1.189D-12i
   -1. - 1.189D-12i
   -1. - 1.919D-13i

// Evaluation of new error, (and defining Z as the intended root, i.e. here Z=-1):
z2=z-4*(z-Z).^4 ./([ones(z),z,z.^2,z.^3]*(C(2:5).*(1:4))')
z2 - Z
  ans  =

    2.233D-08 - 1.923D-13i
   -2.968D-08 + 1.189D-12i
   -2.968D-08 - 1.189D-12i
    2.131D-08 - 1.919D-13i

The factor 4 in the correction is a bit obscure to me, but it seems to work also for R=(3+p)^4, again with an accuracy on the roots of a ~2E-8.

HTH
Denis

-----Message d'origine-----
De : users [[hidden email]] De la part de Federico Miyara
Envoyé : jeudi 10 janvier 2019 00:32
À : [hidden email]
Objet : [Scilab-users] improve accuracy of roots


Dear all,

Consider this code:

// Define polynomial variable
p = poly(0, 'p', 'roots');

// Define fourth degree polynomial
R = (1 + p)^4;

// Find its roots
z = roots(R)

The result (Scilab 6.0.1) is

   z  =

    -1.0001886
    -1. + 0.0001886i
    -1. - 0.0001886i
    -0.9998114

It should be something closer to

    -1.
    -1.
    -1.
    -1.

Using these roots

C = coeff((p-z(1))*(p-z(2))*(p-z(3))*(p-z(4)))

yield seemingly accurate coefficients
   C  =

     1.   4.   6.   4.   1.


but

C - [1  4  6 4 1]

shows the actual error:

ans  =

     3.775D-15   1.243D-14   1.155D-14   4.441D-15   0.

This is acceptable for the coefficients, but the error in the roots is
too large. Somehow the errors cancel out when  assembling back the
polynomial but each individual zero should be closer to the theoretical
value

Is there some way to improve the accuracy?

Regards,

Federico Miyara




---
El software de antivirus Avast ha analizado este correo electrónico en busca de virus.
https://www.avast.com/antivirus

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users




Libre de virus. www.avast.com

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
fmiyara fmiyara
Reply | Threaded
Open this post in threaded view
|

[Scilab-users] Seemingly inconsistent behavior


Dear all,

This statement

a = {[%f, %t], {2; poly([3, 2],'v')}}

defines a cell array whose first element is a boolean row vector and
whose second element in turn is another cell array.

Invoking a{1}(1) correctly returns the boolean value F.

But a{2}{1} does not return 2, as expected but an error:

Error: syntax error, unexpected {, expecting end of file

However

b  =  a{2}
b{1}

returns the correct value 2.

Why, if a{2} is a cell array, its entries cannot be extracted with the
curly brackets {}?

Moreover a{2}(1) and a{2}(2) should be the constant 2. and the polynomial

            2
    6 -5v +v

respectively,  but they are reported as cell arrays, since

iscell(a{2}(1)) and  iscell(a{2}(2)) are both True

Why is a cell array responsive to () at all and why it returns a sub ell
array?

Thank you in advance.

Regards,

Federico Miyara




---
El software de antivirus Avast ha analizado este correo electrónico en busca de virus.
https://www.avast.com/antivirus

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
mottelet mottelet
Reply | Threaded
Open this post in threaded view
|

Re: Seemingly inconsistent behavior

Hello,

This limitation is alreay pointed out here :

http://bugzilla.scilab.org/show_bug.cgi?id=15756

S.

Le 15/01/2019 à 03:36, Federico Miyara a écrit :

>
> Dear all,
>
> This statement
>
> a = {[%f, %t], {2; poly([3, 2],'v')}}
>
> defines a cell array whose first element is a boolean row vector and
> whose second element in turn is another cell array.
>
> Invoking a{1}(1) correctly returns the boolean value F.
>
> But a{2}{1} does not return 2, as expected but an error:
>
> Error: syntax error, unexpected {, expecting end of file
>
> However
>
> b  =  a{2}
> b{1}
>
> returns the correct value 2.
>
> Why, if a{2} is a cell array, its entries cannot be extracted with the
> curly brackets {}?
>
> Moreover a{2}(1) and a{2}(2) should be the constant 2. and the polynomial
>
>            2
>    6 -5v +v
>
> respectively,  but they are reported as cell arrays, since
>
> iscell(a{2}(1)) and  iscell(a{2}(2)) are both True
>
> Why is a cell array responsive to () at all and why it returns a sub
> ell array?
>
> Thank you in advance.
>
> Regards,
>
> Federico Miyara
>
>
>
>
> ---
> El software de antivirus Avast ha analizado este correo electrónico en
> busca de virus.
> https://antispam.utc.fr/proxy/2/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/www.avast.com/antivirus 
>
>
> _______________________________________________
> users mailing list
> [hidden email]
> https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users 
>


--
Stéphane Mottelet
Ingénieur de recherche
EA 4297 Transformations Intégrées de la Matière Renouvelable
Département Génie des Procédés Industriels
Sorbonne Universités - Université de Technologie de Compiègne
CS 60319, 60203 Compiègne cedex
Tel : +33(0)344234688
http://www.utc.fr/~mottelet

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
mottelet mottelet
Reply | Threaded
Open this post in threaded view
|

Re: improve accuracy of roots

In reply to this post by fmiyara
Hello,

After a quick search on the internet I have found and translated in Scilab "multroot", a Matlab Package computing polynomial roots and multiplicities. If you are interested proceed to this url: http://bugzilla.scilab.org/show_bug.cgi?id=15349#c9

Enjoy !

S.

Le 14/01/2019 à 21:07, Federico Miyara a écrit :

Denis,

What I meant is that convergence is a limiting process. On average, as the number of iterations rises you´ll be closer to the limit, bu there is no guarantee that any single iteration will bring you any closer; it may be a question of luck. Maybe (though it would require a proof, it is not self-evident for me) in the exact case of a single multiple root as (x - a)^n the convergence process is monotonous, but what if you have (x - a1)* ... * (x  - an) where ak are all very similar but not identical, say, with relative differences of the order of those reported by the application of the regular version  of roots.    
Regards,

Federico Miyara


On 14/01/2019 13:47, CRETE Denis wrote:
Thank you Frederico!
According to the page you refer to, the method seems to converge more rapidly with this factor equal to the multiplicity of the root. 
About overshoot, it is well known to occur for |x|^a where a <1. But for a>1, the risk of overshoot with the Newton-Raphson method seems to be very small...
Best regards
Denis 

[@@ THALES GROUP INTERNAL @@]

Unité Mixte de Physique CNRS / THALES
1 Avenue Augustin Fresnel
91767 Palaiseau CEDEx - France
Tel : +33 (0)1 69 41 58 52 Fax : +33 (0)1 69 41 58 78 
e-mail : 
 [hidden email] [hidden email]
 http://www.trt.thalesgroup.com/ump-cnrs-thales
 http://www.research.thalesgroup.com


-----Message d'origine-----
De : users [[hidden email]] De la part de Federico Miyara
Envoyé : samedi 12 janvier 2019 07:52
À : Users mailing list for Scilab
Objet : Re: [Scilab-users] improve accuracy of roots


Denis,

I've found the correction here,

https://en.wikipedia.org/wiki/Newton%27s_method

It is useful to accelerate convergence in case of multiple roots, but I 
guess it is not valid to apply it once to improve accuracy because of 
the risk of overshoot.

Regards,

Federico Miyara


On 10/01/2019 10:32, CRETE Denis wrote:
Hello,
I tried this correction to the initial roots z:

z-4*(1+z).^4 ./([ones(z),z,z.^2,z.^3]*(C(2:5).*(1:4))')
  ans  =

   -1. - 1.923D-13i
   -1. + 1.189D-12i
   -1. - 1.189D-12i
   -1. - 1.919D-13i

// Evaluation of new error, (and defining Z as the intended root, i.e. here Z=-1):
z2=z-4*(z-Z).^4 ./([ones(z),z,z.^2,z.^3]*(C(2:5).*(1:4))')
z2 - Z
  ans  =

    2.233D-08 - 1.923D-13i
   -2.968D-08 + 1.189D-12i
   -2.968D-08 - 1.189D-12i
    2.131D-08 - 1.919D-13i

The factor 4 in the correction is a bit obscure to me, but it seems to work also for R=(3+p)^4, again with an accuracy on the roots of a ~2E-8.

HTH
Denis

-----Message d'origine-----
De : users [[hidden email]] De la part de Federico Miyara
Envoyé : jeudi 10 janvier 2019 00:32
À : [hidden email]
Objet : [Scilab-users] improve accuracy of roots


Dear all,

Consider this code:

// Define polynomial variable
p = poly(0, 'p', 'roots');

// Define fourth degree polynomial
R = (1 + p)^4;

// Find its roots
z = roots(R)

The result (Scilab 6.0.1) is

   z  =

    -1.0001886
    -1. + 0.0001886i
    -1. - 0.0001886i
    -0.9998114

It should be something closer to

    -1.
    -1.
    -1.
    -1.

Using these roots

C = coeff((p-z(1))*(p-z(2))*(p-z(3))*(p-z(4)))

yield seemingly accurate coefficients
   C  =

     1.   4.   6.   4.   1.


but

C - [1  4  6 4 1]

shows the actual error:

ans  =

     3.775D-15   1.243D-14   1.155D-14   4.441D-15   0.

This is acceptable for the coefficients, but the error in the roots is
too large. Somehow the errors cancel out when  assembling back the
polynomial but each individual zero should be closer to the theoretical
value

Is there some way to improve the accuracy?

Regards,

Federico Miyara




---
El software de antivirus Avast ha analizado este correo electrónico en busca de virus.
https://www.avast.com/antivirus

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users




Libre de virus. www.avast.com

_______________________________________________
users mailing list
[hidden email]
https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users


-- 
Stéphane Mottelet
Ingénieur de recherche
EA 4297 Transformations Intégrées de la Matière Renouvelable
Département Génie des Procédés Industriels
Sorbonne Universités - Université de Technologie de Compiègne
CS 60319, 60203 Compiègne cedex
Tel : +33(0)344234688
http://www.utc.fr/~mottelet

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
fmiyara fmiyara
Reply | Threaded
Open this post in threaded view
|

Re: improve accuracy of roots

Stéphane,

Thank you very much for your contribution!

Best regards,

Federico Miyara


On 15/01/2019 14:14, Stéphane Mottelet wrote:
Hello,

After a quick search on the internet I have found and translated in Scilab "multroot", a Matlab Package computing polynomial roots and multiplicities. If you are interested proceed to this url: http://bugzilla.scilab.org/show_bug.cgi?id=15349#c9

Enjoy !

S.

Le 14/01/2019 à 21:07, Federico Miyara a écrit :

Denis,

What I meant is that convergence is a limiting process. On average, as the number of iterations rises you´ll be closer to the limit, bu there is no guarantee that any single iteration will bring you any closer; it may be a question of luck. Maybe (though it would require a proof, it is not self-evident for me) in the exact case of a single multiple root as (x - a)^n the convergence process is monotonous, but what if you have (x - a1)* ... * (x  - an) where ak are all very similar but not identical, say, with relative differences of the order of those reported by the application of the regular version  of roots.    
Regards,

Federico Miyara


On 14/01/2019 13:47, CRETE Denis wrote:
Thank you Frederico!
According to the page you refer to, the method seems to converge more rapidly with this factor equal to the multiplicity of the root. 
About overshoot, it is well known to occur for |x|^a where a <1. But for a>1, the risk of overshoot with the Newton-Raphson method seems to be very small...
Best regards
Denis 

[@@ THALES GROUP INTERNAL @@]

Unité Mixte de Physique CNRS / THALES
1 Avenue Augustin Fresnel
91767 Palaiseau CEDEx - France
Tel : +33 (0)1 69 41 58 52 Fax : +33 (0)1 69 41 58 78 
e-mail : 
 [hidden email] [hidden email]
 http://www.trt.thalesgroup.com/ump-cnrs-thales
 http://www.research.thalesgroup.com


-----Message d'origine-----
De : users [[hidden email]] De la part de Federico Miyara
Envoyé : samedi 12 janvier 2019 07:52
À : Users mailing list for Scilab
Objet : Re: [Scilab-users] improve accuracy of roots


Denis,

I've found the correction here,

https://en.wikipedia.org/wiki/Newton%27s_method

It is useful to accelerate convergence in case of multiple roots, but I 
guess it is not valid to apply it once to improve accuracy because of 
the risk of overshoot.

Regards,

Federico Miyara


On 10/01/2019 10:32, CRETE Denis wrote:
Hello,
I tried this correction to the initial roots z:

z-4*(1+z).^4 ./([ones(z),z,z.^2,z.^3]*(C(2:5).*(1:4))')
  ans  =

   -1. - 1.923D-13i
   -1. + 1.189D-12i
   -1. - 1.189D-12i
   -1. - 1.919D-13i

// Evaluation of new error, (and defining Z as the intended root, i.e. here Z=-1):
z2=z-4*(z-Z).^4 ./([ones(z),z,z.^2,z.^3]*(C(2:5).*(1:4))')
z2 - Z
  ans  =

    2.233D-08 - 1.923D-13i
   -2.968D-08 + 1.189D-12i
   -2.968D-08 - 1.189D-12i
    2.131D-08 - 1.919D-13i

The factor 4 in the correction is a bit obscure to me, but it seems to work also for R=(3+p)^4, again with an accuracy on the roots of a ~2E-8.

HTH
Denis

-----Message d'origine-----
De : users [[hidden email]] De la part de Federico Miyara
Envoyé : jeudi 10 janvier 2019 00:32
À : [hidden email]
Objet : [Scilab-users] improve accuracy of roots


Dear all,

Consider this code:

// Define polynomial variable
p = poly(0, 'p', 'roots');

// Define fourth degree polynomial
R = (1 + p)^4;

// Find its roots
z = roots(R)

The result (Scilab 6.0.1) is

   z  =

    -1.0001886
    -1. + 0.0001886i
    -1. - 0.0001886i
    -0.9998114

It should be something closer to

    -1.
    -1.
    -1.
    -1.

Using these roots

C = coeff((p-z(1))*(p-z(2))*(p-z(3))*(p-z(4)))

yield seemingly accurate coefficients
   C  =

     1.   4.   6.   4.   1.


but

C - [1  4  6 4 1]

shows the actual error:

ans  =

     3.775D-15   1.243D-14   1.155D-14   4.441D-15   0.

This is acceptable for the coefficients, but the error in the roots is
too large. Somehow the errors cancel out when  assembling back the
polynomial but each individual zero should be closer to the theoretical
value

Is there some way to improve the accuracy?

Regards,

Federico Miyara




---
El software de antivirus Avast ha analizado este correo electrónico en busca de virus.
https://www.avast.com/antivirus

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users




Libre de virus. www.avast.com

_______________________________________________
users mailing list
[hidden email]
https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users


-- 
Stéphane Mottelet
Ingénieur de recherche
EA 4297 Transformations Intégrées de la Matière Renouvelable
Département Génie des Procédés Industriels
Sorbonne Universités - Université de Technologie de Compiègne
CS 60319, 60203 Compiègne cedex
Tel : +33(0)344234688
http://www.utc.fr/~mottelet


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users