# Derivatives.ml

(* Copyright INRIA and Microsoft Corporation, 2008-2013. *)

INCLUDE "preamble.ml"

let title _ = <:text<Derivative in Terms of Lower-Order Derivatives>>

let_service Derivatives
(eqn : diffeq maple)
(notation : string)
(var : name maple)
(order : int = Constants.default_order) :
DC.sec_entities * unit with { title = title } =

(* let sf = SF.sf_of_id sf_id and rep = SF.rep_of_id sf_id in *)
(* let eqn = sf.SF.lode in *)
(* let var = FEqn.var_of_t (DB.eqn_of_id (sf.SF.ode_id)) in *)
let res = <<
proc(m_eq, m_order, x, $) local diff_op, Alg, sprem, deq, dx; diff_op := subs( {seq(diff(y(x), [x$ i]) = dx^i, i = 0..DDMF:-ode_order(m_eq))},
m_eq);
Alg := Ore_algebra:-diff_algebra(
[dx, x],
op(map(a->[comm,a], remove(has, indets(m_eq), x)))
);
sprem :=
collect(
Ore_algebra:-skew_pdiv(dx^m_order, diff_op, dx, Alg),
dx, factor);
deq :=
diff(y(x), [x $m_order]) = 1/sprem[1] * Ore_algebra:-applyopr(sprem[3], y(x), Alg); subs(y = __DDMF_rep, convert(deq, Diff)) end proc($(eqn),$(int:order),$(var))
>> in

(* A hack to use notation (without evaluation) in the displayed formula. *)
(* Not so nice: this way we have always d/dx and never \partial. *)
let regexp =
Str.regexp_string
("{\\rm \\_\\_DDMF\\_rep} \\left( " ^ <:latex< $(var) >> ^ " \\right)") in let result_as_latex = Str.global_replace regexp notation <:latex<$(res) >> in
let par = <:par<<:dmath< \$(str: result_as_latex). >>>> in

(DC.section (title ()) par, ())


Generated by GNU Enscript 1.6.5.90.