I want to solve the following equation: log(log(y))=1/(x**2), and I want to get y as a function of x. How can I make a program in phyton in order to to this?
Thank you in advance!
By rearrangement, y = exp(exp(x ** -2)) will do it.
Note that this is a very strong function of x. Are you sure your starting equation is correct? (The log10 log10 of the number of particles in the universe is less than 2).
Related
So I have this analytically unsolvable non-linear second order differential equation:
x''=(-1/x)((x')²+gx-gh+ax')
to which I've been trying to apply the Runge-Kutta method in Octave for a while without getting good results. This is the code I've been using:
graphics_toolkit('gnuplot')
to=0
tf=2.8
N=150
dt=[tf-to]/N
b=2.65
g=9.81
h=0.07
y(1)=0.015
z(1)=0
t(1)=to
for i=1:N-1
y(i+1)= y(i) - dt.*z(i)
z(i+1)= z(i) - dt.*[z(i).**2 + g.*y(i) - g.*h + b.*z(i)]./y(i)
t(i+1)= t(i) + dt
endfor
plot(y,t)
title=('Numerical solution')
xlabel=('Time')
ylabel=('Position')
Frankly, I'm unable to tell where the issue is, maybe there's something about the method I'm not getting, or maybe is my code missing something important.
Thanks for your time and attention.
The realization of
y' = z
in the Euler method is
y(i+1)= y(i) + dt.*z(i)
note the addition instead of the subtraction.
The problem is as follows: obtain the function H = X + Y using only
You cannot use the complements of X and Y as inputs. Use as few of these logic gates as possible.
I eventually figured out the answer to be
but that was through trial and error. Is there a good way of solving this and similar problems?
I am using SCIP with ZIMPL to solve an optimization problem where I want to "punish" a solution for which variable x < k, with k being a parameter.
I do not want to exclude all solutions where this is the case. Therefore, I introduced variable y= x-k and want to add a penalty term to my objective value, but only if y is negative, as I don't want to punish a solution if x>k.
Adding -(min(y,0)) should do the trick, but I got the feeling that all functions and operations in ZIMPL such as the min - function (listed in Table 2 and 3 on p. 7 of the ZIMPL documentation) can only be aplied to parameters.
Can someone confirm that? And if yes, does anyone maybe have an idea how I can implement a kind of penalty term that only punishes the negative part of variable y in ZIMPL?
PS: Sorry for the misleading tag #scip, as it is a clear ZIMPL related problem. But unfortunatelly there was no existing tag #zimpl.
Yes, you can't use this kind of operators with variables (it wouldn't be a MILP anymore). However, why don't you model it like y1 - y2 = x-k with y1 >= 0 and y2 >= 0 and then put y2 into the objective function?
I guess I don't know enough about this Majority function to wrap my head around it... I just don't know where to begin with this. I'm no pro Verilog yet lol
It's defined as a function of x, y, and z, so I'm thinking the function would be a function of three binary input bits. Beyond that I'm lost.
Any help/direction appreciated.
In boolean terms, a majority gate is true if more than half it's inputs are true. https://en.wikipedia.org/wiki/Majority_function
If you think about it those simple terms than the 3 input example is fairly simple. There are only 3 situations that will result in a true.
(X AND Y) OR (Y AND Z) OR (X AND Z)
You may want to extend that to an arbitrary number of inputs and that is what the equation is for. My verilog is fairly rusty so I don't remember right off but I think that you can do that kind of math with binary inputs if you so choose.
I am having some problem about calculating the FWHM of my data. Because the "fwhm" function in signal package results in a 100 times bigger value than i expected to get.
What i did is that,
Depending on the gaussian distribution function (you can find it on wikipedia) I produced some data. In this function you can give a specific sigma (RMS) value (FWHM=sigma*2.355). Here is that the script I wrote to understand the situation
x=10:0.01:40;
x0=25;
sigma=0.25;
y=(1/(sigma*sqrt(2*pi)))*exp(-((x-x0).^2)/(2*sigma^2));
z=fwhm(y)/2.355;
plot(x,y)
when I compared the results the output of "fwhm" function (24.999) is 100 times bigger than the one I used (0.25) in the function.
If you have any idea it will be very helpful.
Thanks in advance.
Your z is 100 times bigger because your steps in x are 1/100 (0.01). If you use fwhm(y) it is expected that the stepsize in x is 1. If not you have to specify that.
In your case you should do:
z=fwhm(x, y)/2.355
z = 0.24999
which matches your sigma