differential equation by maxima - differential-equations

I am new in maxima, so I am really sorry if I ask simple question. I have a differential equation,
(%i1) -(x-x/2*sinh(x/2)+'diff(y,x))*(1/y+'diff(y,x)*x/y^2)+(x-x^2/sinh(x/2)+x^2*cosh(x/2)/(4*(sinh(x/2))^2)+'diff(y,x)*x+'diff(y,x,2)*x^2)/y+y^2-1-0.9*(x-x^2/(2*sinh(x/2)))=0;
2 x
2 2 x cosh(-)
2 d y dy x 2
x --- + x -- - ------- + ---------- + x
2 dx x 2 x
dx sinh(-) 4 sinh (-)
2 2
(%o1) ----------------------------------------
y
x dy
x sinh(-) x -- 2
dy 2 dx 1 2 x
+ (- -- + --------- - x) (---- + -) + y - 0.9 (x - ---------) - 1 = 0
dx 2 2 y x
y 2 sinh(-)
2
(%i2) ode2(%,y,x);
rat: replaced -0.9 by -9/10 = -0.9
(%o2) false
what should I do?

The equation you have is nonlinear. Maxima's ode2 can only solve a limited variety of differential equations, and it appears your equation doesn't fall into any of the categories it can handle.
I don't know if there is another symbolic diff eq solver in Maxima that you can try. If a numerical solution is enough, take a look at rk (a Runge-Kutta implementation).

Related

Linear constraints for nonlinear variable relationship

Assume a mathematical optimization problem with two positive continuous variables:
0 <= x <= 1
0 <= y <= 1000
I am seeking of an efficient way to express in form of linear constraints (possibly with the use of binary/integer variables and big M) the following nonlinear relationship, so the problem can be solved with milp solvers:
when 0 <= y < 200 then x = 0
when y = 200 then 0 <= x <= 1
when 200 < y <= 1000 then x = 1
The numbers 200 and 1000 are indicative.
Are there any direct suggestions or papers/books addressing similar problems?
I think this will work...
Here's how I think of this. You have 3 states that you need to be aware of, which are the 3 partitions on the domain of y. So, 2 binary variables can capture these 3 states. In order to keep things linear, you will need to work with non-strict inequalities. So define:
y_lb ∈ {0, 1} and let y_lb = 1 if y >= 200
y_ub ∈ {0, 1} and let y_ub = 1 if y <= 1000
so now we have our partitions set up in terms of a truth table for y_lb and y_ub:
y y<200 200<=y<=1000 y>1000
y_lb 0 | 1 | 1
y_ub 1 | 1 | 0
Now we can easily link that truth table to constrain x:
x ∈ Reals
x <= y_lb
x >= 1 - y_ub

Guidance needed | Optimization challenge. Would love to get some inputs 🙏🏻

I need some guidance on how to approach for this problem. I've simplified a real life example and if you can help me crack this by giving me some guidance, it'll be awesome.
I've been looking at public optimization algorithms here (https://www.cvxpy.org/) but I'm a noob and I'm not able to figure out which algorithm would help me (or if I really need it).
Problem:
x1 to x4 are items with certain properties (a,b,c,y,z)
I have certain needs:
Parameter My Needs
a 150
b 800
c 80
My goal is get all optimal coefficient sets for x1 to x4 (can be
fractions) so as to get as much of a, b and c as possible to satisfy
needs from the smallest possible y.
These conditions must always be met:
1)Individual values of z should stay within threshold (between maximum and minimum for x1, x2, x3 and x4)
2)And Total y should be maintained within limits (y <=1000 & y>=2000)
To illustrate an example:
x1
Each x1 has the following properties
a 20 Minimum z 10 Maximum z 50
b 200
c 0
y 300
z 20
x2
Each x2 has the following properties
a 30 Minimum z 60 Maximum z 160
b 5
c 20
y 50
z 40
x3
Each x3 has the following properties
a 20 Minimum z 100 Maximum z 200
b 200
c 15
y 200
z 40
x4
Each x4 has the following properties
a 5 Minimum z 100 Maximum z 300
b 30
c 20
y 500
z 200
One possible arrangement can be (not the optimal solution as I'm trying to keep y as low as possible but above 1000 but to illustrate output)
2x1+2x2+1x3+0.5x4
In this instance:
Coeff x1 2
Coeff x2 2
Coeff x3 3
Coeff x4 0.5
This set of coefficients yields
Optimal?
total y 1550 Yes
total a 162.5 Yes
total b 1025 Yes
total c 95 Yes
z of x1 40 Yes
z of x2 80 Yes
z of x3 120 Yes
z of x4 100 Yes
Lowest y? No
Can anyone help me out?
Thanks!

Hive impala query

Input.
Key---- id---- ind1 ----ind2
1 A Y N
1 B N N
1 C Y Y
2 A N N
2 B Y N
Output
Key ind1 ind2
1 Y Y
2 Y N
So basically whenever the ind1..n col is y for same key different id . The output should be y else N.
That why for key 1 both ind is y
And key 2 ....ind is y and n.
You can use max() for this:
select id, max(ind1), max(ind2)
from t
group by id;

Currying a function with a variable in J

I can create a function that multiplies by 2 with 2&\*, and indeed 20 = (2&\*)10
What I want to do is create a factory-function that makes these to order.
So, I want a monad f s.t. ( f y ) x == (y * x )
whilst (\*& 2) 3 works ((\*&) 2) 3 doesn't, so trying explicitly:
(3 : 'y&*') 2 produces a syntax error.
Where am I going wrong ?
A verb that creates a verb is actually an adverb1 in J:
f =: 1 : 'm&*'
2 f
2&*
(2 f) 5
10
(i.10)f 5
0 5 10 15 20 25 30 35 40 45
or tacitly:
f =: &*
2 f
2&*
h =: 3 :'...' won't work because that produces a verb and then h y wants to be a noun.
g =: 4 :'x&* y' is fine and equivalent to f.
[1]: or a conjunction

Difficulties understanding variable reassignment in Lisp

I'm facing some problems understanding the results of a few experiments with nconc.
(setf x '(a b c))
(setf y '(1 2 3))
(nconc x y) ; => x = (A B C 1 2 3), y = (1 2 3)
From what I've read, nconc changes the rest field of x to point to y.
(setf (nth 1 y) 10) ; => x = (A B C 1 10 3), y = (1 10 3)
So far, so good.
(setf y '(4 5 6)) ; => x = (A B C 1 10 3) y = (4 5 6)
Why does x still reference to the old cons cell, or in other words does the reassignment of y not just change the data at the address of y?
Thanks in advance
Michael
Lisp variables don't point to fixed memory. They point to Lisp data objects. Setting a variable does not change any object memory. The variable just points to some other data.
Because the last cons in x is set to pointing to the cons that y was pointing at. It doesn't point at y's value dynamically or by reference.
(setf x '(a b c))
; x = (a b c)
(setf y '(1 2 3))
; x = (a b c)
; y = (1 2 3)
(nconc x y)
; x = (a b c 1 2 3)
; y = (1 2 3) = (nthcdr 3 x)
(setf (nth 1 y) 10)
; x = (a b c 1 10 3)
; y = (1 10 3) = (nthcdr 3 x)
(setf y '(4 5 6))
; x = (a b c 1 10 3)
; y = (4 5 6)
nconc changes the rest field of x to point to the value of y. The value y is the cell, which y points to. If you move the y pointer to another target, the rest field of x won't change, and will still point to (1 2 3).