how to make maxima create equation like i give in attachment
Subject: how to make maxima create equation like i give in attachment
From: Stavros Macrakis
Date: Thu, 13 Jan 2011 08:19:22 -0500
Should be
f[n,k] := concat('f_,n,"_",k)(s)
to produce a function call, not a string. So the complete solution is:
f[n,k] := concat('f_,n,"_",k)(s)$
df[n,k] :=
if n=0 then 0
else 'diff(f[2*n,k],s)=x*((k-1)*sqrt(n-k+2)*f[2*n,k-1]-k*sqrt(n-k+1)*f[2*n,k+1])$
desolve( makelist( df[2,k],k,1,3 ), makelist(f[4,k],k,1,3) );
Remember that f[...]:= defines a *memoizing* function, so you need to kill f
if you want to redefine it.
-s
On Thu, Jan 13, 2011 at 08:08, Stavros Macrakis <macrakis at alum.mit.edu>wrote:
> Sorry for the bug in atvalue.
>
> You can replace the f[i,j]'s with the atomic f_i_j using subst(
> concat("f_",i,"_",j), f[i,j], ... ). Or even easier, define:
>
> f[n,k] := concat("f_",n,"_",k)
>
> and then whenever you write f[n,k], it will evaluate to f_n_k.
>
> You also need to either declare all the f_n_k's as depending on s or,
> better, write 'diff(...) instead of diff(...).
>
> -s
>
> On Thu, Jan 13, 2011 at 03:44, razif razali <razif66 at gmail.com> wrote:
>
>> Macrakis,
>>
>> Here example that I used 'desolve' for my problem,
>> --------------------------------------------------------------------
>> eq1:diff(f(s),s)=-sqrt(2)*g(s)*k;
>>
>> eq2:diff(g(s),s)=k*(sqrt(2)*f(s)-2*h(s));
>>
>> eq3:diff(h(s),s)=2*k*g(s);
>>
>> atvalue(f(s),s=0,f0);
>>
>> atvalue(g(s),s=0,0);
>>
>> atvalue(h(s),s=0,0);
>>
>> desolve([eq1,eq2,eq3],[f(s),g(s),h(s)]);
>>
>> nonzero;
>> ---------------------------------------------------
>>
>> I manually replace f[4,1] to f(s), f[4,2] to g(s) and f[4,3] to h(s)
>> because 'atvalue' can't accept f[4,1](s), it will give error.
>>
>> so how to make maxima automatically convert all those f[n,k] function into
>> f(s),g(s),h(s).....n(s) in code below so that I can used code above to solve
>> my problem?
>>
>> --------------------------------------
>> depends(f,s);
>> df[n,k] :=
>> if n=0
>> then 0
>> else
>>
>> diff(f[2*n,k],s)=x*((k-1)*sqrt(n-k+2)*f[2*n,k-1]-k*sqrt(n-k+1)*f[2*n,k+1]);
>> eqs:makelist(df[2,k],k,1,3);
>> -----------------------------------------
>>
>> or maybe there some way that we didn't need to replace the function but
>> make maxima solve it automatically?
>>
>> On Thu, Jan 13, 2011 at 12:41 PM, Stavros Macrakis <macrakis at alum.mit.edu
>> > wrote:
>>
>>> Razif,
>>>
>>> In Maxima, you do not assign values to derivatives etc. You write
>>> equations and can store the equations in variables or lists.
>>>
>>> Let me give an example with ordinary (not differential) equations.
>>>
>>> eq1: x = y+3$
>>> eq2: x*5=2*y-7$
>>>
>>> solve( [eq1, eq2], [x,y]);
>>>
>>> OR
>>>
>>> eqs: [ x = y+3, x*5=2*y-7 ]$
>>> vars: [x,y]$
>>> solve(eqs,vars);
>>>
>>> You can do the same thing for systems of equations using 'makelist':
>>>
>>> eqs: makelist( x[ i ] = x[ i+1 ] + x[ i-1 ] + 1, i , 1, 5 )$
>>> solve( append([x[0]=x[8],x[3]=1],eqs), << add some extra
>>> equations
>>> makelist(x[i],i,0,8)); << list of
>>> variables
>>>
>>> I have not worked with the differential equation solvers for a long time,
>>> so I don't know whether they can solve your equations.
>>>
>>> -s
>>>
>>>
>>>
>>>
>>> On Wed, Jan 12, 2011 at 22:46, razif razali <razif66 at gmail.com> wrote:
>>>
>>>>
>>>>
>>>> On Thu, Jan 6, 2011 at 9:40 PM, Leo Butler <l.butler at ed.ac.uk> wrote:
>>>>
>>>>>
>>>>>
>>>>> On Thu, 6 Jan 2011, razif razali wrote:
>>>>>
>>>>> < Thanks for your reply,
>>>>> < so from your guide, here what I come through,
>>>>> < ------------------
>>>>> < df(n,k):=
>>>>> < block ([],
>>>>> < if n=0
>>>>> < then 0
>>>>> < else
>>>>> <
>>>>> 'diff(f[2*n,k],s)=x*((k-1)*sqrt(n-k+2)*f[2*n,k-1]-k*sqrt(n-k+1)*f[2*n,k+1])
>>>>> < );
>>>>> < makelist(df(1,k),k,1,2);
>>>>> < ------------------------
>>>>> < I can get the equation for diff( f[2,1],s) and diff( f[2,2],s)
>>>>> respectively,
>>>>> <
>>>>> < so next thing is, how can i make diff( f[2,1],s) and diff( f[2,2])
>>>>> hold it value?because when I type again diff( f[2,1],s) in maxima after give
>>>>> code above, it gives
>>>>> < zero. what i want do here is after i get equation diff( f[2,1],s) i
>>>>> want to solve with both equation using ode method to get function of f[2,1]
>>>>> and f[2,2] with
>>>>> < f[2*n,k](0)=A, and value of x and A are not zero...
>>>>>
>>>>> The problem is that Maxima does not know that f[n,k] is a function of
>>>>> s, too. Here is a solution:
>>>>>
>>>>> depends(f,s);
>>>>> df[n,k] := if n=0 then 0 else
>>>>> diff(f[2*n,k],s)=x*((k-1)*sqrt(n-k+2)*f[2*n,k-1]-k*sqrt(n-k+1)*f[2*n,k+1]);
>>>>> .
>>>>> .
>>>>> .
>>>>> Note that I do not use 'diff, because the first line tells Maxima
>>>>> that f is a function of s.
>>>>>
>>>>> Leo
>>>>> --
>>>>> The University of Edinburgh is a charitable body, registered in
>>>>> Scotland, with registration number SC005336.
>>>>>
>>>>> by telling MAXIMA that f[n,k] is function of s to helped me without
>>>> using 'diff but then it still not hold the function for next used?
>>>> the result still the same,
>>>>
>>>> depends(f,s);
>>>> df[n,k] := if n=0 then 0 else
>>>> diff(f[2*n,k],s)=x*((k-1)*sqrt(n-k+2)*f[2*n,k-1]-k*sqrt(n-k+1)*f[2*n,k+1]);
>>>> makelist(df[1,k],k,1,2);
>>>>
>>>> then i got the diff(f [2,1],s) and diff( f[2,2],s)
>>>>
>>>> so how to make diff(f [2,1],s) and diff( f[2,2],s) hold its function so
>>>> that I can solve it using ODE in MAXIMA?because when i type all command
>>>> above and get the result, when i type again diff( f[2,1],s) it give
>>>> nothing...
>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Regards,
>>>>
>>>> RAZIF RAZALI,
>>>> Tutor & Master Student,
>>>> Physics Department,
>>>> Faculty Of Science,
>>>> Universiti Teknologi Malaysia(UTM).
>>>> +60199393606
>>>>
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> Maxima mailing list
>>>> Maxima at math.utexas.edu
>>>> http://www.math.utexas.edu/mailman/listinfo/maxima
>>>>
>>>>
>>>
>>
>>
>> --
>> Regards,
>>
>> RAZIF RAZALI,
>> Tutor & Master Student,
>> Physics Department,
>> Faculty Of Science,
>> Universiti Teknologi Malaysia(UTM).
>> +60199393606
>>
>>
>>
>>
>