How to find nth derivative of a function using leibnitz rule in wxMaxima? - maxima

I know the pseudo code.
It goes something like this:
if f(x): g(x)*h(x) then u:g(x) and v:h(x)
for i:0 thru n do block
( binomial(n,i)*diff(u,x,i)*diff(v,x,n-i), i:i+1);
I'm not able to actually execute the code. I get some thing I don't need. Please
help me.
Thankyou

kill(all)$
y:x^4*log(x);
u:log(x);
v:x^4;
n:4;
lsum(binomial(n,i)*diff(u,x,n-i)*diff(v,x,i),i,[0,1,2,3,4]);

Related

Adding labels to my programming language

Actually I am writting a programming language in Lua. It was quite fun. I've wrote a bit of standard library (stack op and simple io). Then I've thought about labels. It would look like in assembly. While and for loop aren't funny in any bit so programming in that language can be quite challenging. Here are some requirements for this system:
Label stack (or array, dictionary) must be accessible from global context.
Jump instruction handler will be in separate file.
This is how my label-handling function look like:
function handleLabel(name,currentLine)
end
I have no idea how to implement this kind of magic. First I've thought about that:
LabelLineIDS = {}
Labels = {}
Labelamount = 1;
function handleLabel(name,currentLine)
LabelLineIDS[Labelamount]=currentline
Labels[Labelamount]=name
Labelamount=Labelamount+1
end
-- In file "jump.lua":
local function has_value (tab, val)
for index, value in ipairs(tab) do
if value == val then
return index
end
end
print ("Error: Label not defined.") -- Bail out.
os.exit(1)
end
local function _onlabel()
local labelName = globalparams --Globalparams variable contain parameters to each function, at the moment
--this will contain label name. It _can_ be nil.
return LabelLineIDS[has_value(Labels, labelName)]
end
CurrLine = _onlabel() --Currline - current line that get's parsed.
--1 command per one line.
But I'm unsure is this well written or even work. Can you give me idea how to parse labels in my programming language (and write jump functions)? Or if my code is pretty ok at the moment, can you help me to improve it?
Using line counter in my parser I've decided to implement gotos like we can see in BASIC. Thanks everyone for help.

lua - loadfile is executing right away and i can't figure out why

I was under the impression that doing something like this:
local f = assert (loadfile('/var/www/widgets/widgetlookup.lua'))('13')
would just load the contents of widgetlookup.lua into the variable "f" and then to run the code, i could do this:
f()
However, what's happening is that as soon as I load the file, it's executing. I know because widgetlookup.lua prints out a string with the results. Ultimately, I need to capture the results of the script in a variable
Can you tell me what I'm doing wrong? If you need to see the contents of widgetlookup.lua please just say the word and i will post. Just didn't want to clutter up the question with unnecessary information.
Thanks.
EDIT 1
I changed my code to look like this:
local f = assert (loadfile('/var/www/widgets/widgetlookup.lua'))
local p = f(13)
And now code waits to run until i hit the second line... but I need to know how to capture the output of the script as a variable....
print(p) current returns a null value.
You're calling it with that ('13') at the end.
You want this:
local f = assert (loadfile('/var/www/widgets/widgetlookup.lua'))

wxMaxima: how to get decimal number results?

This should be easy but I am struggling on that.
I googled already but nothing seems to work.
(I am using wxMaxima 15.08.1 on Windows)
My example code looks like this:
kill (all);
numer:true;
sigma_z: 1000.0$ /*[N/mm²]*/
sigma_b_zul : simga_z*0.7;
sigma_b_zul : simga_z*0.7, numer;
sigma_b_zul : simga_z*0.7, numer:true;
float(sigma_b_zul);
the output is every time:
0.7 simga_z
the next cell looks like:
d_d: 1000$ /*dfd*/
sigma_g_f_d: d_d * 0.7;
the result is:
7.0E+2
I am completely clueless why maxima behaves like this. Can anyone help?
The variable you define is
sigma_z: 1000.0$ /*[N/mm²]*/
but then you call
simga_z*0.7;
Please, notice the difference between sigma_z and simga_z.

Error loading Partial View script (file: ~/Views/MacroPartials/ezSearch.cshtml)

I am having some issue with ezSearch (Umbraco) and it is very similar to this one
http://our.umbraco.org/projects/website-utilities/ezsearch/bugs-feedback-suggestions/48460-Search-error-when-searching-for-test-keyword?p=0#comment176864
Here is the screenshot of error
http://our.umbraco.org/media/upload/e08b702e-b738-42a4-81d8-382a4400b96a/error.jpg
Can anyone hep me with this please?
Thank you,
Adi
I'm using ezSearch, and from reading the ezSearch.cshtml this looks like a bug if the query passed to the macro is " ". That is to say, if the search is empty, it works ok, but if the search is an actual quoted space then the line in the cshtml: (line 60 in my version)
// Check the search term isn't empty
if(!string.IsNullOrWhiteSpace(model.SearchTerm))
{
// Tokenize the search term
model.SearchTerms = Tokenize(model.SearchTerm);
...
etc.
...
}
ends up with a bad set of tokens in model.SearchTerms.
it's a bit of a hack, but i think putting this before that if statement will help.
model.SearchTerm = model.SearchTerm.Replace("\"","").Replace(" ","").Replace("'","");
..hope that helps.
'ingie.

Lua arguments passed to function in table are nil

I'm trying to get a handle on how OOP is done in Lua, and I thought I had a simple way to do it but it isn't working and I'm just not seeing the reason. Here's what I'm trying:
Person = { };
function Person:newPerson(inName)
print(inName);
p = { };
p.myName = inName;
function p:sayHello()
print ("Hello, my name is " .. self.myName);
end
return p;
end
Frank = Person.newPerson("Frank");
Frank:sayHello();
FYI, I'm working with the Corona SDK, although I am assuming that doesn't make a difference (except that's where print() comes from I believe). In any case, the part that's killing me is that inName is nil as reported by print(inName)... therefore, myName is obviously set to nil so calls to sayHello() fail (although they work fine if I hardcode a value for myName, which leads me to think the basic structure I'm trying is sound, but I've got to be missing something simple). It looks, as far as I can tell, like the value of inName is not being set when newPerson() is called, but I can't for the life of me figure out why; I don't see why it's not just like any other function call.
Any help would be appreciated. Thanks!
Remember that this:
function Person:newPerson(inName)
Is equivalent to this:
function Person.newPerson(self, inName)
Therefore, when you do this:
Person.newPerson("Frank");
You are passing one parameter to a function that expects two. You probably don't want newPerson to be created with :.
Try
Frank = Person:newPerson("Frank");

Resources