julia

How can you perform this improper integral as Mathematica does?

此生再无相见时 提交于 2020-01-21 09:01:49
问题 Take this Mathematica code: f[x_] := Exp[-x]; c = 0.9; g[x_] := c*x^(c - 1)*Exp[-x^c]; SetPrecision[Integrate[f[x]*Log[f[x]/g[x]], {x, 0.001, \[Infinity]}],20] Mathematica computes this without problem and gives the answer 0.010089328699390866240 . I would like to be able to perform similar integrals but I don't have a copy of Mathematica. Just naively implementing it in scipy, for example, using a standard quadrature library fails sadly because f(x) and g(x) get arbitrarily close to 0. Here

What should path be to Julia source file?

ⅰ亾dé卋堺 提交于 2020-01-17 13:48:09
问题 I have a .jl file at /Users/myuser/Documents/JuliaLearn/Julia/mysource.jl In Julia Repl, I'm trying to run as: include("/Users/myuser/Documents/JuliaLearn/Julia/mysource.jl") But get this error: ERROR: could not open file /Users/myuser/~/Documents/JuliaLearn/Julia/mysource.jl in include at /Applications/Julia-0.4.5.app/Contents/Resources/julia/lib/julia/sys.dylib in include_from_node1 at /Applications/Julia-0.4.5.app/Contents/Resources/julia/lib/julia/sys.dylib I also tried but get an error

What mistake did I make in this matrix multiplication in Julia?

穿精又带淫゛_ 提交于 2020-01-17 02:16:49
问题 In Julia: In [1]: M1 = [1 3 4; 45 64 33; 456 3 454;] Out [1]: 3x3 Array{Int64,2}: 1 3 4 45 64 33 456 3 454 In [2]: M1 * inv(M1) Out [2]: 3x3 Array{Float64,2}: 1.0 6.93889e-18 -8.67362e-19 0.0 1.0 -2.08167e-17 -1.42109e-14 -8.88178e-16 1.0 M1 * inv(M1) is supposed to get the Identity matrix by definition. What's wrong? I tried the same thing in Matlab: >> M1 = [1 3 4; 45 64 33; 456 3 454;] M1 = 1 3 4 45 64 33 456 3 454 >> inv(M1) ans = -0.280088987764182 0.013057987135465 0.001518595540939 0

What mistake did I make in this matrix multiplication in Julia?

落花浮王杯 提交于 2020-01-17 02:15:32
问题 In Julia: In [1]: M1 = [1 3 4; 45 64 33; 456 3 454;] Out [1]: 3x3 Array{Int64,2}: 1 3 4 45 64 33 456 3 454 In [2]: M1 * inv(M1) Out [2]: 3x3 Array{Float64,2}: 1.0 6.93889e-18 -8.67362e-19 0.0 1.0 -2.08167e-17 -1.42109e-14 -8.88178e-16 1.0 M1 * inv(M1) is supposed to get the Identity matrix by definition. What's wrong? I tried the same thing in Matlab: >> M1 = [1 3 4; 45 64 33; 456 3 454;] M1 = 1 3 4 45 64 33 456 3 454 >> inv(M1) ans = -0.280088987764182 0.013057987135465 0.001518595540939 0

Generate DifferentialEquations ifrom a vector in Julia

你说的曾经没有我的故事 提交于 2020-01-16 08:40:34
问题 I have created a vector which concatenates strings of differential equations that are in the correct format to be used be the differeq ode sovler in Julia (i.e, f(du,u,p,t): Combine <- c("du[1] = - 1*0.4545*(u[1]^1) - 1*27000000*(u[4]^1)*(u[1]^1)", "du[2] = - 1*3100000000*(u[2]^1)*(u[4]^1)", "du[3] = - 1*33000*(u[3]^1)*(u[4]^1)", "du[4] =2*0.4545*(u[1]^1) - 1*3100000000*(u[2]^1)*(u[4]^1) - 1*33000*(u[3]^1)*(u[4]^1) - 1*27000000*(u[4]^1)*(u[1]^1) - 1*8500000*(u[4]^1)*(u[5]^1) - 1*390000000*(u

Julia:passing argument to the `include(“file.jl”)`

大憨熊 提交于 2020-01-15 06:56:18
问题 I was wondering if it is possible to pass arguments to include("file.jl") . For example we parse the ARGS in the file.jl and use them in there. Similar to what we do in a command line by passing arguments. 回答1: Reassigning ARGS to make file.jl think it received arguments works, but leads to a warning (because it overwrites Base.ARGS ). A better methods perhaps is to use isdefined to check for a different source of parameters before using ARGS in file.jl . For example, file main.jl would be:

Julia:passing argument to the `include(“file.jl”)`

删除回忆录丶 提交于 2020-01-15 06:56:11
问题 I was wondering if it is possible to pass arguments to include("file.jl") . For example we parse the ARGS in the file.jl and use them in there. Similar to what we do in a command line by passing arguments. 回答1: Reassigning ARGS to make file.jl think it received arguments works, but leads to a warning (because it overwrites Base.ARGS ). A better methods perhaps is to use isdefined to check for a different source of parameters before using ARGS in file.jl . For example, file main.jl would be:

Get rid of Julia's `WARNING: redifining constant` for strings that are not changed?

*爱你&永不变心* 提交于 2020-01-15 04:49:08
问题 In my julia code I am using some constants. Some of these constants are strings (they serve as identifiers). My issues is that whenever I run a julia script, I always get the following warning for constant strings, even when I do not change the constants : WARNING: redefining constant pot_type To illustrate my problem, here is a MWE: const pot_type = "constant" const b = 12 println("Given parameters: Potential = $pot_type, b = $b .") If I run this script two times, I will get the

IJulia install - WARNING: Module BinDeps uuid did not match cache file

那年仲夏 提交于 2020-01-15 03:22:19
问题 After running Pkg.update() I ran into the following error message regarding IJulia installation: WARNING: Module BinDeps uuid did not match cache file ===============================[ ERROR: IJulia ]================================ LoadError: __precompile__(true) but require failed to create a precompiled cache file while loading /home/om/.julia/v0.4/IJulia/deps/build.jl, in expression starting on line 2 ================================================================================ ========

scope of julia variables: re-assigning within a loop in open expression

回眸只為那壹抹淺笑 提交于 2020-01-15 03:16:09
问题 I am struggling with re-assigning a variable in a loop in Julia. I have a following example: infile = "test.txt" feature = "----" for ln in 1:3 println(feature) feature = "+" end open(infile) do f #if true # println(feature) # feature = "----" println(feature) for ln in 1:5 #eachline(f) println("feature") #fails here println(feature) # because of this line: feature = "+" end end It fails if I do reassignment within the loop. I see that the issue with the variable scope, and because nested