Thanks, I'll implement the function in a different way then.

Regards
Vinayak

On Monday, July 17, 2023 at 6:26:17 PM UTC+5:30 [email protected] wrote:

> Vinayak,
>
> The error is pretty explicit, the function is not implemented in 
> SymEngine. Maybe it is fixed in a newer version of SymEngine. If it is not, 
> you will need to change the formulation of your equation.
>
> Best,
>
> Bruno
>
> On Monday, July 17, 2023 at 3:51:24 AM UTC-4 [email protected] wrote:
>
>> Hello,
>>
>> I am trying to differentiate and then evaluate a function with abs(). As 
>> a simple example, consider the function to be f(x) = abs(x). I use the 
>> following code to first define the symbolic function and then try to 
>> evaluate its derivative:
>>
>>    double x = -2;
>> Differentiation::SD::Expression x_sd("x");
>> const Differentiation::SD::types::substitution_map substitution_map =
>> Differentiation::SD::make_substitution_map(
>> std::pair<Differentiation::SD::Expression, double>{x_sd, x});
>> std::cout << "Evaluate f(x) at x = " << x << std::endl;
>> Differentiation::SD::Expression f = abs(x_sd);
>> std::cout << "Function f(x)= " << f << std::endl;
>> const double computed_f =
>> f.substitute_and_evaluate<double>(substitution_map);
>> std::cout << "Computed Function f(x)= " << computed_f << std::endl;
>>
>> Differentiation::SD::Expression df_dx_sd = f.differentiate(x_sd);
>> std::cout << "Derivative of f: " << df_dx_sd << std::endl;
>> const double computed_df_dx =
>> df_dx_sd.substitute_and_evaluate<double>(substitution_map);
>>
>> std::cout << "Computed df_dx: " << computed_df_dx << std::endl;
>>
>> However, I get the output as below with an error:
>>
>> [ 91%] Built target main
>> [100%] Run main with Debug configuration
>> Evaluate f(x) at x = -2
>> Function f(x)=  abs(x)
>> Computed Function f(x)=  2
>> Derivative of f:  Derivative(abs(x), x)
>> terminate called after throwing an instance of 
>> 'SymEngine::NotImplementedError'
>>   what():  Not Implemented
>> make[3]: *** [CMakeFiles/run.dir/build.make:71: CMakeFiles/run] Aborted 
>> (core dumped)
>> make[2]: *** [CMakeFiles/Makefile2:116: CMakeFiles/run.dir/all] Error 2
>> make[1]: *** [CMakeFiles/Makefile2:123: CMakeFiles/run.dir/rule] Error 2
>> make: *** [Makefile:137: run] Error 2
>>
>> Can someone help me with the issue here?
>>
>> Thanks
>> Vinayak
>>
>

-- 
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see 
https://groups.google.com/d/forum/dealii?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dealii/6b179669-a315-47bb-9886-bdb4cea25709n%40googlegroups.com.

Reply via email to