mathematica

How to get rid of Log[e] from mathematica output?

Hello My mathematica output is -0.751988 - 0.0708732 Log[e] - 0.0140273 Log[e]^2 But I want mathematica to calculate this expression for me i.e. set Log[e] = 1 and sum the terms. How do I instruct it to do that. I'm assuming it must be treating the functions as complex?? Regards ...

Pattern matching Inequality

I'd like to extract arguments from instances of Inequality. Following doesn't work, any idea why and how to fix it? Inequality[1, Less, x, Less, 2] /. Inequality[a_, _, c_, _, e_] -> {a, c, e} ...

Putting things inside HoldPattern

I'm generating a list of replacement rules like this ops = {LessEqual, GreaterEqual}; ineqRules = Table[HoldPattern[Inequality[a_, op1, c_, _, e_]] -> a == c, {op1, ops}] Above doesn't work because "op1" is hidden from Table by HoldPattern, how do I fix it? This is a follow-up to previous question ...

Input, output and text in one Mathematica cell?

Hi, I'd like to be able to mix text and computation. Something like this: blah blah blah ... blah blah ... The average mass is (m1 + m2 + m3)/3 = 23.4 g ... blah blah blah blah blah ... Where the "(m1... )/3" is the input, and the "23.4" is the output. Right now I only know how to show input in one cell, and the output in...

In Mathematica, what interpolation function is ListPlot using?

Hi, [Screenshot below] I was using ListPlot to draw a smooth line through some data points. But I want to be able to work with the 1st and 2nd derivative of the plot, so I thought I'd create an actual "function" using Interpolation. But as you can see in the picture, it's not smooth. There are some strange spikes when I do Plot[Interp...

Solve recurrence of form p[n,m]==p[n,m-2]+p[n-1,m-1]+p[n-2,m]

I'm trying to solve (find a closed-form solution to) this (Risk odds calculator) recurrence relation: p[n,m] == 2890/7776*p[n,m-2] + 2611/7776*p[n-1,m-1] + 2275/7776*p[n-2,m], p[n,1] == 855/1296 + 441/1296*p[n-1,1], p[3,m] == 295/1296*p[3,m-2] + 420/1296*p[2,m-1], p[2,m] == 55/216, p[1,m] == 0 Mathematica's RSolve function doesn't wor...

How use sub and superscript in Mathematica text, eg: chemical formulas?

Hi, This is not quite a programming question, but it's about a programming environment, so hopefully not too out of place. I need to be able to write chemical formulas in Mathematica text (this is specifically about text, not input/code). Something like: H3O+. But Mathematica can't seem to do this. If you use the normal sub/superscr...

Tools to be used for Image processing

I'm Developing a CBIR (Content based Image Retrieval System) as part of my BE project. Which of the below mentioned tools will be better to be used for image processing?? 1-> Matlab 2-> Mathematica I'm planning to develop this system using java as a front end of the system. which of above systems will be better. Or should I go for som...

Mathematica manipulate variables that are already defined.

Is it possible to use Mathematica's manipulate to change variables that have already been declared? Example: changeme = 8; p = SomeSortOfPlot[changeme]; manipulate[Show[p],{changeme,1,10}] The basic idea is that I want to make a plot with a certain changable value but declare it outside of manipulate. Any ideas? ...

Creating a graph with edges of different colours in Mathematica

I want to create a graph (Graph Theory) where certain edges have a different colour to other edges, which would be used to highlight a path in the graph from one vertex to another. Here are some examples which have different coloured edges http://demonstrations.wolfram.com/AGraphTheoryInterpretationOfTheSumOfTheFirstNIntegers/ and http...

General::ivar: ... is not a valid variable.

I have been trying to decipher what this output means, but I just can't seem to figure it out. Does anybody know what is going on here? I have even tried running the lines one by one and the errors only show up when the final line (show) is executed. ...

ListPlot3D of data on "regular" lattice contained in an "irregular" region

I have the following problem when trying to plot some 3D data in Mathematica. The data are initially computed on a regular lattice, that is I compute data = Flatten[Table[{x,y,f[x,y]},{x,x0,x1,dx},{y,y0,y1,dy}],1] The problem is that f takes real values only in a non-convex subset U on the plane. U is actually quite nasty: a "triangul...

Plot multiple functions in different intervals (Mathematica)

Hi, I need some help in Mathematica. I'm trying to plot functions that are stored in lists like: list = {{3x,1,5},{2x^2,0,4}} I need get an output similar to if I inputted: Show[Plot[3x,{x,1,5}],Plot[2x^2,{x,0,4}]] But I am not quite sure how this is achieved? Thanks in advance ...

Mathematica plot, exclude endpoints?

Hi, Why does the following give me errors about dividing by 0? ParametricPlot[{1/Sin[t], t}, {t, 0, 3 Pi}, Exclusions -> Sin[t] == 0] Power::infy: Infinite expression 1/0 encountered. It does successfully exclude the points at Pi and 2 Pi, but not the points at 0 and 3 Pi. If I exclude the endpoints by changing the interval... Para...

How to print out equations in Mathematica

How do i define, that formula should not be computed, but rather displayed in Traditional format. Here are 2 examples, where 1'st one is displayed like I want it, but 2'nd one is simplified. Print["5. ", Limit[f[x]/g[x], x -> a], "=", Limit[f[x], x -> a]/Limit[g[x], x -> a], ", where ", Limit[g[x], x -> a] != 0]; Print["7. ", Limit[c, x...

An efficient code to determine if a set is a subset of another set

I am looking for an efficient way to determine if a set is a subset of another set in Matlab or Mathematica. Example: Set A = [1 2 3 4] Set B = [4 3] Set C = [3 4 1] Set D = [4 3 2 1] The output should be: Set A Sets B and C belong to set A because A contains all of their elements, therefore, they can be deleted (the order of elements...

Mathematica: Show Complex Numbers in Polar Form

I want to display complex numbers in trig form. For example: z = (-4)^(1/4); I'm not sure what the command for that is, and its silly to write: I thought, that the command was ExpToTrig, but solution can't possibly be just 1+i (Or can it, and I'm misusing it?). How do display complex number in trig form. Edit: Command is ExpToTr...

What's the best way to slurp the contents of a file into a string in Mathematica?

I know this is asked commonly but googling doesn't turn up a definitive answer for Mathematica so I thought it would be valuable to have this on StackOverflow. I've been doing this with Import but it occurred to me that that might be horribly inefficient, Import being such a heavyweight function. So the question is, can you improve on ...

naming variable in mathematica with an algorithm

I'd like to generate definitions of variables using an algorithm. For example: i'd like to run a loop that does the following p=p1 p^2=p2 p^3=p3 so for p^i i'd like to define a variable pi (i is a number). ...

What generates the In/Out CellLabels in Mathematica and how do I change it?

When Mathematica evaluates a cell, it gives the Input cell and Output cell the CellLabels In[$Line]:= and Out[$Line]= where $Line is a counter that gets incremented on each evaluated input. If you input something like TraditionalForm[expr] or TeXForm[expr] (or any other *Form from $OutputForms) then the name of the form also gets added ...