Community RSS Feed
http://community.wolfram.com
RSS Feed for Wolfram Community showing any discussions in tag Wolfram Scienceshowthread.php?threadid=78 sorted by activePlot in OblateSpheroidal coordinate system?
http://community.wolfram.com/groups/-/m/t/1132374
I wanted to produce a plot in OblateSpheroidal coordinate system. Since there is no such function in Mathematica, I tried to do coordinate transformation to Spherical Coordinate follow by a plot using SphericalPlot3D . I want to plot an ellipse and hyperbola of revolution as the image below. But the code just plots a sphere.
![enter image description here][1]
fromOblatetoSpherical =
CoordinateTransformData[{{"OblateSpheroidal", 1}, 3} -> "Spherical",
"Mapping"];
CoordinateChartData[{{"OblateSpheroidal", {\[FormalA]}}, "Euclidean",
3}, "StandardCoordinateNames"]
sph = fromOblatetoSpherical@%
sph2 = Simplify[sph /. x_String :> ToExpression[x]]
SphericalPlot3D[
sph2[[1]] = #/5, {\[Eta], 0, 3 Pi/4}, {\[CurlyPhi], 0, 2 Pi},
PlotStyle ->
Directive[Orange, Opacity[0.7], Specularity[White, 10]],
PlotRange -> All, ImageSize -> Small, Mesh -> None,
PlotPoints -> 50] & /@ {-1, 3, 6, 8, 12}`
[1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ObaltedSpheroid.png&userId=120134Jose Calderon2017-07-01T20:26:26ZResourceSearch[] Error about CreateDirectory[]
http://community.wolfram.com/groups/-/m/t/1154600
Hi. I was using ResourceSearch[], but encountered this error:
In[1]= resources = ResourceSearch["Machine Learning"]
Out[1]=
CreateDirectory::privv: Privilege violation for file or directory C:\Users\ed\[PlusMinus]ӜAppData.
Put::noopen: Cannot open C:\Users\ed\[PlusMinus]ӜAppData\Roaming\Wolfram\Objects\Resources\69f\69f1e629-81e6-4eaa-998f-f6734fcd2cb3\metadata\object.wl.
What is causing this problem? Thank you,Michael Jang2017-07-28T01:09:28ZWho Else thinks this kind of Visualization of CAs is cool!
http://community.wolfram.com/groups/-/m/t/1154438
Column[ArrayPlot[{#}, ImageSize -> Medium] & /@
CellularAutomaton[30, {{1}, 0}, 20]]
![enter image description here][1]
[1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=frequencyview.PNG&userId=598890Jackreece Ejini2017-07-28T07:42:07ZThe Kolakoski Sequence
http://community.wolfram.com/groups/-/m/t/1154374
The Kolakoski Sequence was recently in the news. It starts out as
12211212212211211221211212211211212212211212212112112212211212212211211212212112212211212212211211221211212212211211212
n = 10; ko = Prepend[Nest[Flatten[Partition[#, 2] /.
{{2, 2} -> {2, 2, 1, 1}, {2, 1} -> {2, 2, 1}, {1, 2} -> {2, 1, 1}, {1, 1} -> {2, 1}}] &, {2, 2}, n], 1];
Try doing Length /@ Split[ko] on that, and you get the same sequence. It is self-descriptive. I bumped the code up to n=32 to get 1058436 terms. What is the behavior of 1 and 2 over that range?
ListPlot[FoldList[Plus, 0, 2 (ko - 3/2)], Joined -> True, AspectRatio -> 1/7]
![Kolakowski sequence][1]
Seems pretty chaotic.
[1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=kolakowski.jpg&userId=21530Ed Pegg2017-07-27T22:13:10ZWorking with the Water and Steam Thermodynamic and Transport Prop. archive
http://community.wolfram.com/groups/-/m/t/1154651
Hello,
I am trying to connect the "Water and Steam Thermodynamic and Transport Properties
" archive, which is written in C, with my Mathematica Code. This archive can be found in the Wolfram Library Archive.
There are two files available for download but none of them includes some instructions how to work with them so I tried it by myself.
Until now i was not able to make it runnable. I created several errors with the result that i had to rewrite the C-Code in several lines and files.
Since I do not belive that it should be necessary to rewrite the entire C-Code i wanted to ask you if someone has alredy worked with this archive ore if anybody has some clues for me, how i should proceed?
Thanks in advance for your help.Moritz Pallua2017-07-28T09:09:29ZHow to obtain all Options[] for a graphic?
http://community.wolfram.com/groups/-/m/t/1154087
I have this simple graphic for which I want to list out all of the options including
`ViewCenter` and `ViewVertical`. But `Options[%]` (after generating the graphic) only emits
{Boxed -> True, Lighting -> "Neutral"}
Why?
The generating command is:
Graphics3D[{
EdgeForm[], Specularity[White, 10]
, FaceForm[Red], Sphere[{-0.2, -0.1, -0.3}, .2]
, FaceForm[Blue], Cylinder[{{0., 0.3, -0.5}, {0., 0.3, 0.}}, 0.1]
, FaceForm[Green], Cone[{{0.2, 0., -0.5}, {0.2, 0., -0.1}}, 0.2]
}, Boxed -> True, Lighting -> "Neutral"
]
Thanks in advance for your help.Aeyoss Antelope2017-07-27T15:26:31ZHow to Plot f(A^2) in Y axis and A^2 in x axis
http://community.wolfram.com/groups/-/m/t/1154051
I have the following function
F(A^2)= G (1 - A^2/4 + \[Alpha] A^4/8 - 5 \[Gamma] A^6/64) - d
I want to plot this in Y axis and X axis should be A^2. Please help me in this regard.Here
\[Alpha] = 0.114;
\[Gamma] = 0.003;G = 0.1;d = 0.2;Dia Ghosh2017-07-27T10:36:52ZWays to access elements of a list or an array
http://community.wolfram.com/groups/-/m/t/1142765
Dear All,
For your information only.
A code to access elements of a list or an array.
Grid[{
{"Description\n\nUsage with:\nmatx={{2,3,5},{7,11,13},{17,19,23}},\n\
b={6,1,8,-4}", "Mathematica function", "Expression", "Output"}
, {"Select an element", " - ", "b[{3]]\nmatx[[2,3]]", "8\n13"}
, {"Select a row", " - ", "matx[[2]]", "{7,11,13}"}
, {"Select a column", " - ", "matx[[All,1]]", "{2,7,17}"}
, {"Select a submatrix", " - ", "matx[[2;;3,1;;2]]",
"{{7,11},{17,19}"}
, {"Select the first element", "First[list]", "First[b]", "6"}
, {"Select the last element", "Last[list]", "Last[b]", "-4"}
, {"Select the first row", "First[mat]", "First[matx]", "{2,3,5}"}
, {"Select the last row", "Last[mat]", "Last[matx]", "{17,19,23}"}
, {"Take the first n elements of a list", "Take[list,n]",
"Take[b,2]", "{6,1}"}
, {"Take the last n elements of a list", "Take[list,-n]",
"Take[b,-2]", "{8,-4}"}
, {"Take the nth to kth elements of a list", "Take[list,{n,k}]",
"Take[b,{2,4]", "{1,8,-4}"}
}
, Alignment -> Left
, Frame -> {{Red}, {Red}}
, Background -> {{Lighter[Yellow, .9]}, {Lighter[Yellow, .9]}, None}
, Spacings -> {3, 2}
, Dividers -> All
, ItemStyle -> Directive[FontSize -> 16, Bold]
, FrameStyle -> Thick]
Print[Style[
"mat = array of mXm elements,m > 1\nlist = list of m elements\nn, k \
= integer", 18, Red, Bold]]
![enter image description here][1]
[1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Select-Take.jpg&userId=185016
Cheers,.....JosJos Klaps2017-07-09T21:54:08ZHelp for Machine Learning and Neural Network
http://community.wolfram.com/groups/-/m/t/1154350
(Sorry if there are mistakes, I'm not English)
Hello everyone, I'm a student which come in a stage in the British Wolfram, and we have to make a little project on the 2 last days. Me and my friend we had the idea to create a very little game : a red point at the centre of a square need to move and eat other green points, and we wanted to build a neural network for that the computer learn how to play, the only problem is that, because of the recent update to Mathematica 11, we don't really know how to use the functions for build a neural network. If someone can help us to understand what functions we should use and in which order, it will help us a lot.
Thank you in advance.Mathieu DEGRE2017-07-27T14:15:37ZError code 702 on launch of Mathematica (Windows 10)
http://community.wolfram.com/groups/-/m/t/917946
Hello
I am testing Mathematica on Windows 10 and I am seeing the following error:
A serious error has occurred while Mathematica was starting up. Mathematica will probably not function properly until this problem is resolved. You may choose to continue anyway, but Mathematica may crash or exit without warning.
------------------------------
The installation of Mathematica may be corrupted. Contact Techincal Support or visit... for more information.
Error Code: 702.
I am not given the option to continue anyway - only the option to Quit.
I have submitted this information over a week ago to Mathematica but have not received a response - not even an auto-response, not sure if this is normal or not?
Has anyone else encountered this error or similar before - any advice?
I do not see the same error when using the same installation on Windows 7.
Many thanks
SarahSarah B2016-09-02T09:27:55ZWhat is the most efficient export/import format for persisting data?
http://community.wolfram.com/groups/-/m/t/1153585
I exported a List from a Mathematica 11.1.1.0 Notebook to .wdx format. Since this format is native to Mathematica and intended for data, I had expected it to be the most performant option, with fast export and import times and maintaining exaction resolution of numerics. Unfortunately, the load time to read the .wdx for a moderate size List was over an hour. The List holds a rectangular structure with 24,000 rows and 11,000 columns.
Is .wdx really the best / fastest format for exporting data in a Mathematica variable and then loading it back into a new session?Donald Pellegrino2017-07-26T21:21:30Z[✓] Access an image in a System.Windows.Media.Imaging.CachedBitmap ?
http://community.wolfram.com/groups/-/m/t/1148854
I am trying to use a camera with a .NET interface. The code below seems like it may be capturing an image into a System.Windows.Media.Imaging.CachedBitmap object.
Any ideas how to access this from within Mathematica? Eventually, I will need a solution that runs quickly. Saving to disk using .NET and then reading the file into Mathematica would functionally give me what I need, but will be too slow.
Needs["NETLink`"];
InstallNET[];
LoadNETAssembly["C:\\XIMEA\\API\\x64"];
LoadNETType["xiApi.NET.xiCam"];
myCam = NETNew["xiApi.NET.xiCam"];
myCam@OpenDevice[0];
(*Start acquisition *)
myCam@StartAcquisition[];
timeouts = 1000;
myCam@GetImage[myImage, timeouts]
myCam@StopAcquisition[];
myImage
Output of last statement is:
« NETObject[System.Windows.Media.Imaging.CachedBitmap]»Jeff Burns2017-07-18T22:49:33ZRepresenting three dimensions of data on a 2D ListPlot
http://community.wolfram.com/groups/-/m/t/1153831
Is it possible to make a List Plot in which each point is colored based on the count of that point's `{x,y}` occurrence in the data set? Specifically, I have data of the form `data={{x1,y1}->c1, ... ,{xn,yn}->cn}` where `cn` is the nth count for the occurrence of `{xn,yn}` in the data set. I can almost get what I want in two ways:
Method 1:
ListPlot[{#1} & @@@ data,PlotMarkers -> cf /@ #2 & @@@ data]
where cf is my ColorDataFunction[], and I have neglected my plotting options for clarity.
Method 2:
ListPlot[{#1} & @@@ data,PlotStyle -> cf /@ #2 & @@@ data]
again where cf is my ColorDataFunction[], and I have neglected my plotting options for clarity.
For method 1, the rendered markers are large squares, and for method 2, the markers are automatically sized. In both cases, I loose control of marker size and shape customization.Jacob Lapenna2017-07-26T22:22:02ZMy Robots and Mathematica
http://community.wolfram.com/groups/-/m/t/1153218
Hi there, (Sharing an idea)
I am a hobbyist user of Mathematica. I am using it to control my three robot systems. Firstly there is Jeeves. It is a modified Meccano G15 KS. The Meccano control system has been removed and replaced with another control system (EZ-Robot). This new controller and its PC based control software is capable of starting an external program. In my case that external program is Mathematica. The sensors on the robot read in data and pass these data onto the PC based control software which then fires up Mathematica which in turn carries out some computation and passes a result back to the PC based control software. Data is stored in files. Using this set up means there can be latency. Sometimes quite a bit. For me this is not a problem as the robot is mainly used to test algorithms. Waiting a minute for a result is not an issue.
![Modified Meccano G15 KS][1]
This robot can read text from a sheet of paper or screen and then repeat what it has seen. It can also read text and evaluate it. For example given the question, “What is the capital of England” the robot will reply “London”. It can recognise objects in an image(potentially thousands). By reading in text similar to the following “AABBCCD”, it will play sounds relating to the musical notes. All this is made possible because of Mathematica. As stated above I use this robot for algorithm testing. In this case Mathematica is used indirectly.
My second robot is a small 16 DOF humanoid robot. This robot is controlled by a 24 channel Pololu Maestro servo controller.
![Modified EZ-Robot][2]
![Rear of modified EZ][3]
Now this robot is controlled directly by Mathematica. All code is contained in a notebook and uses all the features of connected devices contained within Mathematica. Data can be read from and sent to the robot. Just by using the Manipulate function every servo in the robot can be controlled by Mathematica. I have not done so at the moment but to create a robot animation system using Mathematica would only be a few dozen lines of code. That is one of my first tasks. This robot is a modified EZ-Robot now totally under the control of Mathematica.
My third robot is a robot workbench. Built by me to test more complex algorithms. This is controlled by a 24 channel Pololu Maestro servo controller. In turn controlled completely by, you guessed Mathematica.
![Robot Workbench 1][4]
![Robot Workbench 2][5]
![Robot Workbench 3][6]
![Robot Workbench 4][7]
![Robot Workbench 5][8]
The robot workbench only has a servo control program written at the moment. This control program makes use of the Manipulate function. I have some great plans for this workbench in the future. Under the control of Mathematica it will perform tasks using all the power of the neural networks and machine learning. Image and text processing. To name but a few.
My big goal is to create a Robot Operating System that will contain all the code required for the robots to carry out complex tasks. This would include features such as inverse and forward kinematics. I want to achieve this using only Mathematica.
[1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=20170722_204150%282%29.jpg&userId=1152078
[2]: http://community.wolfram.com//c/portal/getImageAttachment?filename=20170722_210215%282%29.jpg&userId=1152078
[3]: http://community.wolfram.com//c/portal/getImageAttachment?filename=20170722_210324%283%29.jpg&userId=1152078
[4]: http://community.wolfram.com//c/portal/getImageAttachment?filename=20170722_205616%282%29.jpg&userId=1152078
[5]: http://community.wolfram.com//c/portal/getImageAttachment?filename=20170722_205908%282%29.jpg&userId=1152078
[6]: http://community.wolfram.com//c/portal/getImageAttachment?filename=20170722_210128%283%29.jpg&userId=1152078
[7]: http://community.wolfram.com//c/portal/getImageAttachment?filename=20170722_204931%282%29.jpg&userId=1152078
[8]: http://community.wolfram.com//c/portal/getImageAttachment?filename=20170722_205445%282%29.jpg&userId=1152078Terence Smith2017-07-26T17:11:41Z[Conference] "Maths 4 Everyday Life" powered by the Wolfram Language
http://community.wolfram.com/groups/-/m/t/1150809
We will be organising a Wolfram Language Event in Aberdeen from 14th-19th August this year in close collaboration with Wolfram Europe. It is going to be en exciting event as we try to cover a huge range of applications of the Wolfram Language. We reach out to people from all walks of life: we ask pupils, teachers, academic and industrial researchers, people from various administrative areas and the city council, and laypersons to attend. We want to show how broadly applicable the Wolfram Language is and how relevant computational thinking is for all of us. We will cover typical areas where computational thinking is key, but also look at applications to arts, music and literature.
There will be two streams of events all week. One will be for absolute beginners, with no experience in programming or maths. The second one will be for users with either a maths/science or programming background. Experienced programmers both from Wolfram Europe and the University of Aberdeen will guide you though the week's program.
There will roughly be three parts to the event: the first two days (Monday/Tuesday) will introduce attendees to the Wolfram Language. The next two days (Wednesday, Thursday) will feature interesting applications of the Wolfram Language; we will cover statistics, image and sound analysis, connected devices and much more. Conrad Wolfram will speak via video link. The final two days will be project oriented. Small groups of attendees will work on projects of their choice - with the support of experience programmers and scientists.
Please check out the following link
[https://www.maths4everydaylife.org/conference][1]
for more information.
We look forward to seeing you at Aberdeen,
Marco
![enter image description here][2]
[1]: https://www.maths4everydaylife.org/conference
[2]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2017-07-21at15.49.09.png&userId=48754Marco Thiel2017-07-21T15:03:25Z//Normal : a sign of gross inefficiency in my code?
http://community.wolfram.com/groups/-/m/t/1153576
The following question concerns a phase of development where I’m working with a new data set to figure out its features...
Concerning higher level Mathematica constructs such as `TimeSeries`, `EventSeries`, `Associations` and `DataSets`, my initial tendency is to convert raw imports of my data almost immediately into these higher level constructs. However, during my exploration phase of figuring out features of my data, I quickly realize I am frequently invoking `//Normal` — so as to invoke Mathematica functions that are not tuned for the higher level constructs. And then that leads me to worry about runtime efficiency (or worse) that I am committing too early to converting my raw data into these higher level constructs.
Lately, I’m thinking to myself that I ought to re-think my Mathematica notebook development into a “exploration” phase were I use only basic Mathematica constructs . And later, when I am confident I understand my data set features, that the second section of Mathematica notebooks is where I’m committing to using the higher level constructs knowing I won’t need to devolve them with `//Normal`.
In summary : If there is indeed negative runtime consequences by invoking `//Normal` too frequently, what is a good practice of creating a cookie-crumb of initial data analysis to discover essential features of unknown data sets, followed by a full-fledged jump into the higher level Mathematica constructs as the data processing pipeline takes shape?A Chase Turner2017-07-26T21:06:27ZRemote Kernel via SSH for Workbench
http://community.wolfram.com/groups/-/m/t/1153365
Hello everyone!
I have access to a remote kernel for some heavy duty computations via ssh, which is set up by the admin using [@Sascha Kratky][at0]'s "Tunnel" package. Is it possible to set up Workbench to use the same tunnel?
Thanks!
[at0]: http://community.wolfram.com/web/kratkyAri Wugalter2017-07-26T20:43:54ZColorizing beyond tomgographies and gray images
http://community.wolfram.com/groups/-/m/t/1153239
Here are the lines of a simple colorizing program, but I am stuck focusing it with the Wolfram platform, any one knows how to make it readable by other languages?
p12=Image[ ]
p1=Colorize[p12,ColorRules->{j->Yellow,.1*j->LightYellow , .01*j ->Purple ,.001*j-> LightPurple ,k->Blue,.001*K-> LightBlue ,ComplexInfinity->White}]
p2=ImageData[%]
Image[v]
HistogramTransform==v
u=ImageDimensions[p1]
t=Reverse[u]
o1=ImageLevels[p1]
p=Flatten [p2]
ImageHistogram[p1]
ImageHistogram [p12]
n=p*(p-Power[p, (p)^-1])
l=p-p*Power[p, (p)^-1]
k=n/l
j=(n/l)^p
bg=Binarize[o1, f]
Module f= PixelValue=j->Yellow=j->Yellow=j->Blue=k->Blue->{p1,j}
ReplacePixelValue[p1,{j,p1}]
f=Module{u}->Yellow==20>j>1->j->{j;p1}==Yellow=Yellow=j
Column[ColorConvert[j,v]&/@{"Green"}]
ImageApply[UnitStep[f]&,bg]
SetAlphaChannel[f,p1]
ImageHistogram [p1]
ImageTransformation[p1,{f}&,DataRange->{{All}}]
ImageHistogram [v]
Do [NestWhile .1 * 10^-7<j<20 [HistogramTransform[p1]]]
v=HistogramTransform[p1]
c=ImageSubtract[v,p1]
d=Colorize[c,ColorRules->{j->Yellow,k->Blue}]
c3=HistogramTransform[c]
c2=ImageSubtract[d,c]
g=Image[p1]
ColorSeparate[g,"Red"]
z=ImageSubtract[ImageSubtract[#1]& @@ ColorSeparate[g,"Blue"]]
v1=ImageSubtract[g,z]
ImageSubtract[p1,v1]
b=ImageFilter[MedianDeviation[Flatten[#]]&,c2,2]// ImageAdjust
z1=ImageSubtract[ImageSubtract[#1]& @@ ColorSeparate[c2,"Blue"]]
b1=Colorize[z1,ColorRules->{z1->Pink,ComplexInfinity->White}]
ImageMultiply[c2,c3]
img=HistogramTransform[%]
DominantColors[%]
ImageMultiply[v,c,d,c2,g,z,c3]
HistogramTransform[%]
p21=ImageData[img]
p13=Image[v5]
DominantColors[%]
HistogramTransform==v5
u1=ImageDimensions[p21]
t1=Reverse[u1]
o12=ImageLevels[p21]
pr=Flatten [p21]
ImageHistogram[p13]
ImageHistogram [img]
n1=pr*(pr-Power[pr, (pr)^-1])
l1=pr-pr*Power[pr, (pr)^-1]
k1=n1/l1
j1=(n1/l1)^pr
bg1=Binarize[o12, f1]
Module f1= PixelValue=j1->Yellow=j1->Yellow=j1->Blue=k1->Blue->{img,j1}
ReplacePixelValue[img,{j1,img}]
f1=Module{u1}->Yellow==20>j1>1->j1->{j1;img}==Yellow=Yellow=j1
Column[ColorConvert[j1,v5]&/@{"Green"}]
ImageApply[UnitStep[f1]&,bg1]
SetAlphaChannel[f1,img]
ImageHistogram [img]
ImageTransformation[img,{f1}&,DataRange->{{All}}]
ImageHistogram [v5]
Do [NestWhile .1 * 10^-7<j1<20 [HistogramTransform[img]]]
v5=HistogramTransform[img]
d1=ImageSubtract[z,c3]
ImageSubtract[d,d1]
c1=HistogramTransform[%]
c3=ImageSubtract[c,c1]
c4=ImageMultiply[d1,c3]
g=ImageSubtract[v,c,d,c2,g,z,c3]
g1=ImageAdd[v,c,d,c2,g,z,c3]
ImageMultiply[g,g1]
a=HistogramTransform[%]
ImageSubtract[a,b]
ImageMultiply[a,b]
HistogramTransform[%]
F=ImageAdd[c1,c4]
DominantColors[%]
ImageAdd[c1,v]
DominantColors[%]
F1=HistogramTransform[F]
ImageAdd[F1,F]
ImageSubtract[F1,F]
f2=ImageSubtract[F,F1]
ct1=ImageCompose[F,F1]
f3=ImageAdd
p14=Image[p12]
p24=ImageData[%]
Image[v]
HistogramTransform==v4
u4=ImageDimensions[p14]
t4=Reverse[u4]
o14=ImageLevels[p14]
p4=Flatten [p24]
ImageHistogram[p14]
ImageHistogram [p12]
n4=p4*(p4-Power[p4, (p4)^-1])
l4=p4-p4*Power[p4, (p4)^-1]
k=n4/l
j=(n4/l4)^p4
bg4=Binarize[o14, f4]
Module f4= PixelValue=j4->Yellow=j4->Yellow=j4->Blue=k4->Blue->{p14,j4}
ReplacePixelValue[p14,{j4,p14}]
f4=Module{u4}->Yellow==20>j4>1->j4->{j4;p14}==Yellow=Yellow=j4
Column[ColorConvert[j4,v]&/@{"Green"}]
ImageApply[UnitStep[f4]&,bg4]
SetAlphaChannel[f4,p14]
ImageHistogram [p14]
ImageTransformation[p14,{f4}&,DataRange->{{All}}]
ImageHistogram [v4]
Do [NestWhile .1 * 10^-7<j4<20 [HistogramTransform[p14]]]
v4=HistogramTransform[p14]
c4=ImageSubtract[v,p14]
d4=Colorize[c4,ColorRules->{j4->Yellow,k4->Blue}]
c34=HistogramTransform[c4]
c24=ImageSubtract[d4,c4]
g4=Image[p14]
ColorSeparate[g4,"Red"]
z4=ImageSubtract[ImageSubtract[#1]& @@ ColorSeparate[g4,"Blue"]]
v14=ImageSubtract[g4,z4]
ImageSubtract[p14,v14]
b4=ImageFilter[MedianDeviation[Flatten[#]]&,c24,2]// ImageAdjust
z14=ImageSubtract[ImageSubtract[#1]& @@ ColorSeparate[c24,"Blue"]]
b14=Colorize[z14,ColorRules->{z14->Pink,ComplexInfinity->White}]
ImageMultiply[c24,c34]
img4=HistogramTransform[%]
DominantColors[%]
ImageMultiply[v4,c4,d4,c24,g4,z4,c34]
HistogramTransform[%]
p214=ImageData[img4]
p134=Image[v54]
DominantColors[%]
HistogramTransform==v54
u14=ImageDimensions[p21]
t14=Reverse[u14]
o124=ImageLevels[p214]
pr4=Flatten [p214]
ImageHistogram[p134]
ImageHistogram [img4]
n14=pr4*(pr4-Power[pr4, (pr4)^-1])
l14=pr4-pr4*Power[pr4, (pr4)^-1]
k14=n14/l14
j14=(n14/l14)^pr4
bg14=Binarize[o124, f14]
Module f14= PixelValue=j14->Yellow=j14->Yellow=j14->Blue=k14->Blue->{img4,j14}
ReplacePixelValue[img,{j14,img4}]
f14=Module{u14}->Yellow==20>j14>1->j1->{j14;img4}==Yellow=Yellow=j14
Column[ColorConvert[j14,v5]&/@{"Green"}]
ImageApply[UnitStep[f14]&,bg14]
SetAlphaChannel[f14,img4]
ImageHistogram [img4]
ImageTransformation[img4,{f14}&,DataRange->{{All}}]
ImageHistogram [v5]
Do [NestWhile .1 * 10^-7<j14<20 [HistogramTransform[img4]]]
v5=HistogramTransform[img]
d14=ImageSubtract[z4,c34]
ImageSubtract[d4,d14]
c14=HistogramTransform[%]
c34=ImageSubtract[c4,c14]
c44=ImageMultiply[d14,c34]
g4=ImageSubtract[v4,c4,d4,c24,g4,z4,c34]
g14=ImageAdd[v4,c4,d4,c24,g4,z4,c34]
ImageMultiply[g4,g14]
HistogramTransform[%]
ImageSubtract[a4,b4]
ImageMultiply[a4,b4]
HistogramTransform[%]
F24=ImageAdd[c14,c44]
DominantColors[%]
F4=ImageAdd[c14,v4]
DominantColors[%]
F34=HistogramTransform[F24]
ImageAdd[F14,F4]
ImageSubtract[F34,F24]
f3=ImageSubtract[F34,F24]
ct2=ImageCompose[F34,F24]
fg=ImageCompose[ct1,ct2]
DominantColors[%]
af=Image[p12]
bf=Image[fg]
ImageCompose[af,bf]
cf=ImageMultiply[bf,af]
df=ImageSubtract [af,bf]
ff=ImageAdd[cf,df]
ImageCompose[af,df]
p1=Image[ct2]
p2=ImageData[%]
p5=Image[ct1]
p4=ImageData[%]
Image[v]
HistogramTransform==v
u=ImageDimensions[p1]
t=Reverse[u]
o1=ImageLevels[p1]
p=Flatten [p2]
p3=Flatten[p4]
ImageHistogram[p1]
ImageHistogram [v]
n=p*(p-Power[p, (p)^-1])
y=p-p*Power[p, (p)^-1]
x=n/y
g=(n/y)^p
n1=p3*(p3-Power[p3, (p3)^-1])
y1=p3-p3*Power[p3, (p3)^-1]
x1=n1/y1
G=(n1/y1)^p3
bg=Binarize[o1, f]
Module f= PixelValue=g->Yellow=g->Yellow=g->Blue=x->Blue->{p1,g}
ReplacePixelValue[p1,{g,p1}]
f=Module{u}->Yellow==20>g>1->g->{g;p1}==Yellow=Yellow=g
Column[ColorConvert[g,v1]&/@{"Green"}]
ImageApply[UnitStep[f]&,bg]
SetAlphaChannel[f,p1]
ImageHistogram [p1]
ImageTransformation[p1,{f}&,DataRange->{{All}}]
ImageHistogram [v1]
v1=HistogramTransform [p1]
Do [NestWhile .1 * 10^-7<g<20 [HistogramTransform[p1]]]
v=HistogramTransform[p1]
Module f2= PixelValue=G->Yellow=G->Yellow=G->Blue=x1->Blue->{p1,G}
ReplacePixelValue[p1,{G,p1}]
f2=Module{u}->Yellow==20>G>1->G->{G;p1}==Yellow=Yellow=G
Column[ColorConvert[G,v]&/@{"Green"}]
ImageApply[UnitStep[f2]&,bg]
SetAlphaChannel[f2,p1]
ImageHistogram [p1]
ImageTransformation[p1,{f2}&,DataRange->{{All}}]
ImageHistogram [v]
Do [NestWhile .1 * 10^-7<G<20 [HistogramTransform[p1]]]
v=HistogramTransform[p1]
Do [NestWhile .1 * 10^-7<G<200 [ImageSubtract[p1,v]]]
ImageHistogram[%]
![Microscopic imagee][1]
[1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=MitochondriaLUISFELIPEMASSENAMISIECIMGCOLORRMNTCRXLOUIVILLEADVANCE.jpg&userId=1147177luis felipe massena misiec2017-07-26T20:18:24ZExamples of Query[]
http://community.wolfram.com/groups/-/m/t/1152954
I routinely work with nested Associations that might be efficiently queried and manipulated with the Query[] command, but I have trouble making the command do what I want. A trivial example:
The following dataset describes a couple of grades at a hypothetical secondary school.
sampleStructure = {<|"grade" -> 11,
"students" -> {<|"name" -> "bill", "age" -> 15|>, <|
"name" -> "susan", "age" -> 16|>}|>, <|"grade" -> 12,
"students" -> {<|"name" -> "manuel", "age" -> 16|>, <|
"name" -> "morris", "age" -> 17|>, <|"name" -> "jackie",
"age" -> 16|>}|>};
Problem 1 (solved): We want to pass over the entire school, assigning a grade to every student. The process is designed to be perfectly objective and remove any chance of favoritism by the teacher -- if the student's age is an even number, he or she gets an A-, otherwise a B+.
Solution: `Query[All, All, All, <|#, "score" -> If[EvenQ@#["age"], "A-", "B+"]|> &]@sampleStructure`
Problem 2 (unsolved): How might one assign grades on the basis of each student's age and grade, rather than just his or her age?
Problem 3 (unsolved): How might one add an additional Key ("teacher"→) at the top level of any grade that has more than two students, leaving other grades unchanged?
Thanks for any help.Michael Stern2017-07-26T01:24:27ZMathematica in Ubuntu
http://community.wolfram.com/groups/-/m/t/1150624
**Problem Detail**
I am using a package in Mathematica 7 on Ubuntu 16.04 LTS OS(**/usr/local/ and script files in /usr/local/bin**). It works well when Mathematica is installed fresh without reboot. But when reboot occurs, that package stops working for a specific case until i reinstall Mathematica and it starts working again.
**My Ideas**
I am guessing that somehow upon rebooting, Ubuntu modifies Mathematica installation folders in some way that interferes with the package(cache?). I have tried starting Mathematica with clean-start command from terminal but the package will not run at all in such a way. I have tried changing swapping settings to no use.
**Query**
Since i cannot modify the package(built by someone else), my only way out is to undo the modification Ubuntu does to newly installed Mathematica folder on reboot, so that it is equivalent to fresh installation, which works. Any idea how to accomplish that?**pasmon 802017-07-21T09:38:31ZThe Calabi Triangle
http://community.wolfram.com/groups/-/m/t/1153310
There are three possible orientations for the largest square inside an equilateral triangle, by symmetry.
There are also three possible orientations for the largest square inside a special isosceles triangle called the Calabi triangle. (see wikipedia).
base of Calabi Triangle, assuming sides have length 1
In[1]:= base = x /. Solve[2 x^3 - 2 x^2 - 3 x + 2 == 0, x, Reals][[3]]
Out[1]= Root[2 - 3 #1 - 2 #1^2 + 2 #1^3 &, 3]
height of triangle
In[2]:= height = y /. Solve[y^2 + (base/2)^2 == 1, y][[2]]
Out[2]= 1/2 Sqrt[4 - Root[2 - 3 #1 - 2 #1^2 + 2 #1^3 &, 3]^2]
vertices of triangle
In[3]:= ctrip = Polygon[{{-base/2, 0}, {base/2, 0}, {0, height}}];
square centered at {xc,yc} with side a, rotated by angle \[Theta]
In[4]:= sqr[{xc_, yc_}, a_, \[Theta]_] =
Polygon[(a/2 (RotationMatrix[\[Theta]].#) & /@ {{-1, -1}, {-1, 1}, {1,
1}, {1, -1}}) /. {x_, y_} -> {x + xc, y + yc}];
Find the three orientations
In[5]:= sln1 = FindMaximum[{a,
RegionWithin[ctrip, sqr[{xc, yc}, a, \[Theta]]] }, {{a, .5}, {\[Theta],
0}, {xc, 0}, {yc, 0}}]
Out[5]= {0.448612, {a -> 0.448612, \[Theta] -> -5.33582*10^-21, xc -> -4.00508*10^-17,
yc -> 0.224306}}
In[13]:= p1 = Show[Graphics @ {Opacity[0.3], Green, ctrip},
Graphics @ {Opacity[0.3], Red, sqr[{xc, yc}, a, \[Theta]]} /. sln1[[2]],
ImageSize -> Small];
In[7]:= sln2 = FindMaximum[{a,
RegionWithin[ctrip,
sqr[{xc, yc}, a, \[Theta]]] }, {{a, .5}, {\[Theta], .6}, {xc, 0}, {yc,
0}}]
Out[7]= {0.448612, {a -> 0.448612, \[Theta] -> 0.682984, xc -> -0.0324308,
yc -> 0.315555}}
In[14]:= p2 = Show[Graphics @ {Opacity[0.3], Green, ctrip},
Graphics @ {Opacity[0.3], Red, sqr[{xc, yc}, a, \[Theta]]} /. sln2[[2]],
ImageSize -> Small];
In[9]:= sln3 = FindMaximum[{a,
RegionWithin[ctrip, sqr[{xc, yc}, a, \[Theta]]] }, {{a, .5}, {\[Theta],
2 \[Pi] - .6}, {xc, 0}, {yc, 0}}]
Out[9]= {0.448612, {a -> 0.448612, \[Theta] -> 5.6002, xc -> 0.0324308,
yc -> 0.315555}}
In[15]:= p3 = Show[Graphics @ {Opacity[0.3], Green, ctrip},
Graphics @ {Opacity[0.3], Red, sqr[{xc, yc}, a, \[Theta]]} /. sln3[[2]],
ImageSize -> Small];
Check equality of square sizes
In[11]:= {sln1[[1]] - sln2[[1]], sln1[[1]] - sln3[[1]], sln2[[1]] - sln3[[1]]}
Out[11]= {-7.72961*10^-9, -7.72961*10^-9, 5.55112*10^-17}
![enter image description here][1]
[1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=calabi_triangle.jpg&userId=29126Frank Kampas2017-07-26T13:38:52ZAre not getting expected transformation from OblateSpheroidal to Cartesian
http://community.wolfram.com/groups/-/m/t/1152672
I am trying to plot a line in Oblate Spheroidal Coordinate system (OS). I want to seek the equation in the OS from the code
CoordinateTransformData[
"Spherical" -> "Cartesian", "Mapping", {r, \[Theta], \[CurlyPhi]}]
CoordinateTransformData[
"Cartesian" -> "Spherical", "Mapping", {x, y, z}]
CoordinateTransformData["Cartesian" -> "Spherical",
"Mapping", {r Cos[\[CurlyPhi]] Sin[\[Theta]],
r Sin[\[Theta]] Sin[\[CurlyPhi]], r Cos[\[Theta]]}] // FullSimplify
But the result I am getting is not the same
FullSimplify[{Sqrt[r^2],
ArcTan[r Cos[\[Theta]], Sqrt[r^2 Sin[\[Theta]]^2]],
ArcTan[r Cos[\[CurlyPhi]] Sin[\[Theta]],
r Sin[\[Theta]] Sin[\[CurlyPhi]]]} == {r, \[Theta], \[CurlyPhi]}]
Out[62]= {Sqrt[x^2+y^2+z^2],ArcTan[z,Sqrt[x^2+y^2]],ArcTan[x,y]}
Out[63]= {Sqrt[r^2],ArcTan[r Cos[\[Theta]],Sqrt[r^2 Sin[\[Theta]]^2]],ArcTan[r Cos[\[CurlyPhi]] Sin[\[Theta]],r Sin[\[Theta]] Sin[\[CurlyPhi]]]}
In[65]:= FullSimplify[{Sqrt[r^2],ArcTan[r Cos[\[Theta]],Sqrt[r^2 Sin[\[Theta]]^2]],ArcTan[r Cos[\[CurlyPhi]] Sin[\[Theta]],r Sin[\[Theta]] Sin[\[CurlyPhi]]]}=={r,\[Theta],\[CurlyPhi]}]
Out[65]= {Sqrt[r^2],ArcTan[r Cos[\[Theta]],Sqrt[r^2 Sin[\[Theta]]^2]],ArcTan[r Cos[\[CurlyPhi]] Sin[\[Theta]],r Sin[\[Theta]] Sin[\[CurlyPhi]]]}=={r,\[Theta],\[CurlyPhi]}
Not getting the transformation from OS back to its cartesian coordiantes. Why is this?Jose Calderon2017-07-26T03:51:51ZZ-Transform of sequence=causal sequence+anticausal sequence
http://community.wolfram.com/groups/-/m/t/1153032
Hello everyone. How can I get the Z-Transform of sequence=causal sequence+anticausal sequence like this:
x=a^n HeavisideTheta[n]-b^n HeavisideTheta[-n-1]
Z[x]=(1/(1-a z^-1) + 1/(1-b z^-1))
I know that the command ZTransform works only for causal sequence because ZTransform implements only unilateral Z-Transform.
Thank you very much.Gennaro Arguzzi2017-07-26T10:26:32Z[GIF] Hex (Rotating Hexagons)
http://community.wolfram.com/groups/-/m/t/1152974
![Rotating hexagons][1]
**Hex**
A couple of years ago I set out to recreate Saskia Freeke's piece [_Geometric Animations / 150224_][2]. Once I had gotten a reasonable approximation, I quickly switched from hexagons to squares and played around with it for a bit, but eventually that notebook just kind of languished. A couple of weeks ago I opened it up again and played around some more; eventually [_Just Squares_][3] was the result.
When I posted it, [Harold Hausman suggested][4] a version with hexagons, which I thought was funny since it originally _was_ hexagons. That gave me motivation to try again to make something with hexagons, and this is the result.
Here's the code:
smootheststep[t_] := -20 t^7 + 70 t^6 - 84 t^5 + 35 t^4;
DynamicModule[{colorArray, t,
cols = RGBColor /@ {"#f54123", "#0098d8", "#fbfbfb", "#46454b"}},
colorArray = Table[RandomChoice[cols[[;; 2]]],
{j, -1, 14, 1/2}, {i, -1, 13 - If[OddQ[2 j], 1/2, 0]}];
Manipulate[
t = smootheststep[s];
Graphics[
{Thickness[.005],
Table[
{Blend[{Lighter[colorArray[[2 j + 3, i + 2]], .2], cols[[-2]]}, 2 Abs[t - 1/2]],
Line[
Table[
{ Cos[θ + 2 π/6 t] + 2 i + If[OddQ[2 j], 1, 0], Sin[θ + 2 π/6 t] + 2/Sqrt[3] j},
{θ, 0, 2 π, π/3}]]},
{j, -1, 14, 1/2}, {i, -1, 13 - If[OddQ[2 j], 1/2, 0]}]},
ImageSize -> 540, PlotRange -> {{0, 12}, {0, 12}}, Background -> Darker[cols[[-1]]]],
{s, 0, 1}]
]
[1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=hex9c.gif&userId=610054
[2]: http://sasj.tumblr.com/post/111975871965/geometric-animations-150224
[3]: http://community.wolfram.com/groups/-/m/t/1148062
[4]: https://ello.co/shonk/post/ga9eklc3reri3ykry5dvyqClayton Shonkwiler2017-07-26T04:51:55ZAvoid control variable in Manipulate displaying unexpected values?
http://community.wolfram.com/groups/-/m/t/1135555
I have a Manipulate command in which the control variable runs over an interval which includes zero and with a specific increment. When the slider value is near zero, the value displayed can be an exact zero or an approximate zero depending upon how it was approached. Try the following and note that "sliding" onto zero is no problem, but incrementing to zero from either direction gives an inexact zero representation. This can be overcome with a Chop command, but I can't seem to change the actual display of the value that way. Here's a simplified command to try:
Manipulate[N[c,20],{{c,0,"(-0.5,2)"},-0.5,2.0,0.01,Appearance->{"Labeled","Open"}}];
Is there any way to "manipulate" the control variable to avoid this behavior?William Vaughn2017-07-05T15:26:59ZManipulate does not work on a graphic
http://community.wolfram.com/groups/-/m/t/1152662
This code is not responding. I am tryign to do an animation of a chang in the inside ellipsoid.
Manipulate[
trans = CoordinateTransformData[{{"OblateSpheroidal", 1}, 3} ->
"Cartesian", "Mapping"];
ParametricPlot3D[{trans[{1, \[Eta], \[CurlyPhi]}]}, {\[Eta], 2 Pi/8,
6 Pi/8}, {\[CurlyPhi], -\[Pi], 3 \[Pi]/4},
PlotStyle -> Opacity[.5]];
ParametricPlot3D[{None, trans[{\[Xi], Pi/4, \[CurlyPhi]}],
trans[{\[Xi], 3 Pi/4, \[CurlyPhi]}]}, {\[Xi], 0,
1.4}, {\[CurlyPhi], -\[Pi], \[Pi]},
PlotStyle -> {Opacity[.8], {Red, Green}}];
ParametricPlot3D[{None, None, None,
trans[{\[Xi], \[Eta], 7 Pi/8}]}, {\[Xi], .1, 2}, {\[Eta], -Pi, Pi},
PlotStyle -> Opacity[.5]];
ParametricPlot3D[{None, None, None, None,
trans[{k, \[Eta], \[CurlyPhi]}]}, {\[Eta], 0,
Pi}, {\[CurlyPhi], -\[Pi], \[Pi]}, PlotStyle -> Opacity[.5],
ImageSize -> Medium];
Show[{%, %%, %%%, %%%%}, PlotRange -> 1.5,
ImageSize -> Large], {k, .05, .5}]Jose Calderon2017-07-26T02:15:27ZError: Invalid_argument("SimCodegen.printZeroCrossingOpStr")
http://community.wolfram.com/groups/-/m/t/1152013
I'm trying to model Coulomb static friction in a multi-body system based on the equations from this [physics.stackexchange.com][1] post. I have written a very primitive Modelica code to test the equations you may see in this [GitHub Gist][2]. But when I try to simulate the code using Wolfram System Modeler I get the error below:
> Building "multibody_Coulomb_static_friction" as experiment "multibody_Coulomb_static_friction 1" started at ....
> Error: Error: Internal error Fatal failure: Invalid_argument("SimCodegen.printZeroCrossingOpStr")Warning: Warning: In relation V3==V2, == on > Reals is only allowed inside functions.
> Warning: Warning: In relation V1==V2, == on Reals is only allowed inside functions.
> Warning: Warning: In relation V3==V2, == on Reals is only allowed inside functions.
> Warning: Warning: In relation V1==V2, == on Reals is only allowed inside functions.
> Warning: Warning: In relation V3==V2, == on Reals is only allowed inside functions.
> Warning: Warning: In relation V1==V2, == on Reals is only allowed inside functions.
> Warning: Warning: In relation V3==V2, == on Reals is only allowed inside functions.
> Warning: Warning: In relation V1==V2, == on Reals is only allowed inside functions.
> Warning: [<interactive>:37:3-41:9:writable] Warning: In component <NO COMPONENT>, in relation V3 == V2, == on Real numbers is only allowed inside functions.
> Warning: [<interactive>:32:3-36:9:writable] Warning: In component <NO COMPONENT>, in relation V1 == V2, == on Real numbers is only allowed inside functions.
> Build finished at 14:56:08 (took 00:00).
> Error: No executable generated C:/Users/.../AppData/Local/Temp/WolframSystemModeler-4.3.0/sme.4.3.0_1500900967_26500.exe
> Error: No settings file generated C:/Users/.../AppData/Local/Temp/WolframSystemModeler-4.3.0/sme.4.3.0_1500900967_26500_init.sim
This is strange because the code does compile in OpenModelica, though I get the same warning and it takes ages to finish. I would appreciate if you could help me know why is this happening and how I can solve it?
[This is a related SO post][3] you may want to see too.
[1]: https://physics.stackexchange.com/questions/348240/modeling-static-coulomb-friction-in-a-multibody-system/348254#348254
[2]: https://gist.github.com/Foadsf/a106ec3658df3c1537ff3c2858d50ba6
[3]: https://stackoverflow.com/questions/45281704/openmodelica-translation-warning-in-component-in-relation-on-real-numbers-is-onFoad Sojoodi Farimani2017-07-24T13:27:03ZHow to import and export specific data from Mathematica to Excel ?
http://community.wolfram.com/groups/-/m/t/1152506
Hello everyone,
I would like to import a specific range of data from excel to mathematica (e.g : from B7 to B13) and then after some calculation export the results in specific area in an excel spreadsheet. How do I do that ?Narjes Kandil2017-07-25T09:13:18ZCan I plot it in different ways...
http://community.wolfram.com/groups/-/m/t/1152390
After generating the numbers I can not if not only plot it in this way but there are interesting numbers coming out of the equation, can someone find me a plot , a nice plot for it? It comes about a nice plot little dots of a progression of very high numbers.
a=RandomInteger[20,{40}]
For t[n=0->n^y=1/y->n=a;n==(y)^x/n+(1);y==n*x^n,n<x,n++,x==n+n*-Sqrt[n^Sqrt[n]]
Do[y=n*x^n,{n,x},n];[x=n+n*-Sqrt[n^n
Sqrt[n]],n]If -1<y>1 -> y=n *n-1+n/x While Print[x=y]]
d=x/a
Table[x/a,{x,40}]
ListPlot[x]luis felipe massena misiec2017-07-25T21:21:12ZHow can I rerun this recurrence function multiple times?
http://community.wolfram.com/groups/-/m/t/1152029
Hey,
first and foremost I'm sorry if this is in the wrong thread, it is my first time posting here.
So I'm currently trying to forecast interest rates with the vasicek modell. My approach is to use a recursive equation (mean reversion rate, mean reversion level and volatility are already calculated). It goes as follows:
r_{i+1}=r_{i}+\kappa * (\theta-r_{i})Dt + \sigma \epslion_{i}dt
where \epsilon_{i} is a standard normally-distributed random. For simplicity reasons i set dt as 1, because I wanted to have a daily forecast.
Currently I'm using the recurrencetable to solve it, but I get the error message "the expression 'xy' cannot be used as a part specification" (but the programm gives me an output nevertheless).
![enter image description here][1]
[1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=vasicekforecast.PNG&userId=1151771
It seems like the programm runs as expected, but the error message is buzzing me a little. Is there a better way to implement it? I tried it in a for loop but it didnt work...
My next step would be to rerun this multiple times to get different forecasts but I dont know how I should do this. Manually it would be too much of an effort, but my last try to programm it was a failure. My idea was to have two for-loops that give me an output in matrix form with the days written in the rows and the runs written in the columns.
If you have a question regarding the idea feel free to ask. I'm thankful for all the help.
Regards TimTim2017-07-24T15:18:25ZPolynomial Term Order?
http://community.wolfram.com/groups/-/m/t/1152222
I would like polynomials in TraditionalForm to be ordered in descending order of degrees. All the polynomials that I am dealing with are in one variable. For instance, I have -5x+3. TraditionalForm outputs 3-5x. I found an article [HERE][1] that talks about a solution, but I can't get that solution to work. It says to do this:
poly=-5x+3;
MonomialList[poly, x];
poly // TraditionalForm
But the output I'm getting is still 3-5x. What am I doing wrong?
Thanks in advance,
Mark Greenberg
[1]: http://reference.wolfram.com/language/howto/RearrangeTheTermsOfAPolynomial.html.enMark Greenberg2017-07-24T23:06:34ZVisual Interface to the Wolfram Language
http://community.wolfram.com/groups/-/m/t/1124967
Hi everyone.
I'm working on a visual interface to the Wolfram Language called [visX][1], and I'd like to ask what you all think of it.
Wolfram Language code can often be thought of as a set of blocks, each of which takes some inputs, does something, and produces an output. VisX lets you write WL code exactly this way - you draw a digram, connecting blocks with links. For example, say you want to count how many times each digit (0 to 9) occurs in the first 30 digits of Pi. With text-based WL code, you'd write
digits = RealDigits[N[Pi, 30]][[1]]
Count[digits, #] & /@ Range[0, 9]
In visX, you'd draw this:
![digits of Pi][2]
I guess it's pretty self-explanatory. In addition to using built-in WL blocks, you can write your own, like the CountInList block. Normally, blocks just transform inputs to output, but the CountInList block is mapped over its input which is indicated by the little brackets on the outside of its connection ports. (That's basically visual syntactic sugar for "/@" or Map.) The 4 in the upper-right corner indicates that results inside this block are showing results from the 4-th time through the map. The block with "digits" in it sets a variable, which is then referenced in the CountInList block.
You define blocks (which are basically functions) by just making an empty rectangle and dragging contents in then wiring them together, then you can use copies of the block wherever you want. A change in any copy of the block will be reflected in all other copies. There's no real difference between a defining a block and using it. Recursion can be specified by just including a copy of the block inside itself. Blocks can call other blocks in the same manner.
Just like regular WL code, visX blocks can be nested deeply, but with the visual interface, it's easy to zoom in and out. At any point, the UI will show you the right amount of detail for each block - sometimes no detail at all, sometimes its name and labels on its inputs, sometimes its actual contents (which can then be edited or further zoomed...).
visX is stand-alone software that runs locally on your machine, evaluates the diagram using your local Mathematica kernel, and receives the results and puts them back in the diagram. You can load data files using Import as usual.
One of the problems that I've seen with visual languages in the past is that while simple things are easy to do, the code quickly gets too complex to manage and the visual interface starts to get in the way. With the Wolfram Language in theory everything is an expression, and this can lead you to write functional-style programs which are easily thought of as a diagram, but that's not always the most natural way to express a computation. Sometimes you just need a little for loop. Consider calculating Fibonacci numbers. Start the sequence with 1, 1, ... then each element of the sequence is the sum of the previous two. Yes, you can write a recursive algorithm to do this, but most people just want to write a little for loop. In visX, you can do this (calculates the 6th Fibonacci number):
![embedded code][4]
I've tried to let you use blocks-and-links when that's the most natural thing (which is usually), and text-based code when that's better. Of course, you can mix them together however you want.
A second problem I've found with visual programming languages is that it can actually be much slower to use then writing out text, because you have to laboriously drag and drop every single block. Even simple algebraic expressions like
Sin[x]^2 + Cos[x]^2
2x^2 + 4x*y + 8y^2
would involve a lot of blocks because of all the Plus, Times, and Power blocks, as well as all the constants and symbols. With visX, you can enter Wolfram Language code snippets like those, and it will parse them and transform them into blocks which you can then insert into your diagram all at once and edit at will. This makes it much faster to get your idea onto the screen so that you can start evaluating it and developing it. I'm also working on the ability to take a visX block and give you back the Wolfram Language code that it represents.
The examples given here are simple, but of course you can use this interface for putting together a complex piece of code as well. I find it especially handy when building up a calculation with lots of intermediate results along the way, or to rapidly prototype an algorithm where I want to be able to easily switch the data flows around.
Does this project seem useful to anyone? I'd like to get some feedback - what do you think of it? Would you use it? For what?
If there's interest, I could do a small-scale alpha test in about a month from now.
More info at [visx.io][5].
-Nicholas Hoff
*edited to clarify block definitions and recursion*
[1]: http://visx.io
[2]: http://community.wolfram.com//c/portal/getImageAttachment?filename=pi_digits_without_chrome.png&userId=1124239
[3]: http://community.wolfram.com//c/portal/getImageAttachment?filename=pi_digits.png&userId=1124239
[4]: http://community.wolfram.com//c/portal/getImageAttachment?filename=embeded_wl.png&userId=1124239
[5]: http://visx.ioNicholas Hoff2017-06-20T10:02:52ZHow do I model electrodiffusion in Wolfram Mathematica?
http://community.wolfram.com/groups/-/m/t/1152480
I am an undergraduate researcher. I have been working with Mathematica for roughly a month. I have been assigned a modeling task. My objective is to model the diffusion of ions in solution under the effect of an electric field and ignoring concentration gradient.
Part 1: Equations
-----------------
The model is to be one dimensional for the time being. In the future it will be translated to 2D and ultimately 3D.
The equation used is as follows:
∂C/∂t=∂/∂x(D ∂C/∂x-zμC ∂Φ/∂x)
Where:
C : Concentration of ions
D: Diffusion coefficient
z: Charge per molecule
μ: Ion mobillity
Φ: Electric potential
*C is a function of time and space. “t” and “x”.*
*Φ is a function of space. “x”.*
*All remaining terms are assumed constant. (D,z, μ)*
The model I am making ignores diffusion caused by concentration gradient (The highlighted term).
∂C/∂t=∂/∂x(**D ∂C/∂x**-zμC ∂Φ/∂x)
The following assumptions are made:
D ∂C/∂x=0
z = -1
μ = 1
This leaves us with:
∂C/∂t=∂/∂x(C ∂Φ/∂x)
Finally, performing the product rule gives the final equation.
∂C/∂t=C (∂^2 Φ)/(∂x^2 )+∂C/∂x ∂Φ/∂x
Part 2: Wolfram
---------------
Mathematica’s DSolve function presents a general solution. But despite multiple attempts and combinations of boundary and initial conditions of both the concentration and potential, I can’t get DSolve to present a particular solution. The code is as follows:
enter code h1D Electrodiffusion
The purpose of this program is to model the diffusion of ions under the influence of an electric field ONLY.
The first attempts will use "DSolve"
Later attempts will use "NDSolve" if no prior attempt is successful
The following cell works to describe the partial differential equation to be solved
edeqn = D[u[t, x], t] ==
u[t, x]*D[\[CapitalPhi][x], {x, 2}] +
D[u[t, x], x]*D[\[CapitalPhi][x], x]
The following cell attempts to discern a solution to the differential equation
sol = DSolve[edeqn, u, {t, x}]
Simplify[edeqn /. sol]
This returns the general solution. I have provided a few sample of my attempts to attain a particular solution below.
The following cell shows the effect of adding an initial condition and a boundary condition for the left AND right sides of the channel.
bc = {u[t, 0] == 10, u[t, 2] == 0}
ic = u[0, x] == 8
sol = DSolve[{edeqn, bc, ic}, u, {t, x}]
The following cell attempts to discern a solution to the differential equation.
The solver has been told to solve for "u" and "\[CapitalPhi]".
Both "u" and "\[CapitalPhi]" are given as functions of "t" and "x".
edeqn = D[u[t, x], t] ==
u[t, x]*D[\[CapitalPhi][t, x], {x, 2}] +
D[u[t, x], x]*D[\[CapitalPhi][t, x], x]
sol = DSolve[edeqn, {u, \[CapitalPhi]}, {t, x}]
Boundary condition. "u". Left side.
Boundary condition. "u". Right side.
Initial condition. "u".
Boundary condition "\[CapitalPhi]". Left side.
Boundary condition "\[CapitalPhi]". Right side.
Initial condition. "\[CapitalPhi]".
bc = {u[t, 0] == 10,
u[t, 2] == 0, \[CapitalPhi][t, 0] == 5, \[CapitalPhi][t, 2] == 0}
ic = {u[0, x] == 8, \[CapitalPhi][0, x] == 0}
edeqn = D[u[t, x], t] ==
u[t, x]*D[\[CapitalPhi][t, x], {x, 2}] +
D[u[t, x], x]*D[\[CapitalPhi][t, x], x]
sol = DSolve[{edeqn, bc, ic}, {u, \[CapitalPhi]}, {t, x}]
I apologize for the length of the post. I've never used a forum before.
I do hope you all will consider my dilemma, and are willing and able to provide a solution. I have attached the full code of my attempts. Thank you for your time.Kali Ellison2017-07-25T15:11:17ZHow do I model electrodiffusion in Wolfram Mathematica?
http://community.wolfram.com/groups/-/m/t/1152471
I am an undergraduate researcher. I have been working with Mathematica for roughly a month. I have been assigned a modeling task. My objective is to model the diffusion of ions in solution under the effect of an electric field and ignoring concentration gradient.
Part 1: Equations
-----------------
The model is to be one dimensional for the time being. In the future it will be translated to 2D and ultimately 3D.
The equation used is as follows:
∂C/∂t=∂/∂x(D ∂C/∂x-zμC ∂Φ/∂x)
Where:
C : Concentration of ions
D: Diffusion coefficient
z: Charge per molecule
μ: Ion mobillity
Φ: Electric potential
*C is a function of time and space. “t” and “x”.*
*Φ is a function of space. “x”.*
*All remaining terms are assumed constant. (D,z, μ)*
The model I am making ignores diffusion caused by concentration gradient (The highlighted term).
∂C/∂t=∂/∂x(**D ∂C/∂x**-zμC ∂Φ/∂x)
The following assumptions are made:
D ∂C/∂x=0
z = -1
μ = 1
This leaves us with:
∂C/∂t=∂/∂x(C ∂Φ/∂x)
Finally, performing the product rule gives the final equation.
∂C/∂t=C (∂^2 Φ)/(∂x^2 )+∂C/∂x ∂Φ/∂x
Part 2: Wolfram
---------------
Mathematica’s DSolve function presents a general solution. But despite multiple attempts and combinations of boundary and initial conditions of both the concentration and potential, I can’t get DSolve to present a particular solution. The code is as follows:
enter code h1D Electrodiffusion
The purpose of this program is to model the diffusion of ions under the influence of an electric field ONLY.
The first attempts will use "DSolve"
Later attempts will use "NDSolve" if no prior attempt is successful
The following cell works to describe the partial differential equation to be solved
edeqn = D[u[t, x], t] ==
u[t, x]*D[\[CapitalPhi][x], {x, 2}] +
D[u[t, x], x]*D[\[CapitalPhi][x], x]
The following cell attempts to discern a solution to the differential equation
sol = DSolve[edeqn, u, {t, x}]
Simplify[edeqn /. sol]
This returns the general solution. I have provided a few sample of my attempts to attain a particular solution below.
The following cell shows the effect of adding an initial condition and a boundary condition for the left AND right sides of the channel.
bc = {u[t, 0] == 10, u[t, 2] == 0}
ic = u[0, x] == 8
sol = DSolve[{edeqn, bc, ic}, u, {t, x}]
The following cell attempts to discern a solution to the differential equation.
The solver has been told to solve for "u" and "\[CapitalPhi]".
Both "u" and "\[CapitalPhi]" are given as functions of "t" and "x".
edeqn = D[u[t, x], t] ==
u[t, x]*D[\[CapitalPhi][t, x], {x, 2}] +
D[u[t, x], x]*D[\[CapitalPhi][t, x], x]
sol = DSolve[edeqn, {u, \[CapitalPhi]}, {t, x}]
Boundary condition. "u". Left side.
Boundary condition. "u". Right side.
Initial condition. "u".
Boundary condition "\[CapitalPhi]". Left side.
Boundary condition "\[CapitalPhi]". Right side.
Initial condition. "\[CapitalPhi]".
bc = {u[t, 0] == 10,
u[t, 2] == 0, \[CapitalPhi][t, 0] == 5, \[CapitalPhi][t, 2] == 0}
ic = {u[0, x] == 8, \[CapitalPhi][0, x] == 0}
edeqn = D[u[t, x], t] ==
u[t, x]*D[\[CapitalPhi][t, x], {x, 2}] +
D[u[t, x], x]*D[\[CapitalPhi][t, x], x]
sol = DSolve[{edeqn, bc, ic}, {u, \[CapitalPhi]}, {t, x}]
I apologize for the length of the post. I've never used a forum before.
I do hope you all will consider my dilemma, and are willing and able to provide a solution. I have attached the full code of my attempts. Thank you for your time.Kali Ellison2017-07-25T15:09:20ZHow can i solve-plot numerically this differential equation??
http://community.wolfram.com/groups/-/m/t/1150253
e1 = 0.001;
e^0.4 = {{2.37/de^0.06} - 1.6}/10 {1 - Log[de]/13.8}^0.7
the initial value is e1=0.001 for t0=1 and the time period is between {t,1,18000}dimitriss mal2017-07-20T20:00:18ZlocalVariable
http://community.wolfram.com/groups/-/m/t/1152530
Hi guys
I would like to declare location variable so it will not be signed on the global here is a simple code ( as image attach)
thank you![enter image description here][1]
[1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=LocalVariable.png&userId=931362Sheng Dai2017-07-25T10:42:24ZHow do I add a constraint ??
http://community.wolfram.com/groups/-/m/t/1152558
Hello, my program worked just fine, but when I added a constraint on x, it didn't give me results anymore. I have probably written it wrong but I don't know how to correct it.
Here is my program :
Module[
{
\[Alpha] = 50,
\[Beta] = 100,
c = 10,
b = 0.05,
e = 100,
k = 100,
a = 10000,
t = 0.01 *{69.9, 31.1, 46.7, 48.2, 2.3, 23.9, 11.7},
m,
f
},
(*m=(a+ \[Alpha] p[[n-1]]- \[Alpha] c - (Length[t]-n) \
a)/(\[Alpha](b+(Length[t]-n+1)t[n]- Sum[t[[i]],{i,n+1, Length[t]}]));*)
f[x0_, pList_] := (pList[[1]] -
c - (b + t[[1]]) x0) (a - \[Alpha] pList[[1]]) +
Sum[ (pList[[i]] -
c - (b + t[[i]]) x0) (a - \[Beta] pList[[
i]] + \[Beta] pList[[i - 1]] - \[Alpha] pList[[i]]), {i, 2,
Length[t]}] - k (e - x0)^2;
Maximize[
{f[\[FormalX], Array[\[FormalP], Length[t]]],
And @@ Thread[Array[\[FormalP], Length[t]] > 0] &&
And @@ Table[
a - \[Beta] (\[FormalP][i] + \[FormalP][
i - 1]) - \[Alpha] \[FormalP][i] > 0, {i, 2, 5}] &&
And @@ x > 0
},
Flatten[{\[FormalX], Array[\[FormalP], Length[t]]}]
]
]Narjes Kandil2017-07-25T11:23:07ZGUI tool box
http://community.wolfram.com/groups/-/m/t/1152539
Hi all
How does mathematica has GUI from GUIKit, as matlab below. I am too lazy to code the buttons etc.
I saw Mathematica has GUIkit but, it more like to be Java.
Thank you.
[1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=MatlabGUIexample1.jpg&userId=931362Sheng Dai2017-07-25T10:51:26ZStandardForm in Cloud FormFunctions
http://community.wolfram.com/groups/-/m/t/1152337
[Cross posted on Mathematica.stackexchange](https://mathematica.stackexchange.com/q/152218/5478)
## Example
choices = {
"label 1" -> 1
, Column[{"label", 2}] -> 2
, Framed[3] -> 3
, HoldForm @ Sum[i, {i, 0, ∞}] -> 4
};
CloudDeploy @ FormFunction[
{ "a" -> <|
"Interpreter" -> choices
, "Control" -> (RadioButtonBar[##, Appearance -> "Vertical"] &)|>
}
]
[![enter image description here][1]][1]
So by default StandardForm is not supported (though e.g. `Column` is).
## My attempts to fix it
I tried to force `"HTMLCloudCDF"` as an export form for those elements:
...
"Interpreter" -> MapAt[ExportForm[#, "HTMLCloudCDF"] &, choices, {All, 1}]
...
[![enter image description here][2]][2]
But it is not supported.
At the end I am using: `ExportForm[#, "SVG"] &` but it makes fonts inconsistent with the rest of the form and selected item's label gets an ugly red frame if it is an image:
[![enter image description here][3]][3]
## Question
How to use arbitrary expressions in form functions layout? Is there a better way than SVG? Shouldn't it work out of the box?
## Related
https://mathematica.stackexchange.com/q/123894/5478
[1]: https://i.stack.imgur.com/YJpVB.png
[2]: https://i.stack.imgur.com/K3oYp.png
[3]: https://i.stack.imgur.com/gnMwj.pngKuba Podkalicki2017-07-25T08:08:26ZHow can I use api in Mathematica?
http://community.wolfram.com/groups/-/m/t/1152321
I tried to use an api in Mathematica but failed. I can’t find any more detailed guide in the website, looking for some help.
The api I want to use is below, written in python:
import urllib, urllib2, sys
host = 'http://jisushouji.market.alicloudapi.com'
path = '/shouji/query'
method = 'GET'
appcode = '1d64df14d599b4bc8280c3f6bbf491bd'
querys = 'shouji=18001493959'
bodys = {}
url = host + path + '?' + querys
request = urllib2.Request(url)
request.add_header('Authorization', 'APPCODE ' + appcode)
response = urllib2.urlopen(request)
content = response.read()
if (content):
print(content)
I tried this way, as the attachment
![enter image description here][1]
But it required username and password
![enter image description here][2]
I think I haven’t set the parameter right.
How should I use this api in Mathematica?
[1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=IMG_0138.PNG&userId=770346
[2]: http://community.wolfram.com//c/portal/getImageAttachment?filename=IMG_0139.PNG&userId=770346海晨 郭2017-07-25T05:28:00ZPlot special functions real and imaginary part?
http://community.wolfram.com/groups/-/m/t/1092218
Consider the following code:
0F1[;1;j*pi/2x]*e^j2*pi*x
x[-pi/2,+pi/2]
The task is to visualize the real and imaginary part here is how i tried it what has to be different?besides i need the first three derivatives it didnt work like that
Grid[
Partition[
Table[
Plot[
Evaluate[{Re[
D[Hypergeometric0F1[
1, (\[ImaginaryJ]*\[Pi]/2*x)*E^j2\[Pi]x], {x, i}]],
Im[D[
Hypergeometric0F1[
1, (\[ImaginaryJ]*\[Pi]/2*x)*E^j2\[Pi]x], {x, i}]]}],
{x, -2/\[Pi], 2/\[Pi]},
PlotRange -> Automatic,
Frame -> True,
GridLines -> Automatic,
AspectRatio -> 1,
FrameLabel -> {"x",
StringForm[
"\!\(\*SubscriptBox[\(\[InvisiblePrefixScriptBase]\), \(0\)]\)\
\!\(\*SubscriptBox[OverscriptBox[\(F\), \(~\)], \(1\)]\)^(``)(\
\[ImaginaryJ]*\[Pi]/2*x)*\!\(\*SuperscriptBox[\(\[ExponentialE]\), \
\(j2\[Pi]x\)]\)"]},
PlotLegends -> Placed[{"Re", "Im"}, {Center, Top}],
ImageSize -> 300], {i, 0, 3}], 2], Frame -> All]Azad Kaygun2017-05-12T15:36:28ZFunction eveluation
http://community.wolfram.com/groups/-/m/t/1152248
Hello Everyone,
I would be grateful for any help you can offer.
Given a function of 2 variables and a parameter f(x,y,a), can we find for what values of the variables the function is less than zero?
Thanks a lot for your time.Deepa M2017-07-25T06:35:30ZCompiling a notebook directly into LaTeX
http://community.wolfram.com/groups/-/m/t/1114655
Hi everyone,
Recently I've been writing some work up in LaTeX. As I usually work in Mathematica, I found myself going back and forth between Mathematica and my Tex editor as I adjusted figures I was rendering with Mathematica code. I began to wonder if I could set up my notebook to turn itself into LaTeX, cutting out the middleman (me!).
To achieve this I've done two things, firstly I wrote a notebook that could select sections of itself and convert them to plaintext. I do this using various bits of Mathematicas front end interface. Notably the notebook saves and deletes output cells, this means one can write an input "hello " <> "world", and trust that it will be converted to output, without having to view that output, which might be repetitive or contain a lot of superfluous scaffolding. Find this notebook "Notebook to plaintext" is attached.
The second step was augmenting the above notebook to save the generated plaintext as a tex file, and automatically run pdfLatex.exe on the tex file to receive the ultimate output file. By writing Mathematica functions that export Mathematica plots, and return LaTeX that imports said plots, one can write a LaTeX document in Mathematica, the same environment that we specify our graphics. This notebook "Notebook to LaTex" is also attached, but one requires pdfLatex.exe, as is included in a MikTex installation for example. The pdf output of this example is also attached.
I had not previously worked with front end controls. As write time and run time are so close in Mathematica, we have fairly unique capacity to muck about with the structure of the work environment; automatically updating and evaluating cells. I hope this proves interesting.
DavidDavid Gathercole2017-06-05T16:19:53ZAccessing camera using .Net ?
http://community.wolfram.com/groups/-/m/t/1131472
I am trying to read images from a camera using NETLink. The documentation and example code for the camera API is located at [This link] (https://www.ximea.com/support/wiki/apis/XiAPINET). The code seems to work until I try to read out a parameter from the camera.
Needs["NETLink`"];
InstallNET[];
LoadNETAssembly["C:\\XIMEA\\API\\x64"];
LoadNETType["xiApi.NET.xiCam"];
myCam = NETNew["xiApi.NET.xiCam"];
out = 0;
myCam@GetParam["PRM.EXPOSURE", out];
The last line of code produces this error:
> NET::netexcptn: A .NET exception occurred: xiApi.NET.xiExc: GetParam PRM.EXPOSURE: Parameter is not supported
at xiApi.NET.xiCam.GetParam(String prm, Int32& val).
Any ideas what I am doing wrong?Jeff Burns2017-06-30T18:02:37ZInfinite expression encountered problem
http://community.wolfram.com/groups/-/m/t/1151487
Hi All,
I would like to solve two ODEs coupled together using NDSolve, please see below for my code. Basically, I have two variables, y'[x] and g'[x] (not g''[x]). The reason why I formulate my ODE using g''[x] is that I have integral boundary condition on g'[x], so I use the trick from [here][1] to reformulate my equation. I will be happy to provide an original form of the equation if there is a question that is related to this part.
My problem is Mathematica complaints about "Infinite expression encountered" for my second equation(g''[x]) part. My guess is that in the denominator of this equation, It has y[x] term which equals to 0 at left boundary. Even though I tried to avoid this by calculating y[-1+eps]=eps, It appears to still have this issue.
ClearAll["Global`*"];
w = 0.7;
q = 0.5*w*(1 - x^2);
kappa = 1.469;
sol = With[{eps = 10^-5}, NDSolve[{
y'[x] == (560*y[x]^0.5*q - 64*y[x]^4 + 6*w^(7/8)*(72*kappa - 77)*x*q*(-w*y[x]))/(3*w^(7/8)*(96*kappa - 77)*q^2),
g''[x] == (2695*y[x]^0.5*q - (864*kappa - 385)*y[x]^4 - 693*w^(7/8)*kappa*y[x]*q*(-w*x))/(9*(96*kappa - 77)*y[x]^3),
y[-1 + eps] == eps,
g[1 - eps] - g[-1 + eps] == 0,
g'[0] == 0}, {y[x], g'[x]},
{x, -1 + 0.001, 1 - 0.001}]];
Methods that I have tried is to give initial condition to Mathematica like below. (As suggested by [here][2]). However, I encountered error " Initial conditions should be specified at a single point."
ClearAll["Global`*"];
w = 0.7;
q = 0.5*w*(1 - x^2);
kappa = 1.469;
sol = With[{eps = 10^-5}, NDSolve[{
y'[x] == (560*y[x]^0.5*q - 64*y[x]^4 + 6*w^(7/8)*(72*kappa - 77)*x*q*(-w*y[x]))/(3*w^(7/8)*(96*kappa - 77)*q^2),
g''[x] == (2695*y[x]^0.5*q - (864*kappa - 385)*y[x]^4 - 693*w^(7/8)*kappa*y[x]*q*(-w*x))/(9*(96*kappa - 77)*y[x]^3),
y[-1 + eps] == eps, g[1 - eps] - g[-1 + eps] == 0,
g'[0] == 0}, {y[x], g'[x]},
{x, -1 + 0.001, 1 - 0.001},
Method -> {"Shooting",
"StartingInitialConditions" -> {y[-1 + eps] == eps,
g'[eps] == 0}}]];
Any help will be greatly appreciated! Also, I have a related question: Right now, I have 2 ODEs, but I am planning to add transient terms d/dt for each variable I am solving at here. Let's assume Mathematica could solve these ODEs. Is it possible to solve the transient PDEs? It will be a transient 1D problem, and from the NDSolve documentation, it seems that Mathematica should have capabilities to solve it.
------------------------Update for the original equation-----------------
My x range is from -1 to 1. Here are equations that I would like to solve
![My equation][3]
I also noticed [here][4] that this problem can be formulated as an optimization problem. However, I am having difficulty in this line of code on that link:
sol2[bc2_, {xmin_, xmax_}] :=
NDSolveValue[{y''[x] - y[x] == (x^2), y'[0] == bc2, y[0] == 1}, y, {x, xmin, xmax}];
int[bc2_?NumericQ] := NIntegrate[sol2[bc2, {0, 2}][x], {x, 0, 2}];
**y2 = sol2[NMinimize[(int[bc2V] - 5)^2, bc2V][[-1, -1, -1]], {-3, 3}]**
Plot[{y1[x], y2[x]}, {x, -3, 3}]
I don't know what does **[-1,-1,-1]** has to do with the original problem or formulation.
[1]: https://mathematica.stackexchange.com/questions/86403/solve-differential-equation-using-a-integral-form-boundary-condition
[2]: https://mathematica.stackexchange.com/questions/24312/infinite-expression-error-from-ndsolve
[3]: http://community.wolfram.com//c/portal/getImageAttachment?filename=CodeCogsEqn.png&userId=1150579
[4]: https://mathematica.stackexchange.com/questions/86403/solve-differential-equation-using-a-integral-form-boundary-conditionKai D2017-07-23T17:32:53Z[GIF] Septafoil (Stereographic Projection of a Septafoil Knot)
http://community.wolfram.com/groups/-/m/t/1152144
![Stereographic projection of spheres along a septafoil knot][1]
**Septafoil**
This is the same idea as [_Intertwine_][2], but with the septafoil knot $7_1$ rather than the trefoil knot. Read [the post on _Intertwine_][2] for more details on the code, which is mostly identical. The one notable change is that I've added noise to each of the frames in the animation. This is accomplished by creating a single noisy image of the right size:
noise = ImageEffect[Graphics[Background -> None, ImageSize -> 540], {"PoissonNoise", .4}];
and then combining it with each frame using `ImageMultiply`. Also, after exporting I reduced the color palette to 40 colors and dithered the frames using [gifsicle][3].
Here's the rest of the code (as with _Intertwine_, I used `MaxRecursion -> 5` for the final export, but this is too computationally intensive to use inside `Manipulate`):
Stereo3D[{x1_, y1_, x2_, y2_}] := {x1/(1 - y2), y1/(1 - y2), x2/(1 - y2)};
pqtorus[t_, θ_, p_, q_] := 1/Sqrt[2] Flatten[ReIm /@ {E^(p I (t + θ/p)), E^(q I t)}];
DynamicModule[{p = 7, q = 2, n = 50,
viewpoint = 10. {Cos[-4 π/5], Sin[-4 π/5], 0}, point, basis,
sphere, cols = RGBColor /@ {"#7AC7C4", "#F73859", "#384259"}},
point[t_, θ_] := pqtorus[t + θ, 0, p, q];
basis[t_, θ_] := NullSpace[{point[t, θ]}];
sphere[t_, θ_, ψ_, ϕ_] :=
Cos[.1] point[t, θ] + Sin[.1] Total[{Cos[ψ] Sin[ϕ], Sin[ψ] Sin[ϕ], Cos[ϕ]}*basis[t, θ]];
Manipulate[
ImageMultiply[
ParametricPlot3D[
Evaluate@
Table[Stereo3D[sphere[t, θ, ψ, ϕ]], {t, 0., 2 π - 2 π/(q n), 2 π/(q n)}],
{ψ, 0, π}, {ϕ, 0, 2 π},
Mesh -> None, PlotRange -> 4, ViewPoint -> viewpoint,
ViewAngle -> π/80, ImageSize -> 540, Boxed -> False,
PlotStyle -> White, ViewVertical -> {0, 0, 1}, Axes -> None,
Background -> cols[[-1]],
Lighting -> {{"Point", cols[[1]], 2 {Cos[7 π/10], Sin[7 π/10], 0}},
{"Point", cols[[2]], 2 {Cos[17 π/10], Sin[17 π/10], 0}} ,
{"Ambient", cols[[-1]], viewpoint}}],
noise],
{θ, 0, 2 π/(q n)}]
]
[1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=knots65a.gif&userId=610054
[2]: http://community.wolfram.com/groups/-/m/t/1144941
[3]: http://www.lcdf.org/gifsicle/Clayton Shonkwiler2017-07-24T15:30:57ZUsing (MinimalPolynomial[ x^(1/x)-1,b]==(1 + b)^x-x).
http://community.wolfram.com/groups/-/m/t/1152134
The MRB constant is defined at [http://mathworld.wolfram.com/MRBConstant.htm][1]l.
In looking for a faster method of calculating digits of the MRB constant, Sum[(1-)^x (x^(1/x)-1))],
by the seemingly difficult method of solving minimal polynomials, I came across the following
where it seems Table[Expand[(1 + b)^x-x], {x, 1, 145}] = Table[MinimalPolynomial[x^(1/x)-1, b], {x, 1, 145}] for all x
except for "numbers of the form (kp)^p for prime p and k=1,2,3,...," OEIS [A097764][2] :
(real = Table[MinimalPolynomial[-1 + x^(1/x), b], {x, 1, 145}]);
(guess = Table[Expand[(1 + b)^x]-x, {x, 1, 145}]);
real - guess // TableForm (*shows the equality for all but OEIS [A097764][3] *)
This equality could become very useful because as x gets large the minimal polynomial of x^(1/x)-1 becomes exceedingly difficult to compute!
Here is how this equality can be used:
Partial sum(s) of the MRB constant can be found through a sum of NSolves,
y = 1000; N[-y - Sum[b /. (NSolve[(1 + b)^n == n, b, Reals][[1]]), {n, 1, y}]]
giving a more correct result than
NSum[(-1)^n (n^(1/n) - 1), {n, 1, 1000}]
because it removes the imaginary part given by E^(I*Pi x) i.e. (-1)^x.
[1]: http://mathworld.wolfram.com/MRBConstant.html
[2]: https://oeis.org/A097764
[3]: https://oeis.org/A097764Marvin Ray Burns2017-07-24T15:11:14ZSerial DeviceOpen specifying port name and options
http://community.wolfram.com/groups/-/m/t/1151384
I'm trying to open a Serial device connection, specifying both the port name and connection options (baud rate, handshake method, etc.). Here's a screenshot from the Serial documentation:
![Serial DeviceOpen documentation][1]
This suggests that you can *either* specify a port name *or* specify connection options when opening a port, not both. If I try to use both, I get an ::argt message:
![DeviceOpen called with 3 arguments; 1 or 2 arguments are expected.][2]
I figure I must be missing something here.
[1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=serialdeviceopen.png&userId=20938
[2]: http://community.wolfram.com//c/portal/getImageAttachment?filename=serialdeviceopenerror.png&userId=20938Jesse Friedman2017-07-23T16:12:36Z[✓] Inverse Z-Transform of z/(z - a) with different region of convergence?
http://community.wolfram.com/groups/-/m/t/1147972
Hello everyone. I tried to get the inverse Z transform of z/(z - a) with different ROC.
InverseZTransform[z/(z - a), z, n, Assumptions -> Abs[z] > Abs[a]]
InverseZTransform[z/(z - a), z, n, Assumptions -> Abs[z] < Abs[a]]
Both cases give me the following output a^n. Actually the inverse Z transform is
(a^n) HeavisideTheta[n] when ROC is Abs[z] > Abs[a],
and is
(-a^n) HeavisideTheta[-n-1] when ROC is Abs[z] < Abs[a].
How can I get these outputs?
Thank you very much.Gennaro Arguzzi2017-07-17T19:42:48ZPairs Trading with Copulas
http://community.wolfram.com/groups/-/m/t/1111149
**Introduction**
In a previous post, [Copulas in Risk Management][1], I covered the theory and applications of copulas in the area of risk management, pointing out the potential benefits of the approach and how it could be used to improve estimates of Value-at-Risk by incorporating important empirical features of asset processes, such as asymmetric correlation and heavy tails.
In this post I take a different tack, to show how copula models can be applied in pairs trading and statistical arbitrage strategies.
This is not a new concept - it stems from when copulas began to be widely adopted in financial engineering, risk management and credit derivatives modeling. But it remains relatively under-explored compared to more traditional techniques in this field. Fresh research suggests that it may be a useful adjunct to the more common methods applied in pairs trading, and may even be a more robust methodology altogether, as we shall see.
**Traditional Approaches to Pairs Trading**
Researchers often use simple linear correlation or distance metrics as the basis for their statistical arbitrage strategies. The problem is that statistical relationships may be nonlinear or nonstationary. Correlations (and betas) that have fluctuated in a defined range over a considerable period of time may suddenly break down, producing substantial losses.
A more sophisticated technique is the Kalman Filter, which can be used as a means of dynamically updating the the estimated correlation or relative beta between pairs (or portfolios) of stocks, a technique I have written about in the post Statistical Arbitrage with the Kalman Filter.
Another commonly employed econometric technique relies on cointegration relationships between pairs or small portfolios of stocks, as described in my post on Developing Statistical Arbitrage Strategies Using Cointegration. The central idea is that, in theory, cointegration is a more stable and reliable basis for assessing the relationship between stocks than correlation.
Researchers often use a combination of methods, for example by requiring stocks to be both cointegrated and with stable, high correlation throughout the in-sample formation period in which betas are estimated.
In all these cases, however, the challenge is that, no matter how they are derived or estimated, statistical relationships have a tendency towards instability. Even a combination of several of these methods often fails to detect signs of a breakdown in statistical relationships. There is even evidence that cointegration models are no more robust or reliable than simple correlations. For example, in his paper On the Persistence of Cointegration in Pairs Trading, Matthew Clegg assess the persistence of cointegration among U.S. equities in the calendar years 2002-2012, comprising over 860,000 pairs in total. He concludes that “the evidence does not support the hypothesis that cointegration is a persistent property”.
**Pairs Trading in the S&P500 and Nasdaq Indices**
To illustrate the copula methodology I will use an equity pair comprising the S&P 500 and Nasdaq indices. These are not tradable assets, but the approach is the same regardless and will serve for the purposes of demonstrating the technique.
We begin by gathering daily data on the indices and calculating the log returns series. We will use the data from 2010 to 2015 as the in-sample “formation” period, and test the strategy out of sample on data from Jan 2016-Feb 2017.
![enter image description here][2]
![enter image description here][3]
![enter image description here][4]
![enter image description here][5]
![enter image description here][6]
The chart below shows a scatter plot of daily percentage log returns on the SP500 and NASDAQ indices.
![enter image description here][7]
![enter image description here][8]
**MODELING**
**Marginal Distribution Fitting**
In the post Copulas in Risk Management it was shown that the returns series for the two indices were well-represented by Student T distributions. I replicate that analysis here, estimating the parameters by maximum likelihood and proceed from there to test each distribution for goodness of fit. In each case, the Student T distribution appears to provide an adequate fit for both series.
![enter image description here][9]
![enter image description here][10]
![enter image description here][11]
![enter image description here][12]
**Copula Calibration**
We next calibrate the parameters for the Gaussian copula by maximum likelihood, from which we derive the joint distribution for returns in the two indices via Sklar’s decomposition. This will be used directly in the pairs trading algorithm. As pointed out previously, there are several alternatives to MLE, including the Method of Moments, for example, and these are listed in the Mathematica documentation for the EstimatedDistrubution function.
![enter image description here][13]
![enter image description here][14]
![enter image description here][15]
![enter image description here][16]
![enter image description here][17]
![enter image description here][18]
**Pairs Trading with the Copula Model**
Once we have successfully fitted marginal distributions for the two series and a copula distribution to describe their relationship, we are able to derive the joint distribution. This means that we can directly calculate the joint probability of each pair of data observations. So, for instance, we find that the probability of a return in the S&P500 of 5% or more, together with a return in the Nasdaq of 1% or higher, is approximately 0.2%:
![enter image description here][19]
![enter image description here][20]
So the way we test our model is to calculate the daily returns for the two indices during the-out-of sample period from Jan 2016 to Feb 2017 and compute the probability of each pair of daily observations. On days where we see observation pairs with abnormally low estimated probabilities, we trade the pair accordingly over the following day.
Naturally, there are multiple issues with this simplistic approach. To begin with, the indices are not tradable and if they were we would have to account for transaction costs including the bid-offer spread. Then there is the issue of determining where to set the probability threshold for initiating a trade. We also need to decide on criteria to try to optimize the trade holding period or trade exit rules. And, finally, we need to think about trade expression: for example, we might attempt to trade both legs passively, perhaps crossing the spread to fill the remaining leg when an order for one of the pairs is filled.
But none of these issues are specific to the copula approach - they apply equally to all of the methods discussed previously. So, for the sake of clarity, I am going to ignore them. In this analysis I pick a threshold probability level of 15% and assume we hold the trade for one day only, opening and closing the trade at the start and end of the day after we receive a signal. In computing the returns for each trade I ignore any transaction costs.
First, we gather data for the test period:
![enter image description here][21]
Next, we use the estimated joint distribution to compute the probability of each daily observation of index returns. We gather the daily returns series and associated probability series into a single temporal variable:
![enter image description here][22]
![enter image description here][23]
We plot the time series of index returns and associated probabilities as follows:
![enter image description here][24]
![enter image description here][25]
![enter image description here][26]
![enter image description here][27]
**Trade Signal Generation**
The table below lists the index returns and joint probabilities over the first several days of the series. The sequence of trade signals is as follows:
After a very low probability reading for 2016/1/4, we take equally weighted positions short the S&P500 Index and long the Nasdaq index on 2016/1/5. We close the position at the end of the day, producing a total return of 0.44%. Similar signals are generated on 2016/1/6, 2016/1/7, 2016/1/8, 2016/1/13 , 2016/1/15 and 2016/1/20 (assuming a 15% probability threshold). We take the reverse trade (Buy the S&P500, Sell the Nasdaq) on only one occasion in the initial part of the sample, on 2016/1/14.
![enter image description here][28]
![enter image description here][29]
**Pairs Trading Strategy Results**
We are now ready to apply the trading algorithm to the entire sample and chart the resulting P&L.
![enter image description here][30]
![enter image description here][31]
![enter image description here][32]
![enter image description here][33]
**Comment on Strategy Performance**
The performance of the strategy over the out-of-sample period, at just under 4%, can hardly be described as stellar. But this is largely due to the dampening of volatility seen in both indices over the last year, which is reflected in the progressively lower volatility of joint probabilities over the course of the test period. Such variations in signal frequency and trading strategy performance are commonplace in any statistical arbitrage strategy, regardless of the methodology used to generate the signals.
The obvious remedy is to create similar trading algorithms for a large number of pairs and combine them together in an overall portfolio that will produce a sufficient number of signals and trading opportunities to make the performance sufficiently attractive. One of the benefits of statistical arbitrage strategies developed in this way is their highly efficient use of capital, since the combination of long and short positions minimizes the margin requirement for each trade and for the portfolio as a whole.
Finally, it is worth noting here that, in principle, one could easily create similar copula-based arbitrage strategies for triplets, quadruplets, or any (reasonably small) number of assets. The principle restriction lies in the increasing difficulty of estimating the copulas and joint densities, given the slow convergence of the MLE method.
**Recent Research**
In the last few years several researchers have begun exploring the application of copulas as a basis for statistical arbitrage. In their paper “Nonlinear dependence modeling with bivariate copulas: Statistical arbitrage pairs trading on the S&P 100”, Krauss and Stubinger apply the copula approach to pairs drawn from the universe of S&P 100 index constituents, with promising results. They conclude that their “findings pose a severe challenge to the semi-strong form of market efficiency and demonstrate a sophisticated yet profitable alternative to classical pairs trading”.
In the paper by Rad, et al., cited below, the researchers compare several different methods for pairs trading strategies. They find that all of the tested methods produce economically significant returns, but only the performance of the copula-based approach remains consistent after 2009. Further, the copula method shows better performance for its unconverged trades compared to those of the other methods.
**Conclusion**
The application of copulas to statistical arbitrage strategies is an interesting and relatively under-explored alternative to the usual distance and correlation based methods. In addition to its sound theoretical underpinnings, the copula approach appears to offer greater consistency in performance compared to traditional techniques, whose efficacy has declined since the financial crisis on 2008/09. The benefits of the approach must be weighed against its greater computational complexity, although with the growth in the power of modeling software in recent years this represents less of an obstacle than it has previously.
**References**
Clegg., M., , On the Persistence of Cointegration in Pairs Trading, Jan. 2014
Krauss, C. and Stubinger , J., Nonlinear dependence modeling with bivariate copulas: Statistical arbitrage pairs trading on the S&P 100, Institut für Wirtschaftspolitik und Quantitative Wirtschaftsforschung, No 15/2015.
Rad, H., Kwong, R., Low, Y. and Faff, R., The profitability of pairs trading strategies: distance, cointegration, and copula methods, Quantitative Finance, DOI: org/10.1080/14697688.2016.1164337, 2015
[1]: http://jonathankinlay.com/2017/01/copulas-risk-management/
[2]: http://community.wolfram.com//c/portal/getImageAttachment?filename=PairsTradingwithCopulas_1.gif&userId=773999
[3]: http://community.wolfram.com//c/portal/getImageAttachment?filename=PairsTradingwithCopulas_2.png&userId=773999
[4]: http://community.wolfram.com//c/portal/getImageAttachment?filename=7037Fig1.png&userId=773999
[5]: http://community.wolfram.com//c/portal/getImageAttachment?filename=PairsTradingwithCopulas_3.gif&userId=773999
[6]: http://community.wolfram.com//c/portal/getImageAttachment?filename=PairsTradingwithCopulas_4.gif&userId=773999
[7]: http://community.wolfram.com//c/portal/getImageAttachment?filename=PairsTradingwithCopulas_5.png&userId=773999
[8]: http://community.wolfram.com//c/portal/getImageAttachment?filename=PairsTradingwithCopulas_6.gif&userId=773999
[9]: http://community.wolfram.com//c/portal/getImageAttachment?filename=PairsTradingwithCopulas_7.gif&userId=773999
[10]: http://community.wolfram.com//c/portal/getImageAttachment?filename=PairsTradingwithCopulas_8.png&userId=773999
[11]: http://community.wolfram.com//c/portal/getImageAttachment?filename=PairsTradingwithCopulas_10.gif&userId=773999
[12]: http://community.wolfram.com//c/portal/getImageAttachment?filename=4282Fig2.png&userId=773999
[13]: http://community.wolfram.com//c/portal/getImageAttachment?filename=PairsTradingwithCopulas_16.gif&userId=773999
[14]: http://community.wolfram.com//c/portal/getImageAttachment?filename=PairsTradingwithCopulas_17.png&userId=773999
[15]: http://community.wolfram.com//c/portal/getImageAttachment?filename=PairsTradingwithCopulas_18.png&userId=773999
[16]: http://community.wolfram.com//c/portal/getImageAttachment?filename=PairsTradingwithCopulas_19.gif&userId=773999
[17]: http://community.wolfram.com//c/portal/getImageAttachment?filename=PairsTradingwithCopulas_20.png&userId=773999
[18]: http://community.wolfram.com//c/portal/getImageAttachment?filename=PairsTradingwithCopulas_21.gif&userId=773999
[19]: http://community.wolfram.com//c/portal/getImageAttachment?filename=PairsTradingwithCopulas_22.png&userId=773999
[20]: http://community.wolfram.com//c/portal/getImageAttachment?filename=PairsTradingwithCopulas_23.png&userId=773999
[21]: http://community.wolfram.com//c/portal/getImageAttachment?filename=PairsTradingwithCopulas_24.gif&userId=773999
[22]: http://community.wolfram.com//c/portal/getImageAttachment?filename=PairsTradingwithCopulas_25.gif&userId=773999
[23]: http://community.wolfram.com//c/portal/getImageAttachment?filename=PairsTradingwithCopulas_26.gif&userId=773999
[24]: http://community.wolfram.com//c/portal/getImageAttachment?filename=PairsTradingwithCopulas_27.png&userId=773999
[25]: http://community.wolfram.com//c/portal/getImageAttachment?filename=PairsTradingwithCopulas_28.gif&userId=773999
[26]: http://community.wolfram.com//c/portal/getImageAttachment?filename=PairsTradingwithCopulas_29.png&userId=773999
[27]: http://community.wolfram.com//c/portal/getImageAttachment?filename=PairsTradingwithCopulas_30.gif&userId=773999
[28]: http://community.wolfram.com//c/portal/getImageAttachment?filename=PairsTradingwithCopulas_31.gif&userId=773999
[29]: http://community.wolfram.com//c/portal/getImageAttachment?filename=2430Fig3.png&userId=773999
[30]: http://community.wolfram.com//c/portal/getImageAttachment?filename=PairsTradingwithCopulas_32.gif&userId=773999
[31]: http://community.wolfram.com//c/portal/getImageAttachment?filename=PairsTradingwithCopulas_33.gif&userId=773999
[32]: http://community.wolfram.com//c/portal/getImageAttachment?filename=PairsTradingwithCopulas_34.png&userId=773999
[33]: http://community.wolfram.com//c/portal/getImageAttachment?filename=PairsTradingwithCopulas_35.gif&userId=773999Jonathan Kinlay2017-05-30T17:41:07Z