Ask Your Question

JonasA's profile - activity

2024-02-10 23:46:19 +0200 received badge  Famous Question (source)
2022-12-31 12:30:19 +0200 received badge  Notable Question (source)
2022-12-31 12:30:19 +0200 received badge  Popular Question (source)
2020-03-16 14:54:52 +0200 asked a question Strange behaviour with distributivity of multiplication

I got the following code wich is not consistent. There should be a bug in there. The priority of the parenthesis is not respected in the first case.

 sage: version()                                                                                                                                                                                                                               
'SageMath version 9.0, Release Date: 2020-01-01'
sage: ....: Qpart(x) =5*( unit_step(x)   
....: ....:     * sin(x )  -  
....: ....:     sin(x))                                                                                                                                                                                                                       
sage: Qpart                                                                                                                                                                                                                                   
x |--> 5*sin(x)*unit_step(x) - sin(x)
sage: ....:5*( unit_step(x)   
....: ....:     * sin(x )  -  
....: ....:     sin(x))                                                                                                                                                                                                                       
5*sin(x)*unit_step(x) - 5*sin(x)
2020-03-12 14:07:01 +0200 commented answer How to solve numericaly with arbitrary precision

Dichotomy solve the problem although my function is too much unsmooth to be used so I will stop trying. My function was taking those value: (f(37) was returning 0, but when I used a better resolution it was more 1e67)

sage: f(36.99)
-1.0936253623915059621862511135588106826765847154466062182129e99
sage: f(36.999)
1.0936253623915059621862511135588106826765847154466062182129e99
sage: f(36.99999)
-5.4681268119575298109312555677940534133829235772330310910644e98
sage: f(36.9999999)
5.4681268119575298109312555677940534133829235772330310910644e98
sage: f(36.999999999)
-1.6404380435872589432793766703382160240148770731699093273193e99
2020-03-12 14:02:54 +0200 received badge  Scholar (source)
2020-03-12 13:39:55 +0200 received badge  Supporter (source)
2020-03-11 10:55:56 +0200 received badge  Student (source)
2020-03-09 17:19:29 +0200 received badge  Editor (source)
2020-03-09 17:13:21 +0200 commented answer How to solve numericaly with arbitrary precision

So

sage: x=var('x')
sage: M= Matrix(SR,[[cos(x),cosh(x)],[sin(x),sinh(x)]])
sage: RRR = RealField(200)

Then

 sage: f = lambda om: RRR(M.subs({x:om}).change_ring(RRR).det())

gives f a very long runtime, find_root don't converge on a reasonable time and

sage: f = lambda om: M.subs({x:om}).change_ring(RRR).det()
sage: find_root(f,1,2)

while f has a much faster runtime, throw an exception

2020-03-09 17:11:11 +0200 commented answer How to solve numericaly with arbitrary precision

Thank you for answering. I have a matrix of hyperbolic and trigonometric function of a variable, I want to know for which values of the variable the matrix is singular. It is analog to the physics problem of knowing the natural frequencies of an oscillator. Although my matrix is not very dense, it is dense enough so that the determinant can't be computed in the symbolic ring. I have to use a lambda function to substitute de variable by its value, change the matrix to the real ring then compute the determinant (the computation of the determinant is too slow if I stay in the symbolic ring). Which is the lambda function I write on my first message with RRR a custom Real Field with 200 bits precision.

A code example will follow in the next message

2020-03-09 14:46:04 +0200 asked a question How to solve numericaly with arbitrary precision

Hello,

I want to solve a numerical equation for which I can only access by a lambda function, the M matrix is to big for the determinant to be computed on the symbolic ring.

f = lambda om: RRR(M.subs({omega:om}).change_ring(RRR).det())

But , find-root solve in the built in float type of Python which is lacking the precision I need. Is there a way in sage to solve numericaly with arbitrary precision?

Thank you

Regards

(edited with example more in line with what I am trying to achieve)

sage: x=var('x')
sage: M= Matrix(SR,[[cos(x),cosh(x)],[sin(x),sinh(x)]])
sage: RRR = RealField(200)
sage: f = lambda om: M.subs({x:om}).change_ring(RRR).det()
sage: find_root(f,1,2)